public override void OnInspectorGUI() { MegaAttach mod = (MegaAttach)target; EditorGUIUtility.LookLikeControls(); DrawDefaultInspector(); if (GUILayout.Button("Attach")) { mod.AttachIt(); } if (GUILayout.Button("Detach")) { mod.DetachIt(); } }
public override void OnInspectorGUI() { MegaAttach mod = (MegaAttach)target; #if !UNITY_5 && !UNITY_2017 && !UNITY_2018 && !UNITY_2019 EditorGUIUtility.LookLikeControls(); #endif //DrawDefaultInspector(); mod.target = (MegaModifiers)EditorGUILayout.ObjectField("Target", mod.target, typeof(MegaModifiers), true); mod.attachforward = EditorGUILayout.Vector3Field("Attach Fwd", mod.attachforward); mod.AxisRot = EditorGUILayout.Vector3Field("Axis Rot", mod.AxisRot); mod.radius = EditorGUILayout.FloatField("Radius", mod.radius); mod.up = EditorGUILayout.Vector3Field("Up", mod.up); mod.worldSpace = EditorGUILayout.Toggle("World Space", mod.worldSpace); if (GUI.changed) { EditorUtility.SetDirty(mod); } if (!mod.attached) { if (GUILayout.Button("Attach")) { mod.AttachIt(); EditorUtility.SetDirty(mod); } } else { if (GUILayout.Button("Detach")) { mod.DetachIt(); EditorUtility.SetDirty(mod); } } }
void Start() { Vector3[] v = GetComponent <MegaModifyObject>().sverts; for (int i = 0; i < v.Length; i++) { GameObject mag = new GameObject(); mag.name = "Attach" + i; mag.transform.parent = gameObject.transform; mag.transform.position = transform.localToWorldMatrix.MultiplyPoint3x4(v[i]); MegaAttach ma = mag.AddComponent <MegaAttach>(); ma.target = gameObject.GetComponent <MegaModifyObject>(); ma.radius = 0.1f; ma.AttachIt(transform.localToWorldMatrix.MultiplyPoint3x4(v[i])); GameObject rec = (GameObject)Instantiate(ExternalRecprtor); rec.transform.parent = mag.transform; rec.transform.localPosition = Vector3.zero; } }