コード例 #1
0
        private void OnGUI()
        {
            scrollView = Gl.BeginScrollView(scrollView);
            {
                Gl.TextArea(log);
            }
            Gl.EndScrollView();

            EditorUtil.HorizontalRule();

            Gl.BeginHorizontal();
            {
                Gl.Label("Save Log:", Gl.ExpandWidth(false));
                outputPath = Gl.TextField(outputPath);
            }
            Gl.EndHorizontal();

            Gl.BeginHorizontal();
            {
                if (Gl.Button("Save"))
                {
                    PrintLog();
                }

                if (Gl.Button("Close"))
                {
                    Close();
                }
            }
            Gl.EndHorizontal();
        }
コード例 #2
0
ファイル: InspectorSearch.cs プロジェクト: patel22p/dorumon
    private void DrawObjects()
    {
        List <string> toremove = new List <string>();

        foreach (var inst in instances)
        {
            GUI.BeginHorizontal();
            if (GUI.Button(inst))
            {
                Object o = GameObject.Find(inst) != null?GameObject.Find(inst) : GameObject.FindObjectsOfTypeIncludingAssets(typeof(GameObject)).FirstOrDefault(a => a.name == inst);

                Selection.activeObject = o;
            }
            if (GUI.Button("X", GUI.ExpandWidth(false)))
            {
                toremove.Add(inst);
            }
            GUI.EndHorizontal();
        }
        foreach (var inst in toremove)
        {
            instances.Remove(inst);
            SaveParams();
        }
    }
コード例 #3
0
        public static void SetKeyBinding(ref KeyCode keyCode)
        {
            string label = (keyCode == KeyCode.None) ? Strings.GetText("button_PressKey") : keyCode.ToString();

            if (GL.Button(label, GL.ExpandWidth(false)))
            {
                keyCode = KeyCode.None;
            }
            if (keyCode == KeyCode.None && Event.current != null)
            {
                if (Event.current.isKey)
                {
                    keyCode = Event.current.keyCode;
                    Input.ResetInputAxes();
                }
                else
                {
                    foreach (KeyCode mouseButton in mouseButtonsValid)
                    {
                        if (Input.GetKey(mouseButton))
                        {
                            keyCode = mouseButton;
                            Input.ResetInputAxes();
                        }
                    }
                }
            }
        }
コード例 #4
0
 public static void SetModifiedValueButtonDiceFormula <T>(int rolls, DiceType dice, string name, string guid)
 {
     if (GL.Button(Strings.GetText("button_SetTo") + $" {rolls} * {dice}", GL.ExpandWidth(false)))
     {
         ModifiedDiceFormula diceFormula = new ModifiedDiceFormula();
         diceFormula.m_Rolls = rolls;
         diceFormula.m_Dice  = dice;
         FileInfo file = new FileInfo(Storage.modEntryPath + Storage.modifiedBlueprintsFolder + "\\" + guid + ".json");
         if (File.Exists(file.FullName))
         {
             T modifiedItem = ModifiedBlueprintTools.DeserialiseItem <T>(file);
             Traverse.Create(modifiedItem).Property(name).SetValue(diceFormula);
             string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented);
             File.WriteAllText(file.FullName, json);
         }
         else
         {
             T modifiedItem = default(T);
             modifiedItem = Activator.CreateInstance <T>();
             Traverse.Create(modifiedItem).Property(name).SetValue(diceFormula);
             string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented);
             File.WriteAllText(file.FullName, json);
         }
         ModifiedBlueprintTools.blueprintLists = false;
         ModifiedBlueprintTools.Patch();
     }
 }
コード例 #5
0
 public static void SetModifiedValueButtonAttackType <T>(string name, string guid)
 {
     foreach (AttackType attackType in (AttackType[])Enum.GetValues(typeof(AttackType)))
     {
         if (GL.Button(Strings.GetText("button_SetTo") + $" {attackType}", GL.ExpandWidth(false)))
         {
             FileInfo file = new FileInfo(Storage.modEntryPath + Storage.modifiedBlueprintsFolder + "\\" + guid + ".json");
             if (File.Exists(file.FullName))
             {
                 T modifiedItem = ModifiedBlueprintTools.DeserialiseItem <T>(file);
                 Traverse.Create(modifiedItem).Property(name).SetValue(attackType);
                 string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented);
                 File.WriteAllText(file.FullName, json);
             }
             else
             {
                 T modifiedItem = default(T);
                 modifiedItem = Activator.CreateInstance <T>();
                 Traverse.Create(modifiedItem).Property(name).SetValue(attackType);
                 string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented);
                 File.WriteAllText(file.FullName, json);
             }
             ModifiedBlueprintTools.blueprintLists = false;
             ModifiedBlueprintTools.Patch();
         }
     }
 }
コード例 #6
0
ファイル: InspectorSearch.cs プロジェクト: patel22p/dorumon
    protected virtual void OnGUI()
    {
        if (!SetPivot && Selection.activeGameObject)
        {
            oldpos = Selection.activeGameObject.transform.position;
        }
        GUI.BeginHorizontal();
        SetPivot = (GUI.Toggle(SetPivot, "Pivot", GUI.ExpandWidth(false)) && Selection.activeGameObject != null);

        var old = SetCam;

        SetCam = (GUI.Toggle(SetCam && Camera.main != null, "Cam", GUI.ExpandHeight(false))); //camset

        if (SetCam != old && SetCam == false)
        {
            ResetCam();
        }
        if (GUI.Button("Apply"))
        {
            ApplyAll();
        }
        if (GUI.Button("Add"))
        {
            if (!instances.Contains(Selection.activeObject.name))
            {
                instances.Add(Selection.activeObject.name);
                SaveParams();
            }
        }
        GUI.EndHorizontal();
        DrawObjects();
        DrawSearch();
    }
コード例 #7
0
ファイル: InspectorSearch.cs プロジェクト: patel22p/dorumon
    protected virtual void OnGUI()
    {
        if (GUI.Button("Init"))
        {
            foreach (var go in Selection.gameObjects)
            {
                foreach (var scr in go.GetComponents <Base>())
                {
                    scr.Init();
                }
            }
        }
        foreach (var a in GameObject.FindGameObjectsWithTag("EditorGUI").Where(a => a != Selection.activeGameObject))
        {
            a.GetComponent <Base>().OnEditorGui();
        }

        if (Selection.activeGameObject != null)
        {
            var bs2 = Selection.activeGameObject.GetComponent <Base>();
            if (bs2 != null)
            {
                bs2.OnEditorGui();
            }
        }
        GUI.BeginHorizontal();
        Base.debug = GUI.Toggle(Base.debug, "debug", GUI.ExpandWidth(false));
        GUI.EndHorizontal();
        DrawSearch();
    }
コード例 #8
0
 public static void SetModifiedValueStatType <T>(string name, string guid)
 {
     StatType[] statTypes = (StatType[])Enum.GetValues(typeof(StatType));
     for (int i = 0; i < statTypes.Count(); i++)
     {
         switch (i)
         {
         case 0:
         case 4:
         case 8:
         case 12:
         case 16:
         case 20:
         case 24:
         case 28:
         case 32:
         case 36:
             GL.BeginHorizontal();
             break;
         }
         if (GL.Button(Strings.GetText("button_SetTo") + $" {statTypes[i]}", GL.ExpandWidth(false)))
         {
             FileInfo file = new FileInfo(Storage.modEntryPath + Storage.modifiedBlueprintsFolder + "\\" + guid + ".json");
             if (File.Exists(file.FullName))
             {
                 T modifiedItem = ModifiedBlueprintTools.DeserialiseItem <T>(file);
                 Traverse.Create(modifiedItem).Property(name).SetValue(statTypes[i]);
                 string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented);
                 File.WriteAllText(file.FullName, json);
             }
             else
             {
                 T modifiedItem = default(T);
                 modifiedItem = Activator.CreateInstance <T>();
                 Traverse.Create(modifiedItem).Property(name).SetValue(statTypes[i]);
                 string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented);
                 File.WriteAllText(file.FullName, json);
             }
             ModifiedBlueprintTools.blueprintLists = false;
             ModifiedBlueprintTools.Patch();
         }
         switch (i)
         {
         case 3:
         case 7:
         case 11:
         case 15:
         case 19:
         case 23:
         case 27:
         case 31:
         case 35:
         case 37:
             GL.EndHorizontal();
             break;
         }
     }
 }
コード例 #9
0
ファイル: InspectorSearch.cs プロジェクト: patel22p/dorumon
    protected virtual void OnGUI()
    {
        if (Camera.main == null)
        {
            return;
        }
        if (!SetPivot && Selection.activeGameObject)
        {
            oldpos = Selection.activeGameObject.transform.position;
        }
        GUI.BeginHorizontal();
        SetPivot = (GUI.Toggle(SetPivot, "Pivot", GUI.ExpandWidth(false)) && Selection.activeGameObject != null);

        var old = SetCam;

        SetCam = (GUI.Toggle(SetCam && Camera.main != null, "Cam", GUI.ExpandHeight(false))); //camset

        Camera.main.renderingPath = (RenderingPath)gui.EnumPopup(Camera.main.renderingPath);
        if (SetCam != old && SetCam == false)
        {
            ResetCam();
        }
        if (GUI.Button("Apply"))
        {
            ApplyAll();
        }
        if (GUI.Button("Add"))
        {
            if (!instances.Contains(Selection.activeObject.name))
            {
                instances.Add(Selection.activeObject.name);
                SaveParams();
            }
        }
        if (GUI.Button("Init"))
        {
            foreach (var a in Selection.gameObjects.Select(a => a.GetComponent <MonoBehaviour>()))
            {
                a.SendMessage("Init", SendMessageOptions.DontRequireReceiver);
            }
        }
        GUI.EndHorizontal();
        QualitySettings.shadowDistance = gui.FloatField("LightmapDist", QualitySettings.shadowDistance);
        if (Selection.activeGameObject != null)
        {
            LayerDistances();
            var bs = Selection.activeGameObject.GetComponent <Base>();
            if (bs != null)
            {
                bs.OnInspectorGUI();
            }
        }



        DrawObjects();
        DrawSearch();
    }
コード例 #10
0
        void OnGUI()
        {
            if (!model.enable)
            {
                model.enable = ToggleLeft("Log", model.enable); return;
            }
            instance = this; // TODO: why do this here?
            BeginHorizontal();
            if (GL.Button("˂", GL.ExpandWidth(false)))
            {
                model.SelectPreviousFrame();
                SceneView.RepaintAll();
            }
            GL.Button(frameNo, GL.MaxWidth(48f));
            if (GL.Button("˃", GL.ExpandWidth(false)))
            {
                model.SelectNextFrame();
                SceneView.RepaintAll();
            }
            GL.FlexibleSpace();
            EndHorizontal();
            //
            scroll = BeginScrollView(scroll);
            GUI.backgroundColor = Color.black;
            var style = GUI.skin.textArea;
            var f     = font;

            if (f == null)
            {
                Debug.LogError("font not available");
            }
            style.font              = f;
            style.fontSize          = FontSize;
            style.normal.textColor  = Color.white * 0.9f;
            style.focused.textColor = Color.white;
            style.focused.textColor = Color.white;
            GL.TextArea(model.output, GL.ExpandHeight(true));
            EndScrollView();
            //
            GUI.backgroundColor = Color.white;
            //
            var w30 = GL.MaxWidth(30f);

            BeginHorizontal();
            model.enable = ToggleLeft($"Log", model.enable, GL.MaxWidth(60));
            model.trails = ToggleLeft("Trails", model.trails, GL.MaxWidth(50));
            GL.Label("Offset: ", GL.ExpandWidth(false));
            var rs = model.renderSettings;

            rs.offset = FloatField(model.renderSettings.offset, w30);
            GL.Label("Size: ", w30);
            rs.size = FloatField(rs.size, w30);
            GL.Label("Col: ", w30);
            rs.color = EditorGUILayout.ColorField(rs.color);
            EndHorizontal();
        }
コード例 #11
0
 public static void Section(String title, params Action[] actions)
 {
     UI.Space(25);
     UI.Label($"====== {title} ======".bold(), GL.ExpandWidth(true));
     UI.Space(25);
     foreach (Action action in actions)
     {
         action();
     }
     UI.Space(10);
 }
コード例 #12
0
    protected virtual void OnGUI()
    {
        if (!SetPivot && Selection.activeGameObject)
        {
            oldpos = Selection.activeGameObject.transform.position;
        }
        GUI.BeginHorizontal();
        SetPivot = (GUI.Toggle(SetPivot, "Pivot", GUI.ExpandWidth(false)) && Selection.activeGameObject != null);

        var old = SetCam;

        SetCam = (GUI.Toggle(SetCam && Camera.main != null, "Cam", GUI.ExpandHeight(false))); //camset

        if (SetCam != old && SetCam == false)
        {
            ResetCam();
        }

        if (GUI.Button("NextCam"))
        {
            NextCamera();
        }

        if (GUI.Button("Init"))
        {
            Inits();
        }
        GUI.EndHorizontal();
        QualitySettings.shadowDistance = gui.FloatField("LightmapDist", QualitySettings.shadowDistance);
        GUI.BeginHorizontal();

        GUI.EndHorizontal();
        GUI.BeginHorizontal();
        Base.debug = GUI.Toggle(Base.debug, "debug", GUI.ExpandWidth(false));
        GUI.EndHorizontal();

        foreach (var a in GameObject.FindGameObjectsWithTag("EditorGUI").Where(a => a != Selection.activeGameObject))
        {
            a.GetComponent <bs>().OnEditorGui();
        }

        if (Selection.activeGameObject != null)
        {
            var bs2 = Selection.activeGameObject.GetComponent <Base>();
            if (bs2 != null)
            {
                bs2.OnEditorGui();
            }
        }
        DrawSearch();
    }
コード例 #13
0
 private static void OnGUIOther()
 {
     if (GUI.Button("Init"))
     {
         foreach (var go in Selection.gameObjects)
         {
             foreach (var scr in go.GetComponents <Base>())
             {
                 scr.Init();
             }
         }
     }
     Base.debug = GUI.Toggle(Base.debug, "debug", GUI.ExpandWidth(false));
 }
コード例 #14
0
ファイル: InspectorSearch.cs プロジェクト: patel22p/dorumon
    protected virtual void OnGUI()
    {
        if (!SetPivot && Selection.activeGameObject)
        {
            oldPivot = Selection.activeGameObject.transform.position;
        }
        SetPivot = (GUI.Toggle(SetPivot, "Pivot", GUI.ExpandWidth(false)) && Selection.activeGameObject != null);

        SetCam = (GUI.Toggle(SetCam && Camera.mainCamera != null, "Cam", GUI.ExpandHeight(false))); //camset
        QualitySettings.shadowDistance = gui.FloatField("LightmapDist", QualitySettings.shadowDistance);

        //OnGUIOther();
        OnGUIMono();
        DrawSearch();
    }
コード例 #15
0
    protected virtual void OnGUI()
    {
        if (Camera.main == null)
        {
            return;
        }
        if (!SetPivot && Selection.activeGameObject)
        {
            oldpos = Selection.activeGameObject.transform.position;
        }
        GUI.BeginHorizontal();
        SetPivot = (GUI.Toggle(SetPivot, "Pivot", GUI.ExpandWidth(false)) && Selection.activeGameObject != null);

        var old = SetCam;

        SetCam = (GUI.Toggle(SetCam && Camera.main != null, "Cam", GUI.ExpandHeight(false))); //camset

        Camera.main.renderingPath = (RenderingPath)gui.EnumPopup(Camera.main.renderingPath);
        if (SetCam != old && SetCam == false)
        {
            ResetCam();
        }
        if (GUI.Button("Apply"))
        {
            ApplyAll();
        }
        if (GUI.Button("Add"))
        {
            if (!instances.Contains(Selection.activeObject.name))
            {
                instances.Add(Selection.activeObject.name);
                SaveParams();
            }
        }
        if (GUI.Button("Init"))
        {
            Inits();
        }
        GUI.EndHorizontal();
        QualitySettings.shadowDistance = gui.FloatField("LightmapDist", QualitySettings.shadowDistance);
        GUI.BeginHorizontal();

        GUI.EndHorizontal();
        GUI.BeginHorizontal();
        //EditorPrefs.SetBool("Debug", GUI.Toggle(EditorPrefs.GetBool("Debug"), "debug", GUI.ExpandWidth(false)));
        Base.debug          = GUI.Toggle(Base.debug, "debug", GUI.ExpandWidth(false));
        Base.disableScripts = GUI.Toggle(Base.disableScripts, "disableScripts", GUI.ExpandWidth(false));

        GUI.EndHorizontal();

        if (Selection.activeGameObject != null)
        {
            var bs2 = Selection.activeGameObject.GetComponent <Base>();
            if (bs2 != null)
            {
                bs2.OnEditorGui();
            }
        }
        DrawObjects();
        DrawSearch();
    }
コード例 #16
0
ファイル: UI+Wrappers.cs プロジェクト: ThyWoof/ToyBox
 public static GUILayoutOption AutoWidth()
 {
     return(GL.ExpandWidth(false));
 }
コード例 #17
0
    void OnGUI()
    {
        //This is used for debugging, when the code is changed, simply refocussing the City Generator window will reload the code
        if (window == null)
        {
            OpenWindow();
        }
        scrollLocation = EGL.BeginScrollView(scrollLocation);

        GL.BeginHorizontal();
        GL.Label("Procedural City Generator", EditorStyles.boldLabel);
        GL.Space(50);
        EGL.BeginHorizontal("Box");
        rDebugToggle.target = EGL.ToggleLeft("Debug Mode?", rDebugToggle.target);
        EGL.EndHorizontal();
        GL.EndHorizontal();

        GL.Box("", new GUILayoutOption[] { GL.ExpandWidth(true), GL.Height(1) });
        showTerrainGUI();

        GL.Box("", new GUILayoutOption[] { GL.ExpandWidth(true), GL.Height(1) });
        showPopulationMapGUI();

        GL.Box("", new GUILayoutOption[] { GL.ExpandWidth(true), GL.Height(1) });
        showGrowthMapGUI();

        GL.Box("", new GUILayoutOption[] { GL.ExpandWidth(true), GL.Height(1) });
        showRoadMapGUI();

        GL.Box("", new GUILayoutOption[] { GL.ExpandWidth(true), GL.Height(1) });
        showBuildingGUI();

        GL.Box("", new GUILayoutOption[] { GL.ExpandWidth(true), GL.Height(1) });
        if (GL.Button("Reset"))
        {
            oldShowPop          = false;
            oldShowGrowth       = false;
            showTerrainUI       = true;
            showPopUI           = false;
            showGrowthUI        = false;
            showRoadMapAdvanced = false;
            showRoadMapUI       = false;
            showBuildingUI      = false;
            terrainGenerated    = false;
            populationGenerated = false;
            growthMapGenerated  = false;
            roadMapGenerated    = false;
            roadMeshGenerated   = false;

            terrainLabel    = "1. Terrain Generation - NOT COMPLETED ✘";
            populationLabel = "2. Population Map Generation - NOT COMPLETED ✘";
            growthLabel     = "3. Growth Map Generation - NOT COMPLETED ✘";
            roadmapLabel    = "4. Road Map Generation - NOT COMPLETED ✘";
            buildingLabel   = "5. Building Generation - NOT COMPLETED ✘";
        }

        // TESTING

        /*
         * if (GL.Button ("Generate Houses")) {
         *      generator.testHouses ();
         * }*/
        //END TESTING

        EGL.EndScrollView();
    }
コード例 #18
0
        public static void RenderMenu()
        {
            GL.BeginVertical("box");
            GL.BeginHorizontal();
            GL.Label(RichText.MainCategoryFormat(Strings.GetText("mainCategory_BlueprintModding")));
            GL.FlexibleSpace();
            MenuTools.AddFavouriteButton("BlueprintModdingRender");
            GL.EndHorizontal();


            GL.BeginHorizontal();
            if (GL.Button(MenuTools.TextWithTooltip("misc_Enable", "tooltip_BlueprintModding", $"{ settings.toggleItemModding}" + " ", "", false), GL.ExpandWidth(false)))
            {
                if (settings.toggleItemModding == Storage.isFalseString)
                {
                    settings.toggleItemModding = Storage.isTrueString;
                    ModifiedBlueprintTools.Patch();
                }
                else if (settings.toggleItemModding == Storage.isTrueString)
                {
                    settings.toggleItemModding = Storage.isFalseString;
                }
            }
            GL.EndHorizontal();

            if (Strings.ToBool(settings.toggleItemModding))
            {
                MenuTools.SingleLineLabel(Strings.GetText("label_ItemModdingInfo"));

                GL.BeginHorizontal();
                if (GL.Button(new GUIContent("spacehamster's JSON Blueprint Dump on github", "https://github.com/spacehamster/KingmakerCustomBlueprints/releases/tag/blueprints"), GL.ExpandWidth(false)))
                {
                    Application.OpenURL("https://github.com/spacehamster/KingmakerCustomBlueprints/releases/tag/blueprints");
                }
                GL.EndHorizontal();

                GL.Space(10);

                GL.BeginHorizontal();
                if (GL.Button(MenuTools.TextWithTooltip("button_PatchManually", "tooltip_PatchManually", true), GL.ExpandWidth(false)))
                {
                    Patch();
                }
                GL.EndHorizontal();


                GL.Space(10);

                ItemTypesMenu();

                GL.Space(10);

                showModifiedBlueprints = GL.Toggle(showModifiedBlueprints, RichText.Bold(Strings.GetText("toggle_ShowModifiedItems")));
                if (showModifiedBlueprints)
                {
                    GL.Space(10);

                    GL.BeginHorizontal();
                    if (GL.Button(RichText.Bold(Strings.GetText("button_LoadRefresh")), GL.ExpandWidth(false)))
                    {
                        blueprintLists = false;
                    }
                    GL.EndHorizontal();

                    GL.Space(10);

                    try
                    {
                        if (!blueprintLists)
                        {
                            blueprintsPaths.Clear();
                            blueprintsNames.Clear();
                            blueprintsTypes.Clear();
                            string        path      = Storage.modEntryPath + Storage.modifiedBlueprintsFolder;
                            DirectoryInfo directory = new DirectoryInfo(path);
                            if (directory.GetFiles("*.json").Any())
                            {
                                foreach (FileInfo file in directory.GetFiles("*.json"))
                                {
                                    string json = File.ReadAllText(file.FullName);
                                    string guid = Path.GetFileNameWithoutExtension(file.Name);

                                    if (guid == "Example" && directory.GetFiles("*.json").Count() == 1)
                                    {
                                        MenuTools.SingleLineLabel(Strings.GetText("message_NoModItems"));
                                        continue;
                                    }
                                    else if (guid == "Example" && directory.GetFiles("*.json").Count() > 1)
                                    {
                                        continue;
                                    }

                                    BlueprintScriptableObject blueprintScriptableObject = Utilities.GetBlueprintByGuid <BlueprintScriptableObject>(guid);

                                    if (blueprintScriptableObject != null)
                                    {
                                        if (blueprintItemCategory.Contains(blueprintScriptableObject.GetType()) || blueprintTypeArmourCategory.Contains(blueprintScriptableObject.GetType()) || blueprintScriptableObject.GetType() == blueprintWeaponType)
                                        {
                                            blueprintsPaths.Add(file.FullName);
                                            blueprintsNames.Add(blueprintScriptableObject.name);
                                            blueprintsTypes.Add(blueprintScriptableObject.GetType().ToString());
                                        }
                                    }
                                }
                            }
                            blueprintLists = true;
                        }

                        if (blueprintsPaths.Any())
                        {
                            for (int i = 0; i < blueprintsPaths.Count(); i++)
                            {
                                GL.BeginVertical("box");
                                GL.BeginHorizontal();
                                GL.Label(blueprintsNames[i] + $" ({blueprintsTypes[i]})");
                                GL.FlexibleSpace();
                                if (GL.Button(MenuTools.TextWithTooltip("button_RemoveItemModification", "misc_RequiresRestart", true), GL.ExpandWidth(false)))
                                {
                                    try
                                    {
                                        blueprintLists = false;
                                        File.Delete(blueprintsPaths[i]);
                                    }
                                    catch (Exception e)
                                    {
                                        modLogger.Log(e.ToString());
                                    }
                                }
                                GL.EndHorizontal();
                                GL.EndVertical();
                            }
                        }
                        else
                        {
                            MenuTools.SingleLineLabel(Strings.GetText("message_NoModItems"));
                        }
                    }
                    catch (Exception e)
                    {
                        modLogger.Log(e.ToString());
                    }
                }
            }
            GL.EndVertical();
        }
コード例 #19
0
ファイル: InspectorSearch.cs プロジェクト: patel22p/dorumon
    protected virtual void OnGUI()
    {
        if (Camera.main == null)
        {
            return;
        }
        if (!SetPivot && Selection.activeGameObject)
        {
            oldpos = Selection.activeGameObject.transform.position;
        }
        GUI.BeginHorizontal();
        SetPivot = (GUI.Toggle(SetPivot, "Pivot", GUI.ExpandWidth(false)) && Selection.activeGameObject != null);

        var old = SetCam;

        SetCam = (GUI.Toggle(SetCam && Camera.main != null, "Cam", GUI.ExpandHeight(false))); //camset

        Camera.main.renderingPath = (RenderingPath)gui.EnumPopup(Camera.main.renderingPath);
        if (SetCam != old && SetCam == false)
        {
            ResetCam();
        }
        if (GUI.Button("Apply"))
        {
            ApplyAll();
        }
        if (GUI.Button("Add"))
        {
            if (!instances.Contains(Selection.activeObject.name))
            {
                instances.Add(Selection.activeObject.name);
                SaveParams();
            }
        }
        if (GUI.Button("Init"))
        {
            Inits();
        }
        GUI.EndHorizontal();
        QualitySettings.shadowDistance = gui.FloatField("LightmapDist", QualitySettings.shadowDistance);
        if (Selection.activeGameObject != null) // Layer Distances
        {
            var ls   = Camera.main.layerCullDistances;
            var lr   = Selection.activeGameObject.layer;
            var oldv = ls[lr];
            ls[lr] = gui.FloatField("LayerDist", ls[lr]);
            if (oldv != ls[lr])
            {
                Camera.main.layerCullDistances = ls;
            }
        }
        GUI.BeginHorizontal();
        bake = GUI.Toggle(bake, "Bake", GUI.ExpandWidth(false));

        lfactor = EditorGUILayout.FloatField(lfactor, GUI.Width(30));
        GUI.Label("ambient", GUI.Width(30));
        dfactor = EditorGUILayout.FloatField(dfactor, GUI.Width(30));
        GUI.Label("Directional", GUI.Width(30));
        //if (GUI.Button("SetupLevel"))
        //    LevelSetup();
        GUI.EndHorizontal();
        GUI.BeginHorizontal();
        EditorPrefs.SetBool("Debug", GUI.Toggle(EditorPrefs.GetBool("Debug"), "debug", GUI.ExpandWidth(false)));
        web = GUI.Toggle(web, "web", GUI.ExpandWidth(false));
        GUI.EndHorizontal();
        if (GUI.Button("Build"))
        {
            Build();
            return;
        }
        if (Selection.activeGameObject != null)
        {
            var bs2 = Selection.activeGameObject.GetComponent <Base>();
            if (bs2 != null)
            {
                bs2.OnEditorGui();
            }
        }
        DrawObjects();
        DrawSearch();
    }
コード例 #20
0
        public static void ActionKeyEditStatsGui(UnitEntityData unit)
        {
            GL.Space(10);
            GL.BeginHorizontal();
            editUnitSelectedSizeIndex = GL.SelectionGrid(editUnitSelectedSizeIndex, Storage.charSizeArray, 4);
            GL.EndHorizontal();

            GL.Space(10);
            GL.BeginHorizontal();
            if (GL.Button(Strings.GetText("button_SetSizeTo") + $" {Storage.charSizeArray[editUnitSelectedSizeIndex]}",
                          GL.ExpandWidth(false)))
            {
                unit.Descriptor.State.Size = (Size)editUnitSelectedSizeIndex;
            }
            GL.EndHorizontal();
            GL.BeginHorizontal();
            if (GL.Button(Strings.GetText("button_SetToOriginalSize") + $" ({unit.Descriptor.OriginalSize})",
                          GL.ExpandWidth(false)))
            {
                unit.Descriptor.State.Size = unit.Descriptor.OriginalSize;
            }
            GL.EndHorizontal();
            MenuTools.SingleLineLabel(Strings.GetText("label_CurrentSize") + ": " + unit.Descriptor.State.Size);
            GL.Space(10);

            GL.BeginHorizontal();
            if (unit.Descriptor.HPLeft > 0)
            {
                if (GL.Button(Strings.GetText("button_Kill"), GL.ExpandWidth(false)))
                {
                    Common.Kill(unit);
                }
                if (GL.Button(Strings.GetText("button_Panic"), GL.ExpandWidth(false)))
                {
                    unit.Descriptor.AddFact(
                        (BlueprintUnitFact)Utilities.GetBlueprintByGuid <BlueprintBuff>(
                            "cf0e277e6b785f449bbaf4e993b556e0"), (MechanicsContext)null, new FeatureParam());
                }
                if (GL.Button(Strings.GetText("button_Freeze"), GL.ExpandWidth(false)))
                {
                    unit.Descriptor.AddFact(
                        (BlueprintUnitFact)Utilities.GetBlueprintByGuid <BlueprintBuff>(
                            "af1e2d232ebbb334aaf25e2a46a92591"), (MechanicsContext)null, new FeatureParam());
                }
                if (GL.Button(Strings.GetText("button_MakeCower"), GL.ExpandWidth(false)))
                {
                    unit.Descriptor.AddFact(
                        (BlueprintUnitFact)Utilities.GetBlueprintByGuid <BlueprintBuff>(
                            "6062e3a8206a4284d867cbb7120dc091"), (MechanicsContext)null, new FeatureParam());
                }
                if (GL.Button(Strings.GetText("button_SetOnFire"), GL.ExpandWidth(false)))
                {
                    unit.Descriptor.AddFact(
                        (BlueprintUnitFact)Utilities.GetBlueprintByGuid <BlueprintBuff>(
                            "315acb0b29671f74c8c7cc062b23b9d6"), (MechanicsContext)null, new FeatureParam());
                }
            }

            GL.EndHorizontal();

            GL.BeginHorizontal();
            editUnitStatsAmount = GL.TextField(editUnitStatsAmount, 10, GL.Width(85f));

            editUnitStatsAmount      = MenuTools.IntTestSettingStage1(editUnitStatsAmount);
            editUnitFinalStatsAmount = MenuTools.IntTestSettingStage2(editUnitStatsAmount, editUnitFinalStatsAmount);
            GL.EndHorizontal();

            var charStats = unit.Descriptor.Stats;

            MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("header_AttributesBaseValues")));
            foreach (var entry in Storage.statsAttributesDict)
            {
                MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, editUnitFinalStatsAmount);
            }
            MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("header_SkillsRanks")));
            foreach (var entry in Storage.statsSkillsDict)
            {
                MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, editUnitFinalStatsAmount);
            }
            MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("header_SocialSkillsBaseValues")));
            foreach (var entry in Storage.statsSocialSkillsDict)
            {
                MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, editUnitFinalStatsAmount);
            }
            MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("header_StatsSaves")));
            foreach (var entry in Storage.statsSavesDict)
            {
                MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, editUnitFinalStatsAmount);
            }
            MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("header_StatsCombat")));
            foreach (var entry in Storage.statsCombatDict)
            {
                MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, editUnitFinalStatsAmount);
            }
        }
コード例 #21
0
        public static void RenderMenu()
        {
            GL.BeginVertical("box");
            GL.BeginHorizontal();
            GL.Label(RichText.MainCategoryFormat(Strings.GetText("label_ActionKey")));
            GL.FlexibleSpace();
            MenuTools.AddFavouriteButton("ActionKeyRender");
            GL.EndHorizontal();

            GL.BeginHorizontal();
            if (GL.Button(
                    MenuTools.TextWithTooltip("misc_Enable", "tooltip_ActionKey", $"{settings.toggleEnableActionKey}" + " ",
                                              ""), GL.ExpandWidth(false)))
            {
                if (settings.toggleEnableActionKey == Storage.isFalseString)
                {
                    settings.toggleEnableActionKey = Storage.isTrueString;
                    settings.actionKeyIndex        = 0;
                    settings.actionKeyKillIndex    = 0;
                }
                else if (settings.toggleEnableActionKey == Storage.isTrueString)
                {
                    settings.toggleEnableActionKey = Storage.isFalseString;
                    settings.actionKeyIndex        = 0;
                    settings.actionKeyKillIndex    = 0;
                }
            }

            GL.EndHorizontal();

            if (settings.toggleEnableActionKey == Storage.isTrueString)
            {
                GL.Space(10);

                GL.BeginHorizontal();
                GL.Label(Strings.GetText("label_ActionKey") + ": ", GL.ExpandWidth(false));
                MenuTools.SetKeyBinding(ref settings.actionKey);
                GL.EndHorizontal();

                GL.Space(10);

                GL.BeginHorizontal();
                if (GL.Button(
                        MenuTools.TextWithTooltip("label_ActionKeyEnableExperimental",
                                                  "tooltip_ActionKeyEnableExperimental", $"{settings.toggleActionKeyExperimental}" + " ", ""),
                        GL.ExpandWidth(false)))
                {
                    if (settings.toggleActionKeyExperimental == Storage.isFalseString)
                    {
                        settings.toggleActionKeyExperimental = Storage.isTrueString;
                        settings.actionKeyIndex     = 0;
                        settings.actionKeyKillIndex = 0;
                    }
                    else if (settings.toggleActionKeyExperimental == Storage.isTrueString)
                    {
                        settings.toggleActionKeyExperimental = Storage.isFalseString;
                        settings.actionKeyIndex     = 0;
                        settings.actionKeyKillIndex = 0;
                    }
                }

                GL.EndHorizontal();

                MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("warning_ActionKeyExperimentalMode")));

                GL.BeginHorizontal();
                if (!Strings.ToBool(settings.toggleActionKeyExperimental))
                {
                    settings.actionKeyIndex = GL.SelectionGrid(settings.actionKeyIndex, mainArray, 3);
                }
                else
                {
                    settings.actionKeyIndex = GL.SelectionGrid(settings.actionKeyIndex, mainExperimentalArray, 3);
                }
                GL.EndHorizontal();

                GL.Space(10);

                switch (settings.actionKeyIndex)
                {
                case 1:
                    MenuTools.ToggleButton(ref settings.toggleActionKeyLogInfo, "buttonToggle_LogInfoToFile",
                                           "tooltip_LogInfoToFile");
                    MenuTools.ToggleButton(ref settings.toggleActionKeyShowUnitInfoBox,
                                           "buttonToggle_ShowUnitInfoBox", "tooltip_ShowUnitInfoBox");

                    break;

                case 2:
                    if (Strings.ToBool(settings.toggleActionKeyExperimental))
                    {
                        GL.Space(10);
                        GL.BeginHorizontal();
                        settings.actionKeyKillIndex =
                            GL.SelectionGrid(settings.actionKeyKillIndex, experimentalKillArray, 3);
                        GL.EndHorizontal();
                    }

                    break;

                case 4:
                    if (!Storage.buffFavourites.Any())
                    {
                        MenuTools.SingleLineLabel(Strings.GetText("message_NoFavourites"));
                    }
                    else
                    {
                        if (Storage.buffFavouritesLoad == true)
                        {
                            Main.RefreshBuffFavourites();
                            Storage.buffFavouritesLoad = false;
                        }

                        GL.Space(10);
                        GL.BeginHorizontal();
                        settings.actionKeyBuffIndex = GL.SelectionGrid(settings.actionKeyBuffIndex,
                                                                       Storage.buffFavouriteNames.ToArray(), 2);
                        GL.EndHorizontal();
                    }

                    if (Storage.buffFavourites != Storage.buffFavouritesGuids)
                    {
                        Storage.buffFavourites = Storage.buffFavouritesGuids;
                    }
                    break;

                case 5:
                    if (editUnit != null && editUnit.IsInGame && !editUnit.Descriptor.State.IsFinallyDead)
                    {
                        ActionKeyEditStatsGui(editUnit);
                    }
                    else
                    {
                        MenuTools.SingleLineLabel(Strings.GetText("message_NoUnitSelected"));
                    }
                    break;

                case 6:
                    if (teleportUnit != null && teleportUnit.IsInGame)
                    {
                        MenuTools.SingleLineLabel(Strings.GetText("label_TeleportUnit") +
                                                  $": {teleportUnit.CharacterName}");
                    }
                    else
                    {
                        MenuTools.SingleLineLabel(Strings.GetText("message_NoUnitSelected"));
                    }
                    break;

                case 7:
                    if (Strings.ToBool(settings.toggleActionKeyExperimental))
                    {
                        settings.actionKeySpawnRandomEnemy = GL.Toggle(settings.actionKeySpawnRandomEnemy,
                                                                       " " + Strings.GetText("toggle_SpawnRandomEnemy"), GL.ExpandWidth(false));
                    }

                    GL.Space(10);

                    MenuTools.SingleLineLabel(Strings.GetText("label_ChallengeRating") + " " +
                                              Strings.Parenthesis(Strings.GetText("misc_Bandit")));
                    GL.BeginHorizontal();
                    banidtCrIndex = GL.SelectionGrid(banidtCrIndex, numberArray0t7, 8);
                    GL.EndHorizontal();

                    break;

                case 8:
                    if (rotateUnit != null && rotateUnit.IsInGame)
                    {
                        MenuTools.SingleLineLabel(Strings.GetText("arrayItem_ActionKeyMain_RotateUnit") +
                                                  $": {rotateUnit.CharacterName}");
                    }
                    else
                    {
                        MenuTools.SingleLineLabel(Strings.GetText("message_NoUnitSelected"));
                    }
                    break;

                case 9:
                    if (load)
                    {
                        animationTypes.Clear();
                        animationTypesNames.Clear();
                        foreach (var animation in (UnitAnimationType[])Enum.GetValues(typeof(UnitAnimationType)))
                        {
                            animationTypes.Add(animation);
                            animationTypesNames.Add(animation.ToString());
                        }

                        load = false;
                    }

                    GL.BeginHorizontal();
                    animationTypesIndex = GL.SelectionGrid(animationTypesIndex, animationTypesNames.ToArray(), 3);
                    GL.EndHorizontal();
                    break;

                case 13:
                    MenuTools.SingleLineLabel(Strings.GetText("message_RecreateUnitDescriptor"));
                    break;
                }
            }

            GL.EndVertical();
        }
コード例 #22
0
        /// <summary>
        /// Field drawing utility used when a field of an object needs to be drawn
        /// </summary>
        private static object DrawPropertyObject(object property, Type type, int indent = 0)
        {
            var _val = property;

            // UnityEngine.Object
            if (typeof(U.Object).IsAssignableFrom(type))
            {
                U.Object _elementAsObject = null;
                _val.TryCast <U.Object>(out _elementAsObject);

#if UNITY_EDITOR
                _elementAsObject = EGl.ObjectField(_elementAsObject, type, true);
#else
                Gl.Label(_elementAsObject.ToString());
#endif

                _elementAsObject.TryCast <object>(out _val);

                return(_val);
            }

            // Initialize new if null (and newable).
            // Doing this after the Unity Object check will assure no GameObjects are spawned in the current scene
            if (_val == null)
            {
                var _constructorInfo = type.GetConstructor(Type.EmptyTypes);
                if (_constructorInfo != null)
                {
                    _val = _constructorInfo.Invoke(null);
                }
                else
                {
                    _val = default(object);
                }
            }

            // Implements the iDrawableProperty
            if (_val is iDrawableProperty)
            {
                iDrawableProperty _asDrawable = (iDrawableProperty)_val;
                _asDrawable.DrawAsProperty();
                return(_val);
            }

            // Bool
            if (_val is bool)
            {
                bool _elementAsBool = default(bool);

                if (_val.TryCast <bool>(out _elementAsBool))
                {
                    _elementAsBool = Gl.Toggle(_elementAsBool, "");
                }

                _elementAsBool.TryCast <object>(out _val);

                return(_val);
            }

            // Int
            if (_val is int)
            {
                int _elementAsInt = default(int);

                if (_val.TryCast <int>(out _elementAsInt))
                {
#if UNITY_EDITOR
                    _elementAsInt = EGl.IntField(_elementAsInt);
#else
                    int.TryParse(Gl.TextField(_elementAsInt.ToString()), out _elementAsInt);
#endif
                }

                _elementAsInt.TryCast <object>(out _val);

                return(_val);
            }

            // Float
            if (_val is float)
            {
                float _elementAsFloat = default(float);

                if (_val.TryCast <float>(out _elementAsFloat))
                {
#if UNITY_EDITOR
                    _elementAsFloat = EGl.FloatField(_elementAsFloat);
#else
                    float.TryParse(Gl.TextField(_elementAsFloat.ToString()), out _elementAsFloat);
#endif
                }

                _elementAsFloat.TryCast <object>(out _val);

                return(_val);
            }

            // String
            if (_val is string || typeof(string).IsAssignableFrom(type))
            {
                string _elementAsString = string.Empty;

                if (_val != null)
                {
                    if (_val.TryCast <string>(out _elementAsString))
                    {
                        _elementAsString = Gl.TextField(_elementAsString);
                    }
                }
                else
                {
                    Gl.Label("EMPTY STRING");
                }

                _elementAsString.TryCast <object>(out _val);

                return(_val);
            }

            // Try drawing using reflection,
            // expecting that it is a newable type that is already initialized in the code above
            if (_val != null)
            {
                var _valType = _val.GetType();
                if (indent == 0)
                {
                    Gl.Label(_valType.Name);
                }

                var _fieldInfo = _valType.GetFields(BindingFlags.Public | BindingFlags.Instance);

                if (indent < PROPERTY_DEPTH_LIMIT)
                {
                    indent++;

                    OpenIndent(indent);
                    foreach (var _field in _fieldInfo)
                    {
                        Gl.BeginHorizontal();
                        Gl.Label(StringUtil.WordSplit(_field.Name, true), Gl.ExpandWidth(false));
                        Gl.BeginVertical();
                        var _fieldValue = _field.GetValue(_val);
                        _field.SetValue(_val, DrawPropertyObject(_fieldValue, _field.FieldType, indent));
                        Gl.EndVertical();
                        Gl.EndHorizontal();
                    }

                    CloseIndent();
                }
                else
                {
                    Gl.Label(string.Format("[!] MAX DRAWING DEPTH ({0}) REACHED", PROPERTY_DEPTH_LIMIT));
                }

                return(_val);
            }

            Gl.Label("[ERROR] Unknown Type");
            return(null);
        }
コード例 #23
0
ファイル: ETools.cs プロジェクト: patel22p/dorumon
    protected override void OnGUI()
    {
        GUI.BeginHorizontal();
        web = GUI.Toggle(web, "web", GUI.ExpandWidth(false));
        var old = buildall;

        buildall = GUI.Toggle(buildall, "all", GUI.ExpandWidth(false));
        if (buildall && buildall != old)
        {
            disablePathFinding = debug = disableSounds = stopZombies = false;
        }

        if (GUILayout.Button("Build"))
        {
            EditorUtility.SetDirty(_Loader);
            Build();
            return;
        }
        if (GUI.Button("Refresh"))
        {
            if (!isPlaying)
            {
                var c = EditorApplication.currentScene;
                EditorApplication.SaveScene(c);
                for (int i = 0; i < 4; i++)
                {
                    EditorApplication.OpenScene("Assets/scenes/Menu.unity");
                    EditorApplication.OpenScene("Assets/scenes/Pitt.unity");
                }
                EditorApplication.OpenScene(c);
                return;
            }
        }
        GUI.EndHorizontal();
        BuildButtons();


        GUI.BeginHorizontal();
        if (GUI.Button("loader"))
        {
            EditorUtility.SetDirty(loader);
        }
        debug                      = GUI.Toggle(debug, "Debug");
        _Loader.build              = !debug;
        disablePathFinding         = GUI.Toggle(disablePathFinding, "DPath");
        _Loader.disablePathFinding = disablePathFinding;
        disableSounds              = GUI.Toggle(disableSounds, "Dsounds");
        _Loader.disableSounds      = disableSounds;
        stopZombies                = GUI.Toggle(stopZombies, "DZombies");
        _Loader.stopZombies        = stopZombies;
        client                     = GUI.Toggle(client, "client");
        _Loader.host               = !client;

        GUI.EndHorizontal();
        GUI.BeginHorizontal();
        bake = GUI.Toggle(bake, "Bake");

        lfactor = EditorGUILayout.FloatField(lfactor, GUI.Width(20));
        dfactor = EditorGUILayout.FloatField(dfactor, GUI.Width(20));

        if (GUI.Button("SetupLevel"))
        {
            LevelSetup();
        }
        if (GUI.Button("InitV"))
        {
            foreach (GameObject a in GameObject.FindObjectsOfTypeIncludingAssets(typeof(GameObject)))
            {
                if (AssetDatabase.IsMainAsset(a))
                {
                    bool mod = false;
                    var  ar  = a.transform.GetTransforms().ToArray();
                    foreach (var b in ar)
                    {
                        var bs = b.GetComponent <bs>();
                        if (bs != null)
                        {
                            bs.InitValues();
                            mod = true;
                        }
                    }
                    if (mod)
                    {
                        EditorUtility.SetDirty(a);
                    }
                }
                else if (EditorApplication.isPlaying)
                {
                    a.SendMessage("InitValues", SendMessageOptions.DontRequireReceiver);
                }
            }
        }

        if (GUI.Button("Init"))
        {
            Undo.RegisterSceneUndo("SceneInit");
            SetupMaterials();
            if (Selection.activeGameObject != null)
            {
                Inits(cspath);
            }
        }
        GUI.EndHorizontal();
        //BuildGUI();
        //GUI.Space(10);
        //if (Application.isPlaying && Base2._Game != null)
        //{
        //    foreach (Player p in Base2._Game.players)
        //        if (p != null)
        //            if (GUI.Button(p.name + ":" + p.OwnerID))
        //                Selection.activeObject = p;
        //}
        base.OnGUI();
    }
コード例 #24
0
 // GUILayout wrappers and extensions so other modules can use UI.MethodName()
 public static GUILayoutOption ExpandWidth(bool v) => GL.ExpandWidth(v);
コード例 #25
0
 public static GUILayoutOption AutoWidth() => GL.ExpandWidth(false);
コード例 #26
0
        void OnGUI()
        {
            if (!Config.enable)
            {
                Config.enable = ToggleLeft("Enable Logging", Config.enable); return;
            }
            //
            model.current = Selection.activeGameObject;
            instance      = this;
            BeginHorizontal();
            Config.useSelection = ToggleLeft("Use Selection", Config.useSelection,
                                             GL.MaxWidth(90f));
            Config.allFrames = ToggleLeft("History", Config.allFrames,
                                          GL.MaxWidth(60));
            // TODO - make return type filtering available with the global history
            if (model.applicableSelection)
            {
                GL.Label("→", GL.MaxWidth(25f));
                Config.rtypeIndex = Popup(Config.rtypeIndex, rtypeOptions);
            }
            EndHorizontal();
            if (!Config.useSelection)
            {
                model.current = null;
            }
            BeginHorizontal();
            int frameNo = browsing ? selectedFrame.index : Time.frameCount;

            if (GL.Button("˂", GL.ExpandWidth(false)))
            {
                SelectPrev();
            }
            GL.Button($"#{frameNo}", GL.MaxWidth(48f));
            if (GL.Button("˃", GL.ExpandWidth(false)))
            {
                SelectNext();
            }
            GL.FlexibleSpace();
            Config.step = ToggleLeft("Step", Config.step, GL.MaxWidth(48f));
            EndHorizontal();
            scroll = BeginScrollView(scroll);
            GUI.backgroundColor = Color.black;
            var style = GUI.skin.textArea;
            var f     = font;

            if (f == null)
            {
                Debug.LogError("font not available");
            }
            style.font              = f;
            style.fontSize          = FontSize;
            style.normal.textColor  = Color.white * 0.9f;
            style.focused.textColor = Color.white;
            style.focused.textColor = Color.white;
            string log = model.Output(useHistory, rtypeOptions[Config.rtypeIndex]);

            if (currentLog != log && Config.step)
            {
                Ed.isPaused = true;
            }
            currentLog = log;
            GL.TextArea(browsing ? selectedFrame.Format() : log,
                        GL.ExpandHeight(true));
            EndScrollView();
            GUI.backgroundColor = Color.white;
            BeginHorizontal();
            Config.enable = ToggleLeft(
                $"Enable Logging ({Logger.injectionTimeMs}ms)",
                Config.enable, GL.ExpandWidth(true));
            if (!Application.isPlaying)
            {
                if (GL.Button($"Clear", GL.MaxWidth(90f)))
                {
                    Clear();
                }
            }
            EndHorizontal();
            BeginHorizontal();
            GL.Label("Trail offset: ", GL.MaxWidth(60f));
            Config.trailOffset = FloatField(Config.trailOffset,
                                            GL.MaxWidth(30f));
            GL.Label("Size: ", GL.MaxWidth(30f));
            Config.handleSize = FloatField(Config.handleSize, GL.MaxWidth(30f));
            EndHorizontal();
        }
コード例 #27
0
        public void OnGUI(UnityModManager.ModEntry modEntry)
        {
            if (!Mod.Enabled)
            {
                return;
            }
            if (toggleStyle == null)
            {
                toggleStyle = new GUIStyle(GUI.skin.toggle)
                {
                    wordWrap = true
                }
            }
            ;

            using (new GL.VerticalScope("box"))
            {
                ToggleVendorProgression = GL.Toggle(ToggleVendorProgression, Local["Menu_Tog_VenProgress"], Array.Empty <GLO>());
            }
            using (new GL.VerticalScope("box"))
            {
                ToggleHighlightScrolls = GL.Toggle(ToggleHighlightScrolls, Local["Menu_Tog_HLScrolls"], Array.Empty <GLO>());
                using (new GUISubScope())
                    ScrollColor = OnGUIColorSlider(ScrollColor, Local["Menu_Txt_Unlearned"]);
            }
            using (new GL.VerticalScope("box"))
            {
                ToggleVendorTrash = GL.Toggle(ToggleVendorTrash, Local["Menu_Tog_VendorTrash"], toggleStyle, GL.ExpandWidth(false));
                using (new GUISubScope())
                {
                    TrashColor     = OnGUIColorSlider(TrashColor, Local["Menu_Txt_VendorTrash"]);
                    ToggleAutoSell = GL.Toggle(ToggleAutoSell, Local["Menu_Tog_AutoSell"], toggleStyle, GL.ExpandWidth(false));
                    using (new GL.HorizontalScope())
                    {
                        if (GL.Button(ToggleShowTrash ? Local["Menu_Tog_HideTrash"] : Local["Menu_Tog_ShowTrash"], GL.ExpandWidth(false)))
                        {
                            ToggleShowTrash = !ToggleShowTrash;
                        }
                        if (GL.Button(Local["Menu_Btn_ClearTrash"], GL.ExpandWidth(false)))
                        {
                            VendorTrashItems.Clear();
                        }
                    }
                    if (ToggleShowTrash)
                    {
                        using (new GUISubScope())
                        {
                            string remove = "";

                            foreach (string trash in VendorTrashItems)
                            {
                                using (new GL.VerticalScope("box", GL.ExpandWidth(false)))
                                {
                                    using (new GL.HorizontalScope())
                                    {
                                        bool hasKeep = TrashItemsKeep.ContainsKey(trash);
                                        GL.Label($"{library.Get<BlueprintItem>(trash).Name} x{((hasKeep) ? TrashItemsKeep[trash] : 0)} {Local["Menu_Txt_Kept"]}", GL.MaxHeight(screenWidth), GL.MaxHeight(lineHeight));
                                        if (GL.Button("+", GL.ExpandWidth(false)))
                                        {
                                            if (hasKeep)
                                            {
                                                TrashItemsKeep[trash]++;
                                            }
                                            else
                                            {
                                                TrashItemsKeep.Add(trash, 1);
                                            }
                                        }
                                        if (GL.Button("-", GL.ExpandWidth(false)))
                                        {
                                            if (hasKeep && TrashItemsKeep[trash] > 0)
                                            {
                                                TrashItemsKeep[trash]--;
                                            }
                                            else if (hasKeep)
                                            {
                                                TrashItemsKeep.Remove(trash);
                                            }
                                        }

                                        if (GL.Button(Local["Menu_Btn_Remove"], GL.ExpandWidth(false)))
                                        {
                                            remove = trash;
                                        }

                                        if (Event.current.type == EventType.Repaint)
                                        {
                                            screenWidth = GUILayoutUtility.GetLastRect().width;
                                        }
                                    }
                                }
                            }
                            if (remove != "")
                            {
                                VendorTrashItems.Remove(remove);
                            }
                        }
                    }
                }
            }
            using (new GL.VerticalScope("box"))
            {
                using (new GUISubScope())
                    OnGUILang();
            }
        }
コード例 #28
0
 ///<summary> Draws simple horizontal GUI line </summary>
 public static void HorizontalRule()
 {
     Gl.Box("", Gl.ExpandWidth(true), Gl.Height(2));
 }
コード例 #29
0
    protected override void OnGUI()
    {
        GUI.BeginHorizontal();
        web = GUI.Toggle(web, "web", GUI.ExpandWidth(false));
        var old = _Loader.completeBuild;

        _Loader.completeBuild = GUI.Toggle(_Loader.completeBuild, "all", GUI.ExpandWidth(false));
        if (_Loader.completeBuild && _Loader.completeBuild != old)
        {
            proxy = disablePathFinding = debug = disableSounds = stopZombies = false;
        }

        if (GUILayout.Button("Build"))
        {
            Build();
            return;
        }
        if (GUI.Button("Refresh"))
        {
            if (!isPlaying)
            {
                var c = EditorApplication.currentScene;
                EditorApplication.SaveScene(c);
                for (int i = 0; i < 4; i++)
                {
                    EditorApplication.OpenScene("Assets/scenes/Menu.unity");
                    EditorApplication.OpenScene("Assets/scenes/Pitt.unity");
                }
                EditorApplication.OpenScene(c);
                return;
            }
        }
        GUI.EndHorizontal();
        BuildButtons();



        GUI.BeginHorizontal();
        proxy                      = GUI.Toggle(proxy, "proxy");
        _Loader.proxy              = proxy;
        debug                      = GUI.Toggle(debug, "Debug");
        _Loader.build              = !debug;
        disablePathFinding         = GUI.Toggle(disablePathFinding, "DPath");
        _Loader.disablePathFinding = disablePathFinding;
        disableSounds              = GUI.Toggle(disableSounds, "Dsounds");
        _Loader.disableSounds      = disableSounds;
        stopZombies                = GUI.Toggle(stopZombies, "DZombies");
        _Loader.stopZombies        = stopZombies;
        client                     = GUI.Toggle(client, "client");
        _Loader.host               = !client;

        GUI.EndHorizontal();
        GUI.BeginHorizontal();
        bake = GUI.Toggle(bake, "Bake", GUI.ExpandWidth(false));

        lfactor = EditorGUILayout.FloatField(lfactor, GUI.Width(30));
        dfactor = EditorGUILayout.FloatField(dfactor, GUI.Width(30));

        if (GUI.Button("SetupLevel"))
        {
            LevelSetup();
        }

        if (GUI.Button("Init"))
        {
            Undo.RegisterSceneUndo("SceneInit");
            SetupMaterials();
            FixMaterials();
            if (Selection.activeGameObject != null)
            {
                Inits(cspath);
            }
            else
            {
                InitValues();
            }
        }
        GUI.EndHorizontal();

        base.OnGUI();
    }
コード例 #30
0
        // Build-Compatible GUI Utilities:

        /// <summary>
        /// List GUI drawer utility (Will modify the source list)
        /// </summary>
        public static List <T> ArrayFieldGUI <T>(List <T> list, ArrayFieldOption option = ArrayFieldOption.Default)
        {
            var _listCopy = new List <T>(list);

            U.GUIStyle _style = new U.GUIStyle("Box");

            if (!option.ContainsFlag(ArrayFieldOption.NoBoundries))
            {
                Gl.BeginVertical(_style, Gl.ExpandWidth(true));
            }

            var _clearButtonContent  = new U.GUIContent("Clr", "Clear Field");
            var _removeButtonContent = new U.GUIContent("X", "Remove Element");

            for (int i = 0; i < _listCopy.Count; i++)
            {
                if (!option.ContainsFlag(ArrayFieldOption.NoBoundries))
                {
                    Gl.BeginHorizontal(_style, Gl.ExpandWidth(true));
                }

                if (!option.ContainsFlag(ArrayFieldOption.NoIndex))
                {
                    Gl.Label(i.ToString(), Gl.ExpandWidth(false));
                }

                Gl.BeginVertical();
                {
                    _listCopy[i] = DrawPropertyField(_listCopy[i]);
                }
                Gl.EndVertical();

                if (!option.ContainsFlag(ArrayFieldOption.NoClearButton))
                {
                    if (Gl.Button(_clearButtonContent, Gl.ExpandWidth(false)))
                    {
                        _listCopy[i] = default(T);
                    }
                }

                if (!option.ContainsFlag(ArrayFieldOption.FixedSize))
                {
                    if (Gl.Button(_removeButtonContent, Gl.ExpandWidth(false)))
                    {
                        _listCopy.Remove(_listCopy[i]);
                        i--;
                    }
                }

                if (!option.ContainsFlag(ArrayFieldOption.NoBoundries))
                {
                    Gl.EndHorizontal();
                }
            }

            if (!option.ContainsFlag(ArrayFieldOption.FixedSize))
            {
                if (Gl.Button("Add Element"))
                {
                    _listCopy.Add(default(T));
                }
            }

            if (!option.ContainsFlag(ArrayFieldOption.NoBoundries))
            {
                Gl.EndVertical();
            }

            return(_listCopy);
        }