Exemplo n.º 1
0
            public bool RenderObjectProperties(GUIContent label)
            {
                bool dataChanged = false;

                if (label == null)
                {
                    label = new GUIContent();
                }

                label.text += " (" + this + ")";

                _editorFoldout = EditorGUILayout.Foldout(_editorFoldout, label);
                if (_editorFoldout)
                {
                    int origIndent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel++;

                    dataChanged |= _object.RenderObjectProperties(new GUIContent("Object"));

                    if (_object.GetEditorComponent() != null)
                    {
                        string[] methodNames = GetMethods(_object.GetEditorComponent());

                        if (methodNames.Length > 0)
                        {
                            int currentIndex = 0;

                            for (int i = 0; i < methodNames.Length; i++)
                            {
                                if (methodNames[i] == _methodName)
                                {
                                    currentIndex = i;
                                    break;
                                }
                            }

                            EditorGUI.BeginChangeCheck();

                            int newIndex = EditorGUILayout.Popup("Method", currentIndex, methodNames);

                            if (EditorGUI.EndChangeCheck())
                            {
                                _methodName = methodNames[newIndex];
                                dataChanged = true;
                            }
                        }
                        else
                        {
                            _methodName = null;
                        }
                    }

                    EditorGUI.indentLevel = origIndent;
                }

                return(dataChanged);
            }
Exemplo n.º 2
0
 protected override bool RenderStaticValueProperty()
 {
     return(_value.RenderObjectProperties(new GUIContent("Value")));
 }
Exemplo n.º 3
0
            public bool RenderObjectProperties(GUIContent label)
            {
                bool dataChanged = false;

                if (label == null)
                {
                    label = new GUIContent();
                }

                label.text += " (" + this + ")";

                _editorFoldout = EditorGUILayout.Foldout(_editorFoldout, label);
                if (_editorFoldout)
                {
                    int origIndent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel++;

                    //Draw type dropdown
                    {
                        EditorGUI.BeginChangeCheck();
                        _editorType = (eEdtiorType)EditorGUILayout.EnumPopup("Material Type", _editorType);

                        if (EditorGUI.EndChangeCheck())
                        {
                            dataChanged = true;
                            _materialRef.ClearAsset();
                            _materialIndex = -1;
                            _renderer.ClearComponent();
                        }
                    }

                    //Draw renderer field
                    if (_editorType == eEdtiorType.Instance)
                    {
                        if (_renderer.RenderObjectProperties(new GUIContent("Renderer")))
                        {
                            dataChanged = true;
                            _materialRef.ClearAsset();
                            _materialIndex = 0;
                        }

                        //Show drop down for materials
                        Renderer renderer = _renderer.GetEditorComponent();

                        if (renderer != null)
                        {
                            string[] materialNames = new string[renderer.sharedMaterials.Length];

                            for (int i = 0; i < materialNames.Length; i++)
                            {
                                materialNames[i] = renderer.sharedMaterials[i].name;
                            }

                            _materialIndex = EditorGUILayout.Popup("Material", _materialIndex, materialNames);
                        }
                    }
                    else
                    {
                        dataChanged |= _materialRef.RenderObjectProperties(new GUIContent("Material"));
                    }

                    EditorGUI.indentLevel = origIndent;
                }

                return(dataChanged);
            }