Exemplo n.º 1
0
        public static void Delete(GameObject selectionObj)
        {
            if (selectionObj == null)
            {
                return;
            }

            EditorUndo.BeginRecord();

            EditorUndo.BeginDestroyObject(selectionObj);

            EditorUndo.EndRecord();

            bool isEnabled = EditorUndo.Enabled;

            EditorUndo.Enabled      = false;
            EditorSelection.objects = null;
            EditorUndo.Enabled      = isEnabled;

            EditorUndo.BeginRecord();

            EditorUndo.DestroyObject(selectionObj);

            EditorUndo.EndRecord();
        }
        public static void Reset()
        {
            m_windows           = new List <RuntimeEditorWindow>();
            m_pointerOverWindow = null;
            m_activeWindow      = null;
            m_activeCameraIndex = 0;
            GameCameras         = null;
            SceneCameras        = null;
            m_isOpened          = false;
            m_isPlaying         = false;

            EditorSelection.objects = null;
            EditorUndo.Reset();
            RuntimeTools.Reset();
        }
Exemplo n.º 3
0
 public void RefreshUndoBtnState()
 {
     if (EditorUndo.GetStackCount() > 0)
     {
         if (img_cancel != null)
         {
             img_cancel.gameObject.SetActive(true);
         }
     }
     else
     {
         if (img_cancel != null)
         {
             img_cancel.gameObject.SetActive(false);
         }
     }
 }
Exemplo n.º 4
0
 public void OnBtnRedo()
 {
     EditorUndo.Redo();
 }
Exemplo n.º 5
0
 public void OnBtnUndo()
 {
     EditorUndo.Undo();
 }
Exemplo n.º 6
0
        private void OnResetClick()
        {
            EditorUndo.BeginRecord();

            GameObject go = new GameObject();

            go.SetActive(false);

            Component component = go.GetComponent(Component.GetType());

            if (component == null)
            {
                component = go.AddComponent(Component.GetType());
            }

            bool isMonoBehavior = component is MonoBehaviour;

            PropertyDescriptor[] descriptors = GetDescriptors(m_converter);
            for (int i = 0; i < descriptors.Length; ++i)
            {
                PropertyDescriptor descriptor = descriptors[i];
                MemberInfo         memberInfo = descriptor.ComponentMemberInfo;
                if (memberInfo is PropertyInfo)
                {
                    PropertyInfo p            = (PropertyInfo)memberInfo;
                    object       defaultValue = p.GetValue(component, null);
                    //EditorUndo.RecordValue(Component, memberInfo);
                    p.SetValue(Component, defaultValue, null);
                }
                else
                {
                    if (isMonoBehavior)
                    {
                        if (memberInfo is FieldInfo)
                        {
                            FieldInfo f            = (FieldInfo)memberInfo;
                            object    defaultValue = f.GetValue(component);
                            //EditorUndo.RecordValue(Component, memberInfo);
                            f.SetValue(Component, defaultValue);
                        }
                    }
                }
            }

            for (int i = 0; i < descriptors.Length; ++i)
            {
                PropertyDescriptor descriptor     = descriptors[i];
                MemberInfo         memberInfo     = descriptor.MemberInfo;
                PropertyEditor     propertyEditor = GetPropertyEditor(memberInfo);
                if (propertyEditor != null)
                {
                    propertyEditor.Reload();
                }
            }

            Destroy(go);

            EditorUndo.EndRecord();

            EditorUndo.BeginRecord();

            for (int i = 0; i < descriptors.Length; ++i)
            {
                PropertyDescriptor descriptor = descriptors[i];
                MemberInfo         memberInfo = descriptor.ComponentMemberInfo;
                if (memberInfo is PropertyInfo)
                {
                    //EditorUndo.RecordValue(Component, memberInfo);
                }
                else
                {
                    if (isMonoBehavior)
                    {
                        //EditorUndo.RecordValue(Component, memberInfo);
                    }
                }
            }

            EditorUndo.EndRecord();
        }
Exemplo n.º 7
0
 void OnClickRedo()
 {
     EditorUndo.Redo();
 }
Exemplo n.º 8
0
 //撤销
 void OnClickCancel()
 {
     EditorUndo.Undo();
     this.RefreshUndoBtnState();
 }
Exemplo n.º 9
0
 public void Init()
 {
     EditorUndo.Reset();
 }