using System.Collections;
using System.Collections.Generic;
using UnityEngine;

#if UNITY_EDITOR
using UnityEditor;
#endif

public class TransformScaler : MonoBehaviour {

    public float amount = 3.0f;
    Transform [] transforms;

    void LoadTransforms() {
        transforms = GetComponentsInChildren<Transform>();
    }

    void Scale() {
        for(int i = 0; i < transforms.Length; i++) {
            transforms[i].localPosition = transforms[i].localPosition * amount;
        }
    }

#if UNITY_EDITOR
    [CustomEditor(typeof(TransformScaler))]
    public class TransformScalerEditor : Editor{

        TransformScaler ts;

        private void OnEnable() {
            ts = target as TransformScaler;
        }

        public override void OnInspectorGUI() {
            DrawDefaultInspector();

            if(GUILayout.Button("Scale")) {
                ts.LoadTransforms();
                Undo.RecordObjects(ts.transforms, "Rescaling");
                ts.Scale();
            }
        }
    }
#endif

}
