private void Start() { if (Application.isEditor && !Application.isPlaying) { if (gameObject.GetComponent <PivotDesignTime>() == null) { gameObject.AddComponent <PivotDesignTime>(); } } else { PivotDesignTime editor = gameObject.GetComponent <PivotDesignTime>(); if (editor != null) { DestroyImmediate(editor); } } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); PivotDesignTime pivot = (PivotDesignTime)target; GUILayout.BeginHorizontal(); { if (GUILayout.Button("To Center Of Mass")) { ToCenterOfMass(pivot); } if (GUILayout.Button("To Bounds Center")) { ToBoundsCenter(pivot); } } GUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); PivotDesignTime pivot = (PivotDesignTime)target; GUILayout.BeginHorizontal(); { if (GUILayout.Button("To Center Of Mass")) { Undo.RecordObject(pivot.transform, "Battlehub.PivotPointEditor.CenterOfMass"); pivot.ToCenterOffMass(); EditorUtility.SetDirty(pivot.transform); } if (GUILayout.Button("To Bounds Center")) { Undo.RecordObject(pivot.transform, "Battlehub.PivotPointEditor.BoundsCenter"); pivot.ToBoundsCenter(); EditorUtility.SetDirty(pivot.transform); } } GUILayout.EndHorizontal(); }
public static void ToCenterOfMass(PivotDesignTime pivot) { Undo.RecordObject(pivot.transform, "Battlehub.PivotPointEditor.CenterOfMass"); pivot.ToCenterOffMass(); EditorUtility.SetDirty(pivot.transform); }
public static void ToBoundsCenter(PivotDesignTime pivot) { Undo.RecordObject(pivot.transform, "Battlehub.PivotPointEditor.BoundsCenter"); pivot.ToBoundsCenter(); EditorUtility.SetDirty(pivot.transform); }