Пример #1
0
 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);
         }
     }
 }
Пример #2
0
        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();
        }
Пример #4
0
 public static void ToCenterOfMass(PivotDesignTime pivot)
 {
     Undo.RecordObject(pivot.transform, "Battlehub.PivotPointEditor.CenterOfMass");
     pivot.ToCenterOffMass();
     EditorUtility.SetDirty(pivot.transform);
 }
Пример #5
0
 public static void ToBoundsCenter(PivotDesignTime pivot)
 {
     Undo.RecordObject(pivot.transform, "Battlehub.PivotPointEditor.BoundsCenter");
     pivot.ToBoundsCenter();
     EditorUtility.SetDirty(pivot.transform);
 }