示例#1
0
        // void OnSceneGUI() {
        //     // objectListEditor.OnSceneGUI(attacher.objects, attacher);
        //  serializedObject.ApplyModifiedProperties();
        // }

        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            SerializedProperty prop;

            if (attacher.strategy == null)
            {
                EditorGUILayout.HelpBox("An Attach Strategy describes how objects will attach. You can create one "
                                        + "from the menu in Assets->Create->Clingy.", MessageType.Warning);
            }
            EditorGUI.BeginChangeCheck();
            AttachStrategy newStrategy = (AttachStrategy)EditorGUILayout.ObjectField("Attach Strategy",
                                                                                     attacher.strategy, typeof(AttachStrategy), false);

            if (EditorGUI.EndChangeCheck())
            {
                attacher.strategy = newStrategy;
            }

            prop = serializedObject.FindProperty("_request");
            objectListEditor.OnInspectorGUI(prop, attacher.isActive);

            DrawPropertiesExcluding(serializedObject, new string[] { "m_Script", "_strategy" });
            // EditorGUILayout.PropertyField(serializedObject.FindProperty("attachOnStart"));

            EditorGUI.BeginChangeCheck();
            int executionOrder = EditorGUILayout.IntField("Execution Order", ((Attacher)target).executionOrder);

            if (EditorGUI.EndChangeCheck())
            {
                ((Attacher)target).executionOrder = executionOrder;
            }

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("events"));

            EditorGUI.BeginDisabledGroup(!EditorApplication.isPlaying);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Attach", GUILayout.Width(100)))
            {
                attacher.Attach();
            }
            if (GUILayout.Button("Detach", GUILayout.Width(100)))
            {
                attacher.Detach();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            serializedObject.ApplyModifiedProperties();
        }
示例#2
0
        public static void DoInspectorGUI(SerializedObject obj, AttachStrategy attachStrategy)
        {
            SerializedProperty p = obj.GetIterator();

            if (p.NextVisible(true))
            {
                if (!p.NextVisible(true)) // skip the "Script" property
                {
                    return;
                }
                EditorGUILayout.Space();
                do
                {
                    EditorGUILayout.PropertyField(p, true);
                } while(p.NextVisible(false));
            }
        }
示例#3
0
        protected virtual void OnEnable()
        {
            selectedCategoryProp = serializedObject.FindProperty("_selectedCategory");

            headerTexture = new Texture2D(1, 1);
            headerTexture.SetPixel(0, 0, new Color(0.6f, 0.6f, 0.6f));
            headerTexture.Apply();
            headerStyle = new GUIStyle();
            headerStyle.normal.background = headerTexture;

            AttachStrategy strategy = (AttachStrategy)target;

            categoryNames = new string[strategy.GetCategories().Length];
            for (int i = 0; i < strategy.GetCategories().Length; i++)
            {
                categoryNames[i] = strategy.GetCategories()[i].label;
            }
        }
 new public static void DoInspectorGUI(SerializedObject obj, AttachStrategy attachStrategy)
 {
     DoOnAttachOptions(obj.FindProperty("onAttachOptions"));
     EditorGUILayout.Space();
     DoOnDetachOptions(obj.FindProperty("onDetachOptions"));
 }