Example #1
0
        public void EditorInspector(BuildScenario Config)
        {
            if (_list == null)
            {
                _list = new ReorderableList(Actions, typeof(IAction), true, true, true, true);
                _list.drawHeaderCallback    = (Rect r) => EditorGUI.LabelField(r, "Actions", EditorStyles.boldLabel);
                _list.drawElementCallback   = (Rect rect, int index, bool isActive, bool isFocused) => Actions[index].EditorListInspector(Config, -1, rect);
                _list.onAddDropdownCallback = (Rect r, ReorderableList l) => BuilderWindow.AddDropdownCallback <IAction>(r, l);
                _list.onSelectCallback      = BuilderWindow.OnSelectAction;
            }

            IsBuilding = EditorGUILayout.Toggle("Is need build", IsBuilding);
            TargetName = EditorGUILayout.TextField("Target name", TargetName);

            _list.DoLayoutList();

            /*
             * if(_list.index >= 0 && _list.index < Actions.Count)
             * {
             *  EditorGUILayout.BeginVertical(EditorStyles.helpBox);
             *
             *  var elem = Actions[_list.index];
             *  elem.EditorInspector(Config, -1);
             *
             *  EditorGUILayout.EndVertical();
             * }
             */
        }
Example #2
0
        public void EditorInspector(BuildScenario conf, int target)
        {
            if (properties == null)
            {
                properties = new ReorderableList(OverridedProperty, typeof(IChangeProperty), true, true, true, true);
                properties.drawHeaderCallback  = (Rect r) => EditorGUI.LabelField(r, "Overrided properties", EditorStyles.boldLabel);
                properties.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    EditorGUI.LabelField(rect, OverridedProperty[index].GetType().Name);
                };
                properties.onAddDropdownCallback = (Rect r, ReorderableList l) => BuilderWindow.AddDropdownCallback <IChangeProperty>(r, l);
            }
            if (!isInit)
            {
                var obj = AssetDatabase.LoadAssetAtPath <GameObject>(AssetDatabase.GUIDToAssetPath(TargetGUID));
                if (obj != null)
                {
                    var comps = obj.GetComponents <Component>();
                    if (comps != null)
                    {
                        targetObj = comps[ScriptId];
                    }
                }
                isInit = true;
            }
            var _targetObj = (Component)EditorGUILayout.ObjectField("Target component", targetObj, typeof(Component), false);

            if (_targetObj != targetObj)
            {
                targetObj = _targetObj;
                if (targetObj == null)
                {
                    TargetGUID = "";
                    ScriptId   = -1;
                }
                else
                {
                    TargetGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(targetObj.gameObject.GetInstanceID()));
                    short i = 0;
                    foreach (var item in targetObj.gameObject.GetComponents <Component>())
                    {
                        if (item == targetObj)
                        {
                            ScriptId = i;
                            break;
                        }
                        i++;
                    }
                }
                OverridedProperty.Clear();
            }

            properties.DoLayoutList();

            if (properties.index >= 0 && OverridedProperty.Count > properties.index)
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                OverridedProperty[properties.index].EditorInspector(this);
                EditorGUILayout.EndVertical();
            }
        }