示例#1
0
        public override void OnInspectorGUI()
        {
            if (buttonExAttributeDrawer == null)
            {
                buttonExAttributeDrawer = new ButtonExAttributeDrawer(target);
            }

            buttonExAttributeDrawer.OnInspectorGUI();
            base.OnInspectorGUI();
        }
        public override void OnInspectorGUI()
        {
            if (!target)
            {
                return;
            }

            if (buttonExAttributeDrawer == null)
            {
                buttonExAttributeDrawer = new ButtonExAttributeDrawer(target);
            }

            buttonExAttributeDrawer.OnInspectorGUI();
            DrawDefaultInspector();
        }
示例#3
0
        public override void OnInspectorGUI()
        {
            if (!target)
            {
                return;
            }

            if (buttonExAttributeDrawer == null)
            {
                buttonExAttributeDrawer = new ButtonExAttributeDrawer(target);
            }

            buttonExAttributeDrawer.OnInspectorGUI();
            nListId   = -1;
            nObjectId = serializedObject.targetObject.GetInstanceID();
            CustomInspectorGUI(serializedObject, target, this);
        }
示例#4
0
        private static void CustomInspectorGUI(SerializedObject serializedObject, Object target, QObjectInspector editor,
                                               ButtonExAttributeDrawer buttonExAttributeDrawer)
        {
            //这部分是使用了反编译Editor的代码
            EditorGUI.BeginChangeCheck();
            serializedObject.Update();
            SerializedProperty iterator = serializedObject.GetIterator();
            Event eventCurrent          = Event.current;

            GUILayout.Space(3);
            for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false)
            {
                //using (new EditorGUI.DisabledScope(false))
                //{
                Type      type       = target.GetType();
                FieldInfo fieldInfos =
                    type.GetField(iterator.name, BindingFlags.Instance | BindingFlags.Public |
                                  BindingFlags.NonPublic | BindingFlags.GetField);
                while (fieldInfos == null)
                {
                    type = type.BaseType;
                    if (type == null)
                    {
                        break;
                    }

                    fieldInfos = type.GetField(iterator.name,
                                               BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField);
                }

                if (fieldInfos == null)
                {
                    EditorGUILayout.PropertyField(iterator, true);
                    GUILayout.Space(-21);
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button(EditorGUIUtility.TrTextContent("Name Go"), sStyles.scriptName,
                                         GUILayout.Width(EditorGUIUtility.labelWidth - 22)))
                    {
                        Undo.RecordObjects(Selection.objects, "Rename");
                        for (int j = 0; j < serializedObject.targetObjects.Length; j++)
                        {
                            if (ButtonAttributeDrawer.CalledFunc(serializedObject.targetObjects[j], "NameGo"))
                            {
                                continue;
                            }

                            serializedObject.targetObjects[j].name = serializedObject.targetObjects[j].GetType().Name;
                        }
                    }

                    //治疗双击脚本不能打开的问题
                    //if (GUILayout.Button(EditorGUIUtilityEx.TempContent("Open..."), sStyles.scriptName,
                    //	GUILayout.Width(EditorGUIUtility.labelWidth / 2 - 6)))
                    //{
                    //	AssetDatabase.OpenAsset(iterator.objectReferenceValue);
                    //	GUIUtility.ExitGUI();
                    //}

                    GUILayout.EndHorizontal();
                    buttonExAttributeDrawer.OnInspectorGUI();
                    continue;
                }

                //检查ShowIf特性
                if (!CheckShowIf(fieldInfos, iterator, target))
                {
                    continue;
                }

                EditorGUILayout.PropertyField(iterator, true);
                Event e = Event.current;
                if (e.type == EventType.KeyDown && e.keyCode == KeyCode.C)
                {
                    if (GUILayoutUtility.GetLastRect().Contains(e.mousePosition))
                    {
                        GUIUtility.systemCopyBuffer = iterator.name;
                    }
                }
            }

            serializedObject.ApplyModifiedProperties();
            EditorGUI.EndChangeCheck();
        }