示例#1
0
        void OnGUI()
        {
            _scrollViewPosition = EditorGUILayout.BeginScrollView(_scrollViewPosition);
            {
                EditorLayout.DrawTexture(_headerTexture);

                var descriptionStyle = new GUIStyle(GUI.skin.label);
                descriptionStyle.wordWrap = true;
                for (int i = 0; i < _migrations.Length; i++)
                {
                    var migration = _migrations[i];
                    _showMigration[i] = EditorLayout.DrawSectionHeaderToggle(migration.version, _showMigration[i]);
                    if (_showMigration[i])
                    {
                        EditorLayout.BeginSectionContent();
                        {
                            EditorGUILayout.LabelField(migration.description, descriptionStyle);
                            if (GUILayout.Button("Apply migration " + migration.version))
                            {
                                migrate(migration, this);
                            }
                        }
                        EditorLayout.EndSectionContent();
                    }
                }
            }
            EditorGUILayout.EndScrollView();
        }
    private void OnGUI()
    {
        //GUILayout.BeginArea(new Rect(10, 10, position.width * 0.15f, position.height));

        scroll = GUILayout.BeginScrollView(scroll);

        GUILayout.BeginHorizontal();

        EditorLayout.Button("Add ActionInput", CreateActionInput);

        EditorLayout.Button("Add AxisInput", CreateAxisInput);

        EditorLayout.Button("Save Change", SaveChange);

        GUILayout.EndHorizontal();

        EditorLayout.Space();

        showActionInput = EditorGUILayout.Foldout(showActionInput, "Actions Input");
        DrawAllActionInput(showActionInput);

        EditorLayout.Space();

        showAxisInput = EditorGUILayout.Foldout(showAxisInput, "Axis Input");
        DrawAllAxisInput(showAxisInput);

        GUILayout.EndScrollView();

        EditorLayout.Space();
    }
        protected override void DrawOnlyForPrabInScene()
        {
            base.DrawOnlyForPrabInScene();

            EditorLayout.BeginVerticalBox();
            {
                EditorGUILayout.LabelField("Transition status", EditorStyles.boldLabel);

                EditorLayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("Total transitions: " + CallObject.TransitionCount);
                }
                EditorLayout.EndHorizontal();

                /*
                 * if (CallObject.InTransition)
                 * {
                 *  string status =
                 *      "RUNNING (" +
                 *      (CallObject.Fading ? "Fading" : "Brightening") +
                 *      ") - " +
                 *      Mathf.RoundToInt(CallObject.TransitionPercent * 100) +
                 *      "%"
                 *  ;
                 *  EditorLayout.BeginHorizontal();
                 *  {
                 *      EditorGUILayout.LabelField(status);
                 *  }
                 *  EditorLayout.EndHorizontal();
                 * }
                 */
            }
            EditorLayout.EndVertical();
        }
示例#4
0
 void OnEnable()
 {
     _headerTexture    = EditorLayout.LoadTexture("l:EntitasHeader");
     _migrations       = getMigrations();
     _showMigration    = new bool[_migrations.Length];
     _showMigration[0] = true;
 }
示例#5
0
        void drawHeader(Preferences preferences)
        {
            var rect = EditorLayout.DrawTexture(_headerTexture);
//            if (rect.Contains(Event.current.mousePosition) && Event.current.clickCount > 0) {
//                Application.OpenURL("https://github.com/sschmid/Entitas-CSharp/blob/develop/README.md");
//            }

            var propertiesPath = Path.GetFileName(preferences.propertiesPath);

            var       buttonWidth  = 60 + propertiesPath.Length * 5;
            const int buttonHeight = 15;
            const int padding      = 4;
            var       buttonRect   = new Rect(
                rect.width - buttonWidth - padding,
                rect.y + rect.height - buttonHeight - padding,
                buttonWidth,
                buttonHeight
                );

            if (GUI.Button(buttonRect, "Edit " + propertiesPath, EditorStyles.miniButton))
            {
                EditorWindow.focusedWindow.Close();
                System.Diagnostics.Process.Start(preferences.propertiesPath);
            }
        }
示例#6
0
        protected override void DrawOnlyForPrabInScene()
        {
            base.DrawOnlyForPrabInScene();

            EditorLayout.BeginVerticalBox();
            {
                EditorLayout.BeginHorizontal();
                {
                    string status      = CallObject.Pause ? "Resume" : "Pause";
                    var    buttonStyle = new GUIStyle(GUI.skin.button);

                    if (GUILayout.Button(status, buttonStyle, GUILayout.Width(50)))
                    {
                        CallObject.Pause = !CallObject.Pause;
                    }

                    if (GUILayout.Button("Restart", buttonStyle, GUILayout.Width(50)))
                    {
                        CallObject.RestartCurrentLevel();
                    }
                }
                EditorLayout.EndHorizontal();
            }
            EditorLayout.EndVertical();
        }
示例#7
0
        void drawHeader(Preferences preferences)
        {
            var rect = EditorLayout.DrawTexture(_headerTexture);
//            if (rect.Contains(Event.current.mousePosition) && Event.current.clickCount > 0) {
//                Application.OpenURL("https://github.com/sschmid/Entitas-CSharp/blob/develop/README.md");
//            }

            var propertiesPath = Path.GetFileName(preferences.propertiesPath);

            var       buttonWidth  = 60 + propertiesPath.Length * 5;
            const int buttonHeight = 15;
            const int padding      = 4;
            var       buttonRect   = new Rect(
                rect.width - buttonWidth - padding,
                rect.y + rect.height - buttonHeight - padding,
                buttonWidth,
                buttonHeight
                );

            var allPreferences = Preferences.FindAll("*.properties")
                                 .Select(Path.GetFileName)
                                 .ToArray();

            if (allPreferences.Length > 1)
            {
                var r = new Rect(
                    rect.width - 50 - padding,
                    buttonRect.y,
                    50,
                    buttonHeight
                    );

                if (GUI.Button(r, "Switch", EditorStyles.miniButton))
                {
                    var path  = EditorPrefs.GetString(PreferencesWindow.PREFERENCES_KEY);
                    var index = Array.IndexOf(allPreferences, path);
                    if (index >= 0)
                    {
                        index += 1;
                        if (index >= allPreferences.Length)
                        {
                            index = 0;
                        }
                        EditorPrefs.SetString(PreferencesWindow.PREFERENCES_KEY, allPreferences[index]);
                        var window = EditorWindow.focusedWindow;
                        window.Close();
                        EntitasPreferencesWindow.OpenPreferences();
                    }
                }

                buttonRect.x -= r.width + padding;
            }

            if (GUI.Button(buttonRect, "Edit " + propertiesPath, EditorStyles.miniButton))
            {
                EditorWindow.focusedWindow.Close();
                System.Diagnostics.Process.Start(preferences.propertiesPath);
            }
        }
示例#8
0
        //bool bUnfolded = false;
        /// <summary>
        /// Draws the component.
        /// </summary>
        /// <param name="com">COM.</param>
        void DrawComponent(IZComponent com)
        {
            int iconSize = (int)EditorGUIUtility.singleLineHeight;
            //draw component member
            Rect rect        = EditorGUILayout.BeginVertical(entityStyle);
            Type ty          = com.GetType();
            var  memberInfos = ty.GetPublicMemberInfos();

            bool bUnfolded = poolConfig.unfoldMap.IsUnfold(curEntity.Name + ty.Name);

            //SerializedProperty unfoledObj = serializedObject.FindProperty ("unfoldMap");

            //draw component file info
            EditorGUILayout.BeginHorizontal();
            {
                if (memberInfos.Count == 0)
                {
                    EditorGUILayout.LabelField("    " + ty.Name, EditorStyles.boldLabel);
                }
                else
                {
                    bool bNewUnfold = EditorLayout.Foldout(bUnfolded, ty.Name, iconSize + 10);
                    //EditorGUILayout.LabelField(ty.Name, EditorStyles.boldLabel);
                    if (bNewUnfold != bUnfolded)
                    {
                        poolConfig.unfoldMap.SetUnfold(curEntity.Name + ty.Name, bNewUnfold);

//						unfoldObj.Update();
//						unfoldObj.ApplyModifiedProperties ();
                    }
                }
                if (EditorLayout.MiniButton("-"))
                {
                    //entity.RemoveComponent(index);
                    curEntity.DelComponent(com);
                }
            }
            EditorGUILayout.EndHorizontal();

            //Draw the icon
            if (ComponentsPool <IZComponent> .IsSystem(com))
            {
                GUI.DrawTexture(new Rect(rect.x + 1, rect.y + 1,
                                         iconSize - 2, iconSize - 2), IconHelper.SystemsHierarchyIcon);
            }
            else
            {
                GUI.DrawTexture(new Rect(rect.x + 1, rect.y + 1,
                                         iconSize - 2, iconSize - 2), IconHelper.EntityHierarchyIcon);
            }


            if (bUnfolded)
            {
                InspectorDrawer.DrawObjectMember(com);
            }

            EditorGUILayout.EndVertical();
        }
    public override void OnInspectorGUI()
    {
        UtilityEditor.VersioningTool("TCT", 0, 1, 0, 0);

        EditorLayout.Space(2);

        EditorReflectionLayout.TextField(eTarget, "name", "SmartCam's Name");

        EditorLayout.Space();

        EditorReflectionLayout.EnumPopup <TypeSmartCam>(eTarget, "typeSmartCam", "TYPE SMART CAM");

        if (Reflection.Field <TypeSmartCam>(eTarget, "typeSmartCam") == TypeSmartCam.NONE)
        {
            return;
        }

        EditorLayout.Space();

        SetTargetSmartCam();

        EditorLayout.Space();

        EditorReflectionLayout.Toggle(smartCamOption, "fixeRotationCam", "Fixe Rotation Camera");

        EditorLayout.Space();

        EditorReflectionLayout.Toggle(smartCamOption, "fixeMovementCam", "Fixe Movement Camera");

        EditorLayout.Space();

        SetOffSetSmartCam();

        EditorLayout.Space();

        EditorReflectionLayout.Slider(smartCamOption, "lerp", "Lerp", 0f, 1f);

        EditorLayout.Space();

        SetSensibilitySmartCam();

        EditorLayout.Space();

        if (Reflection.Field <TypeSmartCam>(eTarget, "typeSmartCam") == TypeSmartCam.TPS)
        {
            smartCamOption.RadiusTPS = EditorLayout.Slider(smartCamOption.RadiusTPS, "Radius", 1, 15);
        }

        else
        {
            smartCamOption.RadiusTPS = 0;
        }

        EditorLayout.Space(2);

        UpdateReflection(ref smartCamOption);

        SceneView.RepaintAll();
    }
示例#10
0
        public override void Draw(Rect rect, TweenRotation tween)
        {
            rect.height = EditorConfig.Sizes.SingleLine;
            EditorLayout.PropertyField(rect, ref tween.IsLocal, EditorGUI.Toggle, InspectorStates.Record, contentLocal);

            rect.y    += EditorConfig.Sizes.SingleLine;
            tween.Mode = (TweenRotation.RotationMode)EditorLayout.PropertyField(rect, tween.Mode, EditorGUI.EnumPopup, InspectorStates.Record, contentMode);
        }
示例#11
0
        public static void DrawMultipleEntities(IContext context, IEntity[] entities)
        {
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            {
                var entity = entities[0];
                var index  = drawAddComponentMenu(context, entity);
                if (index >= 0)
                {
                    var componentType = entity.contextInfo.componentTypes[index];
                    foreach (var e in entities)
                    {
                        var component = e.CreateComponent(index, componentType);
                        e.AddComponent(index, component);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            var bgColor = GUI.backgroundColor;

            GUI.backgroundColor = Color.red;

            if (GUILayout.Button("Destroy selected entities"))
            {
                foreach (var e in entities)
                {
                    e.Destroy();
                }
            }

            GUI.backgroundColor = bgColor;

            EditorGUILayout.Space();

            foreach (var e in entities)
            {
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField(e.ToString());

                    bgColor             = GUI.backgroundColor;
                    GUI.backgroundColor = Color.red;

                    if (EditorLayout.MiniButton("Destroy Entity"))
                    {
                        e.Destroy();
                    }

                    GUI.backgroundColor = bgColor;
                }
                EditorGUILayout.EndHorizontal();
            }
        }
        public override void Initialize(Preferences preferences)
        {
            _headerTexture = EditorLayout.LoadTexture("l:EntitasHeader");

            _scriptingDefineSymbols = new ScriptingDefineSymbols();
            _aercMode = _scriptingDefineSymbols.buildTargetToDefSymbol.Values
                        .All <string>(defs => defs.Contains(ENTITAS_FAST_AND_UNSAFE))
                ? AERCMode.FastAndUnsafe
                : AERCMode.Safe;
        }
示例#13
0
        public static void OpenPreferences()
        {
            Preferences.sharedInstance = null;
            var window = EditorLayout.GetWindow <PreferencesWindow>(
                "Entitas " + CheckForUpdates.GetLocalVersion(),
                new Vector2(415f, 600));

            window.preferencesName = "Entitas";
            window.Show();
        }
示例#14
0
        static Func <IList> drawEditActions(IList list, Type elementType, int index)
        {
            if (EditorLayout.MiniButtonLeft("↑"))
            {
                if (index > 0)
                {
                    return(() => {
                        var otherIndex = index - 1;
                        var other = list[otherIndex];
                        list[otherIndex] = list[index];
                        list[index] = other;
                        return list;
                    });
                }
            }

            if (EditorLayout.MiniButtonMid("↓"))
            {
                if (index < list.Count - 1)
                {
                    return(() => {
                        var otherIndex = index + 1;
                        var other = list[otherIndex];
                        list[otherIndex] = list[index];
                        list[index] = other;
                        return list;
                    });
                }
            }

            if (EditorLayout.MiniButtonMid("+"))
            {
                object defaultValue;
                if (EntityDrawer.CreateDefault(elementType, out defaultValue))
                {
                    var insertAt = index + 1;
                    return(() => {
                        list.Insert(insertAt, defaultValue);
                        return list;
                    });
                }
            }

            if (EditorLayout.MiniButtonRight("-"))
            {
                var removeAt = index;
                return(() => {
                    list.RemoveAt(removeAt);
                    return list;
                });
            }

            return(null);
        }
示例#15
0
        public static void DrawComponents(IEntity entity)
        {
            var unfoldedComponents    = getUnfoldedComponents(entity);
            var componentMemberSearch = getComponentMemberSearch(entity);

            EditorLayout.BeginVerticalBox();
            {
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("Components (" + entity.GetComponents().Length + ")", EditorStyles.boldLabel);
                    if (EditorLayout.MiniButtonLeft("▸"))
                    {
                        for (int i = 0; i < unfoldedComponents.Length; i++)
                        {
                            unfoldedComponents[i] = false;
                        }
                    }

                    if (EditorLayout.MiniButtonRight("▾"))
                    {
                        for (int i = 0; i < unfoldedComponents.Length; i++)
                        {
                            unfoldedComponents[i] = true;
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();

                var index = drawAddComponentMenu(entity);
                if (index >= 0)
                {
                    var componentType = entity.contextInfo.componentTypes[index];
                    var component     = entity.CreateComponent(index, componentType);
                    entity.AddComponent(index, component);
                }

                EditorGUILayout.Space();

                componentNameSearchString = EditorLayout.SearchTextField(componentNameSearchString);

                EditorGUILayout.Space();

                var indices    = entity.GetComponentIndices();
                var components = entity.GetComponents();
                for (int i = 0; i < components.Length; i++)
                {
                    DrawComponent(unfoldedComponents, componentMemberSearch, entity, indices[i], components[i]);
                }
            }
            EditorLayout.EndVerticalBox();
        }
示例#16
0
        void drawSystemsMonitor(DebugSystems systems)
        {
            if (_systemsMonitor == null)
            {
                _systemsMonitor    = new Graph(SYSTEM_MONITOR_DATA_LENGTH);
                _systemMonitorData = new Queue <float>(new float[SYSTEM_MONITOR_DATA_LENGTH]);
            }

            _showSystemsMonitor = EditorLayout.DrawSectionHeaderToggle("Performance", _showSystemsMonitor);
            if (_showSystemsMonitor)
            {
                EditorLayout.BeginSectionContent();
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.BeginVertical();
                        {
                            EditorGUILayout.LabelField("Execution duration", systems.executeDuration.ToString());
                            EditorGUILayout.LabelField("Cleanup duration", systems.cleanupDuration.ToString());
                        }
                        EditorGUILayout.EndVertical();

                        if (_stepButtonContent == null)
                        {
                            _stepButtonContent = EditorGUIUtility.IconContent("StepButton On");
                        }
                        if (_pauseButtonContent == null)
                        {
                            _pauseButtonContent = EditorGUIUtility.IconContent("PauseButton On");
                        }

                        systems.paused = GUILayout.Toggle(systems.paused, _pauseButtonContent, "CommandLeft");

                        if (GUILayout.Button(_stepButtonContent, "CommandRight"))
                        {
                            systems.paused = true;
                            systems.StepExecute();
                            systems.StepCleanup();
                            addDuration((float)systems.executeDuration + (float)systems.cleanupDuration);
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    if (!EditorApplication.isPaused && !systems.paused)
                    {
                        addDuration((float)systems.executeDuration + (float)systems.cleanupDuration);
                    }
                    _systemsMonitor.Draw(_systemMonitorData.ToArray(), 80f);
                }
                EditorLayout.EndSectionContent();
            }
        }
示例#17
0
        protected override void DrawOnlyForPrabInScene()
        {
            base.DrawOnlyForPrabInScene();

            AudioClip currentAudioClip = CallObject.CurrentAudioClip;

            EditorLayout.BeginVerticalBox();
            {
                EditorGUILayout.LabelField("Music manager", EditorStyles.boldLabel);

                EditorLayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("Total songs: " + CallObject.MusicPlaylistList.Count);
                }
                EditorLayout.EndHorizontal();

                EditorLayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("Current song: " + currentAudioClip.name);
                }
                EditorLayout.EndHorizontal();

                EditorLayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField(Utility.ConvertTimeToString(CallObject.AudioSource.time) + " / " + Utility.ConvertTimeToString(currentAudioClip.length));
                }
                EditorLayout.EndHorizontal();

                EditorLayout.BeginHorizontal();
                {
                    var buttonStyle = new GUIStyle(GUI.skin.button);
                    if (GUILayout.Button("Play", buttonStyle, GUILayout.Width(50)))
                    {
                        CallObject.Play();
                    }
                    if (GUILayout.Button(CallObject.IsPaused() ? "UnPause" : "Pause", buttonStyle, GUILayout.Width(60)))
                    {
                        CallObject.Pause();
                    }
                    if (GUILayout.Button("Next", buttonStyle, GUILayout.Width(50)))
                    {
                        CallObject.Next();
                    }
                    if (GUILayout.Button("Stop", buttonStyle, GUILayout.Width(50)))
                    {
                        CallObject.Stop();
                    }
                }
                EditorLayout.EndHorizontal();
            }
            EditorLayout.EndVertical();
        }
示例#18
0
        void drawDefaultInstanceCreator()
        {
            var path = EditorLayout.ObjectFieldOpenFolderPanel(
                "Default Instance Creators",
                _visualDebuggingConfig.defaultInstanceCreatorFolderPath,
                _visualDebuggingConfig.defaultInstanceCreatorFolderPath
                );

            if (!string.IsNullOrEmpty(path))
            {
                _visualDebuggingConfig.defaultInstanceCreatorFolderPath = path;
            }
        }
示例#19
0
        void drawTypeDrawerFolder()
        {
            var path = EditorLayout.ObjectFieldOpenFolderPanel(
                "Type Drawers",
                _visualDebuggingConfig.typeDrawerFolderPath,
                _visualDebuggingConfig.typeDrawerFolderPath
                );

            if (!string.IsNullOrEmpty(path))
            {
                _visualDebuggingConfig.typeDrawerFolderPath = path;
            }
        }
    public override void OnInspectorGUI()
    {
        //base.OnInspectorGUI();

        UtilityEditor.VersioningTool("TCT", 0, 1, 0, 0);

        EditorLayout.Space(2);

        EditorReflectionLayout.TextField(eTarget, "name", "Character Name");

        EditorLayout.Space();

        EditorLayout.Button("Add Component Character", eTarget.AddComponent, currentComponent);
    }
    private void OnGUI()
    {
        currentName = EditorGUILayout.TextField(currentName);

        EditorLayout.Space(2);

        EditorGUILayout.BeginHorizontal();

        EditorLayout.Button("OK", ValidateChangeName, currentName);

        EditorLayout.Button("Cancel", Close);

        EditorGUILayout.EndHorizontal();
    }
    void DrawAxisInput(bool _show, TCT_AxisInput _axis)
    {
        if (!_show)
        {
            return;
        }

        if (_axis == null || _axis.AllAxisCode.Count < 1)
        {
            return;
        }

        for (int i = 0; i < _axis.AllAxisCode.Count; i++)
        {
            Enum _currentKeyCode = _axis.AllAxisCode[i];

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.Separator();

            _currentKeyCode = EditorGUILayout.EnumPopup(_currentKeyCode, GUILayout.MaxWidth(100));

            if (_axis.ExistKeyCode((AxisCode)_currentKeyCode) && (AxisCode)_currentKeyCode != _axis.AllAxisCode[i])
            {
                Debug.LogWarning("this Axis is already assign in this Action. Please select an other");
            }
            else
            {
                _axis.AllAxisCode[i] = (AxisCode)_currentKeyCode;
            }

            GUILayout.Box("Sensibility", GUILayout.MaxWidth(80));

            _axis.sensibilty = EditorGUILayout.FloatField(_axis.sensibilty, GUILayout.MaxWidth(50));

            GUILayout.Box("DeadZone", GUILayout.MaxWidth(80));

            _axis.deadZone = EditorGUILayout.FloatField(_axis.deadZone, GUILayout.MaxWidth(50));


            EditorLayout.Button("x", RemoveAxisCode, _axis, (AxisCode)_currentKeyCode);

            EditorGUILayout.EndHorizontal();

            EditorLayout.Space();
        }
    }
示例#23
0
 static void drawSystemsOverview(DebugSystems systems)
 {
     _showDetails = EditorLayout.DrawSectionHeaderToggle("Details", _showDetails);
     if (_showDetails)
     {
         EditorLayout.BeginSectionContent();
         {
             EditorGUILayout.LabelField(systems.name, EditorStyles.boldLabel);
             EditorGUILayout.LabelField("Initialize Systems", systems.totalInitializeSystemsCount.ToString());
             EditorGUILayout.LabelField("Execute Systems", systems.totalExecuteSystemsCount.ToString());
             EditorGUILayout.LabelField("Cleanup Systems", systems.totalCleanupSystemsCount.ToString());
             EditorGUILayout.LabelField("TearDown Systems", systems.totalTearDownSystemsCount.ToString());
             EditorGUILayout.LabelField("Total Systems", systems.totalSystemsCount.ToString());
         }
         EditorLayout.EndSectionContent();
     }
 }
        static Func <Array> drawEditActions(Array array, Type elementType, int index)
        {
            if (EditorLayout.MiniButtonLeft("↑"))
            {
                if (index > 0)
                {
                    return(() => {
                        var otherIndex = index - 1;
                        var other = array.GetValue(otherIndex);
                        array.SetValue(array.GetValue(index), otherIndex);
                        array.SetValue(other, index);
                        return array;
                    });
                }
            }

            if (EditorLayout.MiniButtonMid("↓"))
            {
                if (index < array.Length - 1)
                {
                    return(() => {
                        var otherIndex = index + 1;
                        var other = array.GetValue(otherIndex);
                        array.SetValue(array.GetValue(index), otherIndex);
                        array.SetValue(other, index);
                        return array;
                    });
                }
            }

            if (EditorLayout.MiniButtonMid("+"))
            {
                object defaultValue;
                if (EntityDrawer.CreateDefault(elementType, out defaultValue))
                {
                    return(() => arrayInsertAt(array, elementType, defaultValue, index + 1));
                }
            }

            if (EditorLayout.MiniButtonRight("-"))
            {
                return(() => arrayRemoveAt(array, elementType, index));
            }

            return(null);
        }
示例#25
0
        IList drawAddElement(IList list, string memberName, Type elementType)
        {
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField(memberName, "empty");
                if (EditorLayout.MiniButton("add " + elementType.ToCompilableString().ShortTypeName()))
                {
                    object defaultValue;
                    if (EntityDrawer.CreateDefault(elementType, out defaultValue))
                    {
                        list.Add(defaultValue);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            return(list);
        }
        Array drawAddElement(Array array, string memberName, Type elementType)
        {
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField(memberName, "empty");
                if (EditorLayout.MiniButton("add " + elementType.ToCompilableString().ShortTypeName()))
                {
                    object defaultValue;
                    if (EntityDrawer.CreateDefault(elementType, out defaultValue))
                    {
                        var newArray = Array.CreateInstance(elementType, 1);
                        newArray.SetValue(defaultValue, 0);
                        array = newArray;
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            return(array);
        }
示例#27
0
        public static void DrawEntity(IEntity entity)
        {
            var bgColor = GUI.backgroundColor;

            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("Destroy Entity"))
            {
                entity.Destroy();
            }

            GUI.backgroundColor = bgColor;

            DrawComponents(entity);

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Retained by (" + entity.retainCount + ")", EditorStyles.boldLabel);

            var safeAerc = entity.aerc as SafeAERC;

            if (safeAerc != null)
            {
                EditorLayout.BeginVerticalBox();
                {
                    foreach (var owner in safeAerc.owners.OrderBy(o => o.GetType().Name))
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.LabelField(owner.ToString());
                            if (EditorLayout.MiniButton("Release"))
                            {
                                entity.Release(owner);
                            }

                            EditorGUILayout.EndHorizontal();
                        }
                    }
                }
                EditorLayout.EndVerticalBox();
            }
        }
        void drawTypeDrawerFolder()
        {
            EditorGUILayout.BeginHorizontal();
            {
                var path = EditorLayout.ObjectFieldOpenFolderPanel(
                    "Type Drawers",
                    _visualDebuggingConfig.typeDrawerFolderPath,
                    _visualDebuggingConfig.typeDrawerFolderPath
                    );
                if (!string.IsNullOrEmpty(path))
                {
                    _visualDebuggingConfig.typeDrawerFolderPath = path;
                }

                if (EditorLayout.MiniButton("New"))
                {
                    EntityDrawer.GenerateITypeDrawer("MyType");
                }
            }
            EditorGUILayout.EndHorizontal();
        }
    void DrawKeysActionInput(bool _show, TCT_ActionInput _action)
    {
        if (!_show)
        {
            return;
        }

        if (_action == null || _action.AllKeyCodes.Count < 1)
        {
            return;
        }

        for (int i = 0; i < _action.AllKeyCodes.Count; i++)
        {
            Enum _currentKeyCode = _action.AllKeyCodes[i];

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.Separator();

            EditorLayout.EnumPopup(ref _currentKeyCode, "");

            if (_action.ExistKeyCode((KeyCode)_currentKeyCode) && (KeyCode)_currentKeyCode != _action.AllKeyCodes[i])
            {
                Debug.LogWarning("this Key is already assign in this Action. Please select an other");
            }
            else
            {
                _action.AllKeyCodes[i] = (KeyCode)_currentKeyCode;
            }

            EditorLayout.Button("x", RemoveKeyCode, _action, (KeyCode)_currentKeyCode);

            EditorGUILayout.EndHorizontal();

            EditorLayout.Space();
        }
    }
        public override void OnInspectorGUI()
        {
            var binaryBlueprint = ((BinaryBlueprint)target);

            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.LabelField("Blueprint", EditorStyles.boldLabel);
                binaryBlueprint.name = EditorGUILayout.TextField("Name", binaryBlueprint.name);

                if (_context != null)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        _contextIndex = EditorGUILayout.Popup(_contextIndex, _allContextNames);

                        if (EditorLayout.MiniButton("Switch Context"))
                        {
                            switchToContext();
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    EntityDrawer.DrawComponents(_entity);
                }
                else
                {
                    EditorGUILayout.LabelField("No contexts found!");
                }
            }
            var changed = EditorGUI.EndChangeCheck();

            if (changed)
            {
                binaryBlueprint.Serialize(_entity);
                AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(target), binaryBlueprint.name);
                EditorUtility.SetDirty(target);
            }
        }