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++;

                    //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);
            }
 protected override bool RenderStaticValueProperty()
 {
     return(_value.RenderObjectProperties(new GUIContent("Value")));
 }