private void OnSceneGUI()
    {
        callForAddNode    = (selectedIndex > -1 && Event.current.control && !Event.current.shift && Event.current.type == EventType.MouseUp);
        callForRemoveNode = (selectedIndex > -1 && Event.current.control && Event.current.shift && Event.current.type == EventType.MouseUp);

        handleTransform      = spline.transform;
        handleRotation       = Tools.pivotRotation == PivotRotation.Local ? handleTransform.rotation : Quaternion.identity;
        bezierHandleRotation = Camera.current.transform.rotation;

        Event e = Event.current;

        if (toolboxFoldout)
        {
            if (selectedIndex < 0)
            {
                foldoutHeight = 68;
            }
            else
            {
                foldoutHeight = 120;
            }
        }
        else
        {
            foldoutHeight = 0;
        }
        Rect toolboxRect = new Rect(10f, Screen.height - (70f + foldoutHeight), 300f, 103f + foldoutHeight);

        // Don't deselect upon click
        if (toolboxFoldout && e.type == EventType.Layout)
        {
            HandleUtility.AddDefaultControl(0);
        }

        // Toolbox
        Handles.BeginGUI();
        GUILayout.BeginArea(toolboxRect);
        if (boxStyle == null)
        {
            boxStyle = GUI.skin.FindStyle("box");
        }
        GUILayout.BeginVertical(boxStyle);
        toolboxFoldout = GUILayout.Toggle(toolboxFoldout, playgroundLanguage.playgroundSpline, EditorStyles.foldout);
        if (toolboxFoldout)
        {
            DrawSelectedPointInspector();
        }
        GUILayout.EndVertical();
        GUILayout.EndArea();
        Handles.EndGUI();

        Vector3 p0 = ShowPoint(0);

        for (int i = 1; i < spline.ControlPointCount; i += 3)
        {
            Vector3 p1 = ShowPoint(i);
            Vector3 p2 = ShowPoint(i + 1);
            Vector3 p3 = ShowPoint(i + 2);

            Handles.color = new Color(1f, .8f, 0f);
            Handles.DrawLine(p0, p1);
            Handles.DrawLine(p2, p3);

            p0 = p3;
        }

        if (callForAddNode)
        {
            Undo.RecordObject(spline, "Add Node");
            spline.AddNode(selectedNode);
            EditorUtility.SetDirty(spline);
            selectedIndex = SelectIndex((selectedNode + 1) * 3);
        }
        if (callForRemoveNode)
        {
            Undo.RecordObject(spline, "Remove Node");
            spline.RemoveNode(selectedNode);
            EditorUtility.SetDirty(spline);
            if (selectedIndex >= spline.ControlPointCount)
            {
                selectedIndex = SelectIndex(spline.ControlPointCount - 1);
            }
        }
    }
示例#2
0
        private void OnGUI()
        {
            if (INSTALLATION_TAB < 0)
            {
                INSTALLATION_TAB = 0;
            }

            if (EditorApplication.isCompiling)
            {
                this.ShowNotification(new GUIContent(" Compiling...", EditorGUIUtility.IconContent("cs Script Icon").image));
            }
            else
            {
                this.RemoveNotification();
            }

            //Header
            {
                if (SCPE_GUI.HeaderImg)
                {
                    Rect headerRect = new Rect(0, -5, width, SCPE_GUI.HeaderImg.height);
                    UnityEngine.GUI.DrawTexture(headerRect, SCPE_GUI.HeaderImg, ScaleMode.ScaleToFit);
                    GUILayout.Space(SCPE_GUI.HeaderImg.height - 10);
                }
                else
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField("<b><size=24>SC Post Effects</size></b>\n<size=16>For Post Processing Stack</size>", SCPE_GUI.Header);
                }

                using (new EditorGUILayout.HorizontalScope())
                {
                    using (new EditorGUI.DisabledGroupScope((int)INSTALLATION_TAB != 0))
                    {
                        GUILayout.Toggle((INSTALLATION_TAB == 0), new GUIContent("Pre-install"), SCPE_GUI.ProgressTab);
                    }
                    using (new EditorGUI.DisabledGroupScope((int)INSTALLATION_TAB != 1))
                    {
                        GUILayout.Toggle(((int)INSTALLATION_TAB == 1), "Installation", SCPE_GUI.ProgressTab);
                    }
                    using (new EditorGUI.DisabledGroupScope((int)INSTALLATION_TAB != 2))
                    {
                        GUILayout.Toggle(((int)INSTALLATION_TAB == 2), "Finish", SCPE_GUI.ProgressTab);
                    }
                }
            }

            GUILayout.Space(5f);

            //Body
            Rect oRect    = EditorGUILayout.GetControlRect();
            Rect bodyRect = new Rect(oRect.x + 10, 115, width - 20, height);

            GUILayout.BeginArea(bodyRect);
            {
                switch (INSTALLATION_TAB)
                {
                case (Tab)0:
                    StartScreen();
                    break;

                case (Tab)1:
                    InstallScreen();
                    break;

                case (Tab)2:
                    FinalScreen();
                    break;
                }
            }
            GUILayout.EndArea();

            //Progress buttons

            Rect errorRect = new Rect(225, height - 95, width * 2.2f, 25);

            GUILayout.BeginArea(errorRect);

            if (hasError)
            {
                SCPE_GUI.DrawStatusString("Correct any errors to continue", SCPE_GUI.Status.Error, false);
            }
            GUILayout.EndArea();

            Rect buttonRect = new Rect(width / 2, height - 70, width / 2.2f, height - 25);

            GUILayout.BeginArea(buttonRect);

            using (new EditorGUILayout.HorizontalScope())
            {
                //EditorGUILayout.PrefixLabel(" ");

                //Disable buttons when installing
                using (new EditorGUI.DisabledGroupScope(Installer.CURRENTLY_INSTALLING))
                {
                    //Disable back button on first screen
                    using (new EditorGUI.DisabledGroupScope(INSTALLATION_TAB == Tab.Start))
                    {
                        if (GUILayout.Button("<size=16>‹</size> Back", SCPE_GUI.ProgressButtonLeft))
                        {
                            INSTALLATION_TAB--;
                        }
                    }
                    using (new EditorGUI.DisabledGroupScope(hasError))
                    {
                        string btnLabel = string.Empty;
                        if (INSTALLATION_TAB == Tab.Start)
                        {
                            btnLabel = "Next <size=16>›</size>";
                        }
                        if (INSTALLATION_TAB == Tab.Install)
                        {
                            btnLabel = "Install <size=16>›</size>";
                        }
                        if (INSTALLATION_TAB == Tab.Install && Installer.IS_INSTALLED)
                        {
                            btnLabel = "Finish";
                        }
                        if (INSTALLATION_TAB == Tab.Finish)
                        {
                            btnLabel = "Close";
                        }

                        if (GUILayout.Button(btnLabel, SCPE_GUI.ProgressButtonRight))
                        {
                            if (INSTALLATION_TAB == Tab.Start)
                            {
                                INSTALLATION_TAB = Tab.Install;
                                return;
                            }

                            //When pressing install again
                            if (INSTALLATION_TAB == Tab.Install)
                            {
                                if (Installer.IS_INSTALLED == false)
                                {
                                    Installer.Install();
                                }
                                else
                                {
                                    INSTALLATION_TAB = Tab.Finish;
                                }

                                return;
                            }

                            if (INSTALLATION_TAB == Tab.Finish)
                            {
                                Installer.PostInstall();
                                this.Close();
                            }
                        }
                    }
                }
            }
            GUILayout.EndArea();

            //Footer
            buttonRect = new Rect(width / 4, height - 30, width / 2.1f, height - 25);
            GUILayout.BeginArea(buttonRect);
            EditorGUILayout.LabelField("- Staggart Creations -", SCPE_GUI.Footer);
            GUILayout.EndArea();
        }
        private void DrawDefines()
        {
            GUILayout.BeginArea(new Rect(5, 256, position.width - 10, position.height - 256));
            EditorGUILayout.LabelField("Current Build Target: " + ObjectNames.NicifyVariableName(EditorUserBuildSettings.activeBuildTarget.ToString()), EditorStyles.boldLabel);

            var define_USE_PHYSICS2D   = false;
            var define_USE_TIMELINE    = false;
            var define_USE_CINEMACHINE = false;
            var define_USE_ARTICY      = false;
            var define_USE_AURORA      = false;
            var define_TMP_PRESENT     = false;
            var define_USE_STM         = false;
            var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup).Split(';');

            for (int i = 0; i < defines.Length; i++)
            {
                if (string.Equals(ScriptingSymbolNames.USE_PHYSICS2D, defines[i].Trim()))
                {
                    define_USE_PHYSICS2D = true;
                }
                if (string.Equals(ScriptingSymbolNames.USE_TIMELINE, defines[i].Trim()))
                {
                    define_USE_TIMELINE = true;
                }
                if (string.Equals(ScriptingSymbolNames.USE_CINEMACHINE, defines[i].Trim()))
                {
                    define_USE_CINEMACHINE = true;
                }
                if (string.Equals(ScriptingSymbolNames.USE_ARTICY, defines[i].Trim()))
                {
                    define_USE_ARTICY = true;
                }
                if (string.Equals(ScriptingSymbolNames.USE_AURORA, defines[i].Trim()))
                {
                    define_USE_AURORA = true;
                }
                if (string.Equals(ScriptingSymbolNames.TMP_PRESENT, defines[i].Trim()))
                {
                    define_TMP_PRESENT = true;
                }
                if (string.Equals(ScriptingSymbolNames.USE_STM, defines[i].Trim()))
                {
                    define_USE_STM = true;
                }
            }
#if EVALUATION_VERSION || !UNITY_2018_1_OR_NEWER
            define_USE_PHYSICS2D = true;
            define_TMP_PRESENT   = false;
            define_USE_STM       = false;
            define_USE_ARTICY    = true;
            define_USE_AURORA    = true;
#endif

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.LabelField(new GUIContent("Enable support for:", "NOTE: Enables Dialogue System support. You must still enable each package in Package Manager."));
#if UNITY_2018_1_OR_NEWER && !EVALUATION_VERSION
            var new_USE_PHYSICS2D = EditorGUILayout.ToggleLeft("2D Physics (USE_PHYSICS2D)", define_USE_PHYSICS2D);
#else
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.ToggleLeft(new GUIContent("2D Physics (USE_PHYSICS2D)", "Support is built in for evaluation version or Unity 2017 and earlier."), define_USE_PHYSICS2D);
            EditorGUI.EndDisabledGroup();
            var new_USE_PHYSICS2D = define_USE_PHYSICS2D;
#endif

            var new_USE_TIMELINE    = EditorGUILayout.ToggleLeft(new GUIContent("Timeline (USE_TIMELINE)", "Enable Dialogue System support for Timeline. You must still enable Timeline in Package Manager."), define_USE_TIMELINE);
            var new_USE_CINEMACHINE = EditorGUILayout.ToggleLeft(new GUIContent("Cinemachine (USE_CINEMACHINE)", "Enable Dialogue System support for Cinemachine. You must still enable Cinemachine in Package Manager."), define_USE_CINEMACHINE);

#if EVALUATION_VERSION
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.ToggleLeft(new GUIContent("articy:draft (USE_ARTICY)", "Enable Dialogue System support for articy:draft XML import."), define_USE_ARTICY);
            EditorGUILayout.ToggleLeft(new GUIContent("Aurora Toolset (USE_AURORA)", "Enable Dialogue System support for Aurora (Neverwinter Nights) Toolset import."), define_USE_AURORA);
            EditorGUI.EndDisabledGroup();
            var new_USE_ARTICY = define_USE_ARTICY;
            var new_USE_AURORA = define_USE_AURORA;
#else
            var new_USE_ARTICY = EditorGUILayout.ToggleLeft(new GUIContent("articy:draft (USE_ARTICY)", "Enable Dialogue System support for articy:draft XML import."), define_USE_ARTICY);
            var new_USE_AURORA = EditorGUILayout.ToggleLeft(new GUIContent("Aurora Toolset (USE_AURORA)", "Enable Dialogue System support for Aurora (Neverwinter Nights) Toolset import."), define_USE_AURORA);
#endif

#if EVALUATION_VERSION
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.ToggleLeft(new GUIContent("TextMesh Pro (TMP_PRESENT)", "TextMesh Pro support not available in evaluation version."), define_TMP_PRESENT);
            EditorGUILayout.ToggleLeft(new GUIContent("Super Text Mesh (USE_STM)", "Super Text Mesh support not available in evaluation version."), define_USE_STM);
            EditorGUI.EndDisabledGroup();
            var new_TMP_PRESENT = define_TMP_PRESENT;
            var new_USE_STM     = define_USE_STM;
#else
            var new_TMP_PRESENT = EditorGUILayout.ToggleLeft(new GUIContent("TextMesh Pro (TMP_PRESENT)", "Enable Dialogue System support for TextMesh Pro. You must still enable TextMesh Pro in Package Manager."), define_TMP_PRESENT);
            var new_USE_STM     = EditorGUILayout.ToggleLeft(new GUIContent("Super Text Mesh (USE_STM)", "Enable Dialogue System support for Super Text Mesh. Requires Super Text Mesh in project."), define_USE_STM);
#endif
            var changed = EditorGUI.EndChangeCheck();

            if (new_USE_PHYSICS2D != define_USE_PHYSICS2D)
            {
                MoreEditorUtility.ToggleScriptingDefineSymbol(ScriptingSymbolNames.USE_PHYSICS2D, new_USE_PHYSICS2D);
            }
            if (new_USE_TIMELINE != define_USE_TIMELINE)
            {
                MoreEditorUtility.ToggleScriptingDefineSymbol(ScriptingSymbolNames.USE_TIMELINE, new_USE_TIMELINE, true);
            }
            if (new_USE_CINEMACHINE != define_USE_CINEMACHINE)
            {
                MoreEditorUtility.ToggleScriptingDefineSymbol(ScriptingSymbolNames.USE_CINEMACHINE, new_USE_CINEMACHINE);
            }
            if (new_USE_ARTICY != define_USE_ARTICY)
            {
                MoreEditorUtility.ToggleScriptingDefineSymbol(ScriptingSymbolNames.USE_ARTICY, new_USE_ARTICY);
            }
            if (new_USE_AURORA != define_USE_AURORA)
            {
                MoreEditorUtility.ToggleScriptingDefineSymbol(ScriptingSymbolNames.USE_AURORA, new_USE_AURORA);
            }
            if (new_TMP_PRESENT != define_TMP_PRESENT)
            {
                MoreEditorUtility.ToggleScriptingDefineSymbol(ScriptingSymbolNames.TMP_PRESENT, new_TMP_PRESENT, true);
            }
            if (new_USE_STM != define_USE_STM)
            {
                if (new_USE_STM)
                {
                    if (EditorUtility.DisplayDialog("Enable Super Text Mesh Support", "This will enable Super Text Mesh support. Your project must already contain Super Text Mesh.\n\n*IMPORTANT*: Before pressing OK, you MUST move the Clavian folder into the Plugins folder!\n\nTo continue, press OK. If you need to install Super Text Mesh or move the folder first, press Cancel.", "OK", "Cancel"))
                    {
                        MoreEditorUtility.ToggleScriptingDefineSymbol(ScriptingSymbolNames.USE_STM, new_USE_STM);
                    }
                    else
                    {
                        changed = false;
                    }
                }
                else
                {
                    MoreEditorUtility.ToggleScriptingDefineSymbol(ScriptingSymbolNames.USE_STM, new_USE_STM);
                }
            }

            EditorWindowTools.DrawHorizontalLine();
            GUILayout.EndArea();

            if (changed)
            {
                EditorTools.ReimportScripts();
            }
        }
示例#4
0
 public static ILayoutGUI BeginArea(this ILayoutGUI self, Rect rect, GUIContent content, GUIStyle style)
 {
     GUILayout.BeginArea(rect, content, style);
     return(self);
 }
示例#5
0
    private void OnGUI()
    {
        GUI.Label(new Rect(width / 6, height * 0.25f, width, height * 0.5f), "Название");
        name = GUI.TextField(new Rect(width / 6, height * 0.5f, (Screen.width) / 4, height * 0.5f), name);
        GUI.Label(new Rect(width / 6, height * 1f, width, height * 0.5f), "Описание");
        description = GUI.TextArea(new Rect(width / 6, height * 1.25f, (Screen.width) / 4, 2.5f * height), description);


        GUI.DrawTextureWithTexCoords(new Rect(width + width / 6, height * 0.25f, width / 2, height), image, new Rect(i * 0.07143f, j * 0.03333f, 0.07143f, 0.03333f));
        if (GUI.Button(new Rect(width + (width) * 2 / 3, height * 0.25f, width / 4, height / 2), "-"))
        {
            if (i == 0)
            {
                if (j != 0)
                {
                    j--;
                    i = 13;
                }
            }
            else
            {
                i--;
            }
        }
        if (GUI.Button(new Rect(width + (width) * 2 / 3, height * 0.75f, width / 4, height / 2), "+"))
        {
            if (i == 13)
            {
                if (j != 29)
                {
                    j++;
                    i = 0;
                }
            }
            else
            {
                i++;
            }
        }
        GUI.Label(new Rect(width + width / 6, height * 1.5f, width, height * 0.5f), "Цена покупки");
        buyPrice = GUI.TextField(new Rect(width + width / 6, height * 1.75f, (Screen.width) / 4, height * 0.5f), buyPrice);
        GUI.Label(new Rect(width + width / 6, height * 2.25f, width, height * 0.5f), "Цена продажи");
        sellPrice = GUI.TextField(new Rect(width + width / 6, height * 2.5f, (Screen.width) / 4, height * 0.5f), sellPrice);
        GUI.Label(new Rect(width + width / 6, height * 3f, width, height * 0.5f), "Статы");
        stats = GUI.TextField(new Rect(width + width / 6, height * 3.25f, (Screen.width) / 4, height * 0.5f), stats);

        GUI.Label(new Rect(width * 2 + width / 6, height * 0.25f, width, height * 0.5f), "Уровень использования");
        lvl = GUI.TextField(new Rect(width * 2 + width / 6, height * 0.5f, (Screen.width) / 4, height * 0.5f), lvl);

        GUI.Label(new Rect(width * 2 + width / 6, height, width, height * 0.5f), "Ограничение по расе");
        GUILayout.BeginArea(new Rect(width * 2 + width / 6, height * 1.25f, (Screen.width) / 4, height * 0.75f));
        {
            if (GUILayout.Button(raceStr))
            {
                isOpen2 = !isOpen2;
            }
            if (isOpen2)
            {
                scrollPos = GUILayout.BeginScrollView(scrollPos);
                {
                    foreach (var rac in DataBaseInfo.races)
                    {
                        if (GUILayout.Button(rac.RaceName, GUILayout.ExpandWidth(true)))
                        {
                            raceStr = rac.RaceName;
                            raceId  = rac.Id;
                            isOpen2 = false;
                        }
                    }
                }
                GUILayout.EndScrollView();
            }
        }
        GUILayout.EndArea();

        GUI.Label(new Rect(width * 2 + width / 6, height * 2, width, height * 0.5f), "Тип вещи");
        GUILayout.BeginArea(new Rect(width * 2 + width / 6, height * 2.25f, (Screen.width) / 4, height * 0.75f));
        {
            if (GUILayout.Button(selected))
            {
                isOpen = !isOpen;
            }
            if (isOpen)
            {
                scrollPos = GUILayout.BeginScrollView(scrollPos);
                {
                    foreach (var itemType in DataBaseInfo.types)
                    {
                        if (GUILayout.Button(itemType.Type, GUILayout.ExpandWidth(true)))
                        {
                            selected = itemType.Type;
                            itemID   = itemType.Id;
                            isOpen   = false;
                        }
                    }
                }
                GUILayout.EndScrollView();
            }
        }
        GUILayout.EndArea();

        if (GUI.Button(new Rect(width * 2 + width / 6, height * 3f, (Screen.width) / 4, height), "Добавить"))
        {
            if (name != "" && sellPrice != "" && buyPrice != "" && itemID != 0 && stats != "")
            {
                using (DatabaseManager manager = new DatabaseManager("gamedata.db"))
                {
                    if (manager.ConnectToDatabase())
                    {
                        Condition con = DataBaseInfo.conditions.FirstOrDefault(x => x.Level == int.Parse(lvl) && x.RaceId == raceId);
                        if (con == null)
                        {
                            manager.InsertRecord <Condition>(new Condition()
                            {
                                Level = int.Parse(lvl), RaceId = raceId
                            });
                            DataBaseInfo.conditions = (List <Condition>)manager.ReadAll <Condition>();
                            con = DataBaseInfo.conditions[DataBaseInfo.conditions.Count - 1];
                        }
                        manager.InsertRecord <Item>(new Item()
                        {
                            Name = name, Description = description, SellPrice = int.Parse(sellPrice), AttackDistance = 0, BuyPrice = int.Parse(buyPrice), ItemTypeId = itemID, SpeedAttack = 0, Stats = int.Parse(stats), Image = string.Format("{0}_{1}", i + 1, j + 1), ConditionId = con.Id
                        });
                        DataBaseInfo.shop = (List <Shop>)manager.ReadAll <Shop>();
                    }
                }
                Application.LoadLevel(1);
            }


            // Condition con = new Condition() { Level = int.Parse( lvl), RaceId = raceId };
            //int racIdTest = 0;
            // newItem = new Item() { BuyPrice = buyPrice, Level = lvl, ConditionId =  };
        }
    }
示例#6
0
        void TopToolbar(Rect toolbarPos)
        {
            if (m_SearchStyles == null)
            {
                m_SearchStyles = new List <GUIStyle>();
                m_SearchStyles.Add(GetStyle("ToolbarSeachTextFieldPopup")); //GetStyle("ToolbarSeachTextField");
                m_SearchStyles.Add(GetStyle("ToolbarSeachCancelButton"));
                m_SearchStyles.Add(GetStyle("ToolbarSeachCancelButtonEmpty"));
            }
            if (m_ButtonStyle == null)
            {
                m_ButtonStyle = GetStyle("ToolbarButton");
            }
            if (m_CogIcon == null)
            {
                m_CogIcon = EditorGUIUtility.FindTexture("_Popup");
            }


            GUILayout.BeginArea(new Rect(0, 0, toolbarPos.width, k_SearchHeight));

            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            {
                float spaceBetween = 4f;


                {
                    var  guiMode = new GUIContent("Create");
                    Rect rMode   = GUILayoutUtility.GetRect(guiMode, EditorStyles.toolbarDropDown);
                    if (EditorGUI.DropdownButton(rMode, guiMode, FocusType.Passive, EditorStyles.toolbarDropDown))
                    {
                        var menu = new GenericMenu();
                        foreach (var templateObject in settings.GroupTemplateObjects)
                        {
                            if (templateObject != null)
                            {
                                menu.AddItem(new GUIContent("Group/" + templateObject.name), false, m_EntryTree.CreateNewGroup, templateObject);
                            }
                        }
                        menu.AddSeparator(string.Empty);
                        menu.AddItem(new GUIContent("Group/Blank (no schema)"), false, m_EntryTree.CreateNewGroup, null);
                        menu.DropDown(rMode);
                    }
                }

                CreateProfileDropdown();

                {
                    var  guiMode = new GUIContent("Tools");
                    Rect rMode   = GUILayoutUtility.GetRect(guiMode, EditorStyles.toolbarDropDown);
                    if (EditorGUI.DropdownButton(rMode, guiMode, FocusType.Passive, EditorStyles.toolbarDropDown))
                    {
                        var menu = new GenericMenu();
                        menu.AddItem(new GUIContent("Inspect System Settings"), false, () => {
                            EditorGUIUtility.PingObject(AddressableAssetSettingsDefaultObject.Settings);
                            Selection.activeObject = AddressableAssetSettingsDefaultObject.Settings;
                        });
                        menu.AddItem(new GUIContent("Profiles"), false, () => EditorWindow.GetWindow <ProfileWindow>().Show(true));
                        menu.AddItem(new GUIContent("Labels"), false, () => EditorWindow.GetWindow <LabelWindow>(true).Intialize(settings));
                        menu.AddItem(new GUIContent("Analyze"), false, AnalyzeWindow.ShowWindow);
                        menu.AddItem(new GUIContent("Hosting Services"), false, () => EditorWindow.GetWindow <HostingServicesWindow>().Show(settings));
                        menu.AddItem(new GUIContent("Event Viewer"), false, ResourceProfilerWindow.ShowWindow);
                        menu.AddItem(new GUIContent("Check for Content Update Restrictions"), false, OnPrepareUpdate);
                        menu.AddItem(new GUIContent("Show Sprite and Subobject Addresses"), ProjectConfigData.showSubObjectsInGroupView, () => { ProjectConfigData.showSubObjectsInGroupView = !ProjectConfigData.showSubObjectsInGroupView; m_EntryTree.Reload(); });

                        var bundleList = AssetDatabase.GetAllAssetBundleNames();
                        if (bundleList != null && bundleList.Length > 0)
                        {
                            menu.AddItem(new GUIContent("Convert Legacy AssetBundles"), false, window.OfferToConvert);
                        }

                        menu.DropDown(rMode);
                    }
                }

                GUILayout.FlexibleSpace();
                GUILayout.Space(spaceBetween * 2f);

                {
                    GUILayout.Space(8);
                    var  guiMode = new GUIContent("Play Mode Script");
                    Rect rMode   = GUILayoutUtility.GetRect(guiMode, EditorStyles.toolbarDropDown);
                    if (EditorGUI.DropdownButton(rMode, guiMode, FocusType.Passive, EditorStyles.toolbarDropDown))
                    {
                        var menu = new GenericMenu();
                        for (int i = 0; i < settings.DataBuilders.Count; i++)
                        {
                            var m = settings.GetDataBuilder(i);
                            if (m.CanBuildData <AddressablesPlayModeBuildResult>())
                            {
                                menu.AddItem(new GUIContent(m.Name), i == settings.ActivePlayModeDataBuilderIndex, OnSetActivePlayModeScript, i);
                            }
                        }
                        menu.DropDown(rMode);
                    }
                }

                var  guiBuild = new GUIContent("Build");
                Rect rBuild   = GUILayoutUtility.GetRect(guiBuild, EditorStyles.toolbarDropDown);
                if (EditorGUI.DropdownButton(rBuild, guiBuild, FocusType.Passive, EditorStyles.toolbarDropDown))
                {
                    //GUIUtility.hotControl = 0;
                    var menu = new GenericMenu();
                    for (int i = 0; i < settings.DataBuilders.Count; i++)
                    {
                        var m = settings.GetDataBuilder(i);
                        if (m.CanBuildData <AddressablesPlayerBuildResult>())
                        {
                            menu.AddItem(new GUIContent("New Build/" + m.Name), false, OnBuildScript, i);
                        }
                    }

                    menu.AddItem(new GUIContent("Update a Previous Build"), false, OnUpdateBuild);
                    menu.AddItem(new GUIContent("Clean Build/All"), false, OnCleanAll);
                    menu.AddItem(new GUIContent("Clean Build/Content Builders/All"), false, OnCleanAddressables, null);
                    for (int i = 0; i < settings.DataBuilders.Count; i++)
                    {
                        var m = settings.GetDataBuilder(i);
                        menu.AddItem(new GUIContent("Clean Build/Content Builders/" + m.Name), false, OnCleanAddressables, m);
                    }
                    menu.AddItem(new GUIContent("Clean Build/Build Pipeline Cache"), false, OnCleanSBP);
                    menu.DropDown(rBuild);
                }

                GUILayout.Space(4);
                Rect searchRect    = GUILayoutUtility.GetRect(0, toolbarPos.width * 0.6f, 16f, 16f, m_SearchStyles[0], GUILayout.MinWidth(65), GUILayout.MaxWidth(300));
                Rect popupPosition = searchRect;
                popupPosition.width = 20;

                if (Event.current.type == EventType.MouseDown && popupPosition.Contains(Event.current.mousePosition))
                {
                    var menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Hierarchical Search"), ProjectConfigData.hierarchicalSearch, OnHierSearchClick);
                    menu.DropDown(popupPosition);
                }
                else
                {
                    var baseSearch   = ProjectConfigData.hierarchicalSearch ? m_EntryTree.customSearchString : m_EntryTree.searchString;
                    var searchString = m_SearchField.OnGUI(searchRect, baseSearch, m_SearchStyles[0], m_SearchStyles[1], m_SearchStyles[2]);
                    if (baseSearch != searchString)
                    {
                        if (ProjectConfigData.hierarchicalSearch)
                        {
                            m_EntryTree.customSearchString = searchString;
                            Reload();
                        }
                        else
                        {
                            m_EntryTree.searchString = searchString;
                        }
                    }
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }
示例#7
0
 public static ILayoutGUI BeginArea(this ILayoutGUI self, Rect rect, string text, GUIStyle style)
 {
     GUILayout.BeginArea(rect, text, style);
     return(self);
 }
示例#8
0
    void OnGUI()
    {
        if (string.IsNullOrEmpty(TextureURL))
        {
            saveURL    = EditorPrefs.GetString(LineTool.GetProjectKey("AnimationSaveURL"));
            TextureURL = EditorPrefs.GetString(LineTool.GetProjectKey("AnimationTextureURL"));
            Samples    = EditorPrefs.GetInt(LineTool.GetProjectKey("AnimationSamples"));
        }

        //Select folder contain textures
        EditorGUILayout.BeginHorizontal();
        TextureURL = EditorGUILayout.TextField("Textures URL", TextureURL);
        if (GUILayout.Button("Browser...", GUILayout.Width(100)))
        {
            TextureURL = EditorUtility.OpenFolderPanel("Choose Textures File", TextureURL, "");
            EditorPrefs.SetString(LineTool.GetProjectKey("AnimationTextureURL"), TextureURL);
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        //Get all sprites in this folder
        var           dataPath   = Application.dataPath;
        List <Sprite> allSprites = new List <Sprite>();

        if (!string.IsNullOrEmpty(TextureURL))
        {
            string[] folder_paths = System.IO.Directory.GetDirectories(TextureURL);
            foreach (string folder_path in folder_paths)
            {
                var fs = System.IO.Directory.GetFiles(folder_path, "*.png");
                foreach (var f in fs)
                {
                    string shortPath = "";
                    if (f.Contains(dataPath))
                    {
                        shortPath = f.Replace(dataPath, "Assets");
                    }
                    var objects  = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(shortPath);
                    var _sprites = objects.Where(q => q is Sprite).Cast <Sprite>();
                    allSprites.AddRange(_sprites);
                }
            }

            var files = System.IO.Directory.GetFiles(TextureURL, "*.png");
            foreach (var f in files)
            {
                string shortPath = "";
                if (f.Contains(dataPath))
                {
                    shortPath = f.Replace(dataPath, "Assets");
                }
                var objects  = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(shortPath);
                var _sprites = objects.Where(q => q is Sprite).Cast <Sprite>();
                allSprites.AddRange(_sprites);
            }
            EditorGUILayout.TextArea("Sprite Count: " + allSprites.Count);
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Samples", EditorStyles.boldLabel);
            Samples = EditorGUILayout.IntField(Samples);
            EditorPrefs.SetInt(LineTool.GetProjectKey("AnimationSamples"), Samples);
            EditorGUILayout.EndHorizontal();
        }
        GUILayout.Space(10);

        //Generate animation
        GUILayout.BeginArea(new Rect((position.width - 100) / 2, 100, 100, 30));
        if (GUILayout.Button("Generate", GUILayout.Width(100), GUILayout.Height(30)))
        {
            string existURL = string.IsNullOrEmpty(saveURL) ? Application.dataPath : saveURL;
            saveURL = EditorUtility.SaveFilePanel("Save Animation File", existURL, "Frames", "controller");
            if (saveURL.Contains(dataPath))
            {
                saveURL = saveURL.Replace(dataPath, "Assets");
            }
            EditorPrefs.SetString(LineTool.GetProjectKey("AnimationSaveURL"), saveURL);

            //Create new animator controller
            var controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath(saveURL);
            if (controller != null)
            {
                //Add parameter
                controller.AddParameter("idle", AnimatorControllerParameterType.Trigger);
                controller.AddParameter("walk", AnimatorControllerParameterType.Trigger);
                //Parameter for determine what anim to play
                controller.AddParameter("speed", AnimatorControllerParameterType.Float);
                controller.AddParameter("faceX", AnimatorControllerParameterType.Float);
                controller.AddParameter("faceY", AnimatorControllerParameterType.Float);
            }

            List <Sprite> sprites = new List <Sprite>();
            sprites.AddRange(allSprites);

            var rootStateMachine = controller.layers[0].stateMachine;
            Dictionary <string, UnityEditor.Animations.AnimatorState> animStates = new Dictionary <string, UnityEditor.Animations.AnimatorState>();
            var emptyState = rootStateMachine.AddState("Empty");

            foreach (var poseandTrigger in poses)
            {
                var pose    = poseandTrigger.Pose.ToLower();
                var trigger = poseandTrigger.Trigger;

                //Change sprite name to lower to determine anim by name
                if (sprites.Any(xx => xx.name.ToLower().Contains(pose) || (xx.name.ToLower().Replace("_", "")).Contains(pose)))
                {
                    UnityEditor.Animations.BlendTree blendTree;
                    var currentState = controller.CreateBlendTreeInController(pose, out blendTree, 0);
                    blendTree.name            = pose;
                    blendTree.blendType       = UnityEditor.Animations.BlendTreeType.SimpleDirectional2D;
                    blendTree.blendParameter  = "faceX";
                    blendTree.blendParameterY = "faceY";
                    foreach (var dir in directions)
                    {
                        var sameDir     = dir.Name.Replace("_", "");
                        var foundSprite = sprites.FindAll(xx => (xx.name.ToLower().Contains(pose) || (xx.name.ToLower().Replace("_", "")).Contains(pose)) && (xx.name.ToLower().Contains(dir.Name) || xx.name.ToLower().Contains(sameDir)));

                        if (foundSprite == null || foundSprite.Count == 0)
                        {
                            continue;
                        }
                        string clipName = controller.name + "_" + pose + "_" + dir.Name;

                        bool isLoop = trigger.Equals("idle") || trigger.Equals("walk");
                        Debug.Log(pose + " loop: " + isLoop);
                        var clip = createAnimationClip(foundSprite, clipName, isLoop);

                        AssetDatabase.AddObjectToAsset(clip, controller);
                        //AssetDatabase.CreateAsset(clip, saveURL + clipName+ ".anim");
                        blendTree.AddChild(clip, dir.Position);
                        if (!pose.Contains("fall"))
                        {
                            sprites.RemoveAll(xx => foundSprite.Contains(xx));
                        }
                        Debug.Log("Sprites Count: " + sprites.Count);
                    }
                    animStates.Add(pose, currentState);
                }
            }

            //Make Transition
            UnityEditor.Animations.AnimatorState idle = null;

            if (animStates.ContainsKey("idle"))
            {
                idle = animStates["idle"];
            }

            foreach (var animDict in animStates)
            {
                var pose        = animDict.Key;
                var poseTrigger = poses.Find(x => x.Pose.ToLower().Equals(pose.ToLower())).Trigger;
                var animState   = animDict.Value;

                if (pose.Equals("run"))
                {
                    var walk      = animDict.Value;
                    var transStop = walk.AddTransition(idle);
                    transStop.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Less, 0.001f, "speed");
                    transStop.duration    = 0;
                    transStop.hasExitTime = true;
                    var transWalk = idle.AddTransition(walk);
                    transWalk.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Greater, 0.001f, "speed");
                    transWalk.duration    = 0;
                    transWalk.hasExitTime = false;

                    var trans = rootStateMachine.AddAnyStateTransition(animStates[pose]);
                    trans.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, poseTrigger);
                    trans.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Greater, 0.001f, "speed");
                    trans.duration = 0;
                }
                else if (poses.Any(x => x.Pose.ToLower().Equals(pose)))
                {
                    //var poseTrigger = pose.Equals("attack") || pose.Equals("spell") ? "attack" : pose;
                    controller.AddParameter(poseTrigger, AnimatorControllerParameterType.Trigger);

                    var trans = rootStateMachine.AddAnyStateTransition(animState);
                    trans.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, poseTrigger);
                    trans.duration = 0;
                }
            }
            if (!animStates.ContainsKey("run") && idle != null)
            {
                var trans = rootStateMachine.AddAnyStateTransition(idle);
                trans.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "walk");
                trans.AddCondition(UnityEditor.Animations.AnimatorConditionMode.Greater, 0.001f, "speed");
                trans.duration = 0;
            }
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            Close();
        }
        GUILayout.EndArea();
    }
示例#9
0
        void OnGUI()
        {
            GUI.skin.label.richText = true;
            GUILayout.BeginArea(new Rect(Screen.height * 0.1f, Screen.width * 0.1f, Screen.width * 0.3f, Screen.height));
            {
                if (Application.loadedLevelName != "PromoScene")
                {
                    GUILayout.Label("<size=20><b>Test Scenes</b></size>");
                    switch (Application.loadedLevel)
                    {
                    case 0:
                    {
                        GUILayout.Label("With large amount's of SkinnedMeshRenderer's in the scene. Unity's built-in performance doesn't come close to Mesh Animator's");
                        break;
                    }

                    case 1:
                    {
                        GUILayout.Label("SkinnedMeshRenderer = Worst Performance");
                        GUILayout.Label("Mesh Animator + Mecanim Controller = Better Performance");
                        GUILayout.Label("Mesh Animator + Event Callbacks = Best Performance");
                        break;
                    }

                    case 2:
                    {
                        GUILayout.Label("Animated objects can be combined into a single object and draw call, greatly improving preformance.");
                        break;
                    }
                    }
                    GUI.color = Application.loadedLevel == 0 ? Color.green : Color.white;
                    if (GUILayout.Button("Stadium Test"))
                    {
                        Application.LoadLevel(0);
                    }
                    GUI.color = Application.loadedLevel == 1 ? Color.green : Color.white;
                    if (GUILayout.Button("Skinned Mesh Test"))
                    {
                        Application.LoadLevel(1);
                    }
                    GUI.color = Application.loadedLevel == 2 ? Color.green : Color.white;
                    if (GUILayout.Button("Mesh Filter Test"))
                    {
                        Application.LoadLevel(2);
                    }
                    GUI.color = Color.white;
                    GUILayout.Label("<size=20><b>FPS: " + fps + "</b></size>");
                    GUI.color = selectedOption == 0 ? Color.green : Color.white;
                    if (GUILayout.Button("Skinned Mesh Crowd"))
                    {
                        selectedOption = 0;
                        SpawnCrowd();
                    }
                    GUI.color = selectedOption == 1 ? Color.green : Color.white;
                    if (GUILayout.Button("Mesh Animator Crowd"))
                    {
                        selectedOption = 1;
                        SpawnCrowd();
                    }
                    GUI.color = Color.white;
                    int size = sizeOfCrowd;
                    GUILayout.Label("Crowd Size: " + sizeOfCrowd);
                    sizeOfCrowd = (int)GUILayout.HorizontalSlider(sizeOfCrowd, 1, maxSize);
                    if (size != sizeOfCrowd)
                    {
                        CancelInvoke("SpawnCrowd");
                        Invoke("SpawnCrowd", 1);
                    }
                }
                else
                {
                    GUILayout.Label("<color=black><size=19><b>FPS: " + fps + "</b></size></color>");
                }
            }
            GUILayout.EndArea();
        }
示例#10
0
    void OnGUI()
    {
        if (position.width != _oldPosition.width && Event.current.type == EventType.Layout)
        {
            Drawings     = null;
            _oldPosition = position;
        }

        GUILayout.BeginHorizontal();

        if (GUILayout.Toggle(_showingStyles, "Styles", EditorStyles.toolbarButton) != _showingStyles)
        {
            _showingStyles = !_showingStyles;
            _showingIcons  = !_showingStyles;
            Drawings       = null;
        }

        if (GUILayout.Toggle(_showingIcons, "Icons", EditorStyles.toolbarButton) != _showingIcons)
        {
            _showingIcons  = !_showingIcons;
            _showingStyles = !_showingIcons;
            Drawings       = null;
        }

        GUILayout.EndHorizontal();

        string newSearch = GUILayout.TextField(_search);

        if (newSearch != _search)
        {
            _search  = newSearch;
            Drawings = null;
        }

        float top = 36;

        if (Drawings == null)
        {
            string lowerSearch = _search.ToLower();

            Drawings = new List <Drawing>();

            GUIContent inactiveText = new GUIContent("inactive");
            GUIContent activeText   = new GUIContent("active");

            float x = 5.0f;
            float y = 5.0f;

            if (_showingStyles)
            {
                foreach (GUIStyle ss in GUI.skin.customStyles)
                {
                    if (lowerSearch != "" && !ss.name.ToLower().Contains(lowerSearch))
                    {
                        continue;
                    }

                    GUIStyle thisStyle = ss;

                    Drawing draw = new Drawing();

                    float width = Mathf.Max(
                        100.0f,
                        GUI.skin.button.CalcSize(new GUIContent(ss.name)).x,
                        ss.CalcSize(inactiveText).x + ss.CalcSize(activeText).x
                        ) + 16.0f;

                    float height = 60.0f;

                    if (x + width > position.width - 32 && x > 5.0f)
                    {
                        x  = 5.0f;
                        y += height + 10.0f;
                    }

                    draw.Rect = new Rect(x, y, width, height);

                    width -= 8.0f;

                    draw.Draw = () => {
                        if (GUILayout.Button(thisStyle.name, GUILayout.Width(width)))
                        {
                            CopyText("(GUIStyle)\"" + thisStyle.name + "\"");
                        }

                        GUILayout.BeginHorizontal();
                        GUILayout.Toggle(false, inactiveText, thisStyle, GUILayout.Width(width / 2));
                        GUILayout.Toggle(false, activeText, thisStyle, GUILayout.Width(width / 2));
                        GUILayout.EndHorizontal();
                    };

                    x += width + 18.0f;

                    Drawings.Add(draw);
                }
            }
            else if (_showingIcons)
            {
                if (_objects == null)
                {
                    _objects = new List <UnityEngine.Object>(Resources.FindObjectsOfTypeAll(typeof(Texture)));
                    _objects.Sort((pA, pB) => System.String.Compare(pA.name, pB.name, System.StringComparison.OrdinalIgnoreCase));
                }

                float rowHeight = 0.0f;

                foreach (UnityEngine.Object oo in _objects)
                {
                    Texture texture = (Texture)oo;

                    if (texture.name == "")
                    {
                        continue;
                    }

                    if (lowerSearch != "" && !texture.name.ToLower().Contains(lowerSearch))
                    {
                        continue;
                    }

                    Drawing draw = new Drawing();

                    float width = Mathf.Max(
                        GUI.skin.button.CalcSize(new GUIContent(texture.name)).x,
                        texture.width
                        ) + 8.0f;

                    float height = texture.height + GUI.skin.button.CalcSize(new GUIContent(texture.name)).y + 8.0f;

                    if (x + width > position.width - 32.0f)
                    {
                        x         = 5.0f;
                        y        += rowHeight + 8.0f;
                        rowHeight = 0.0f;
                    }

                    draw.Rect = new Rect(x, y, width, height);

                    rowHeight = Mathf.Max(rowHeight, height);

                    width -= 8.0f;

                    draw.Draw = () => {
                        if (GUILayout.Button(texture.name, GUILayout.Width(width)))
                        {
                            CopyText("EditorGUIUtility.FindTexture( \"" + texture.name + "\" )");
                        }

                        Rect textureRect = GUILayoutUtility.GetRect(texture.width, texture.width, texture.height, texture.height, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false));
                        EditorGUI.DrawTextureTransparent(textureRect, texture);
                    };

                    x += width + 8.0f;

                    Drawings.Add(draw);
                }
            }

            _maxY = y;
        }

        Rect r = position;

        r.y       = top;
        r.height -= r.y;
        r.x       = r.width - 16;
        r.width   = 16;

        float areaHeight = position.height - top;

        _scrollPos = GUI.VerticalScrollbar(r, _scrollPos, areaHeight, 0.0f, _maxY);

        Rect area = new Rect(0, top, position.width - 16.0f, areaHeight);

        GUILayout.BeginArea(area);

        int count = 0;

        foreach (Drawing draw in Drawings)
        {
            Rect newRect = draw.Rect;
            newRect.y -= _scrollPos;

            if (newRect.y + newRect.height > 0 && newRect.y < areaHeight)
            {
                GUILayout.BeginArea(newRect, GUI.skin.textField);
                draw.Draw();
                GUILayout.EndArea();

                count++;
            }
        }

        GUILayout.EndArea();
    }
        internal void OnGUI(Rect pos, AddressableAssetSettings settings)
        {
            if (m_Tree == null)
            {
                if (m_TreeState == null)
                {
                    m_TreeState = new TreeViewState();
                }

                m_Tree = new AssetSettingsAnalyzeTreeView(m_TreeState, this);
                m_Tree.Reload();
            }


            var  buttonHeight = 24f;
            Rect topRect      = new Rect(pos.x, pos.y, pos.width, buttonHeight);
            Rect treeRect     = new Rect(pos.x, pos.y + buttonHeight, pos.width, pos.height - buttonHeight);

            GUILayout.Space(200);
            GUILayout.BeginArea(topRect);
            GUILayout.BeginHorizontal();
            bool doRun = GUILayout.Button("Run Tests");


            bool doFix = GUILayout.Button("Fix All");

            if (GUILayout.Button("Clear Results"))
            {
                m_RuleResults = new List <AnalyzeRule.AnalyzeResult>();
                foreach (var r in rules)
                {
                    r.ClearAnalysis();
                }
                m_Tree.Reload();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            if (doRun)
            {
                m_RuleResults = new List <AnalyzeRule.AnalyzeResult>();
                foreach (var r in rules)
                {
                    m_RuleResults.AddRange(r.RefreshAnalysis(settings));
                }
                m_Tree.Reload();
            }

            if (doFix)
            {
                m_RuleResults = new List <AnalyzeRule.AnalyzeResult>();
                foreach (var r in rules)
                {
                    r.FixIssues(settings);
                    m_RuleResults.AddRange(r.RefreshAnalysis(settings));
                }

                m_Tree.Reload();
            }

            m_Tree.OnGUI(treeRect);
        }
    void OnGUI()
    {
        GUI.skin = skin;

        if (Event.current.keyCode == KeyCode.Tab)
        {
            if (Event.current.type == EventType.KeyDown)
            {
                m_HideFields = true;
            }
            else
            {
                m_HideFields = false;
            }
        }
        Rect rect = new Rect(new Vector2(padding.x, padding.y), size);

        GUILayout.BeginArea(rect);

        GUILayout.BeginHorizontal( );

        GUILayout.BeginVertical(GUILayout.Width(size.x - volWidth - 32));
        GUILayout.BeginHorizontal( );
        GUILayout.Box("Ins " + keyboard.currentInstrument.ToString("X2"));
        if (GUILayout.Button("<"))
        {
            IncInstrument(-1);
        }
        if (GUILayout.Button(">"))
        {
            IncInstrument(1);
        }
        GUILayout.EndHorizontal( );
        GUILayout.EndVertical( );
        GUILayout.Space(16);
        GUILayout.BeginVertical(GUILayout.Width(volWidth));

        GUILayout.BeginHorizontal( );
        if (GUILayout.Button("Volume"))
        {
            m_CurrentScreen = EditorScreen.Volume;
        }
        if (GUILayout.Button("Note"))
        {
            m_CurrentScreen = EditorScreen.Pitch;
        }
        if (GUILayout.Button("Wave"))
        {
            m_CurrentScreen = EditorScreen.Wave;
        }
        GUILayout.EndHorizontal( );

        switch (m_CurrentScreen)
        {
        case EditorScreen.Volume:
            ArraySlider(instrument.volumeTable, 0, 0xF);

            GUILayout.FlexibleSpace( );
            GUILayout.BeginHorizontal( );
            GUILayout.Box(instrument.volumeTable.Length.ToString("X2"));
            if (GUILayout.Button("-"))
            {
                ChangeVolTableSize(-1);
            }
            if (GUILayout.Button("+"))
            {
                ChangeVolTableSize(1);
            }
            GUILayout.EndHorizontal( );
            break;

        case EditorScreen.Pitch:
            GUILayout.Box("Arpeggio");
            arpEnvelope = TabSafeTextField(arpEnvelope);
            break;

        case EditorScreen.Wave:
            bool samp = instruments.presets [keyboard.currentInstrument].samplePlayback;
            samp = GUILayout.Toggle(samp, "Custom waves");

            if (samp != instruments.presets [keyboard.currentInstrument].samplePlayback)
            {
                Instruments.InstrumentInstance ins = instruments.presets [keyboard.currentInstrument];
                ins.samplePlayback = samp;
                instruments.presets [keyboard.currentInstrument] = ins;
            }

            if (samp)
            {
                GUILayout.BeginHorizontal( );
                WaveButton(Instruments.InstrumentInstance.Wave.Pulse);
                WaveButton(Instruments.InstrumentInstance.Wave.Saw);
                WaveButton(Instruments.InstrumentInstance.Wave.Triangle);
                WaveButton(Instruments.InstrumentInstance.Wave.Sine);
                WaveButton(Instruments.InstrumentInstance.Wave.Sample);
                GUILayout.EndHorizontal( );

                switch (instrument.customWaveform)
                {
                case Instruments.InstrumentInstance.Wave.Pulse:
                    int pwmStart, pwmEnd, pwmSpeed;
                    pwmStart = instrument.pulseWidthMin;
                    pwmEnd   = instrument.pulseWidthMax;
                    pwmSpeed = instrument.pulseWidthPanSpeed;

                    GUILayout.BeginHorizontal( );
                    GUILayout.Box("PWM min", GUILayout.Width(96));
                    pwmStart = (int)GUILayout.HorizontalSlider(pwmStart, 0, 100);
                    GUILayout.Box(pwmStart.ToString(), GUILayout.Width(32));
                    GUILayout.EndHorizontal( );

                    GUILayout.BeginHorizontal( );
                    GUILayout.Box("PWM max", GUILayout.Width(96));
                    pwmEnd = ( int )GUILayout.HorizontalSlider(pwmEnd, 0, 100);
                    GUILayout.Box(pwmEnd.ToString( ), GUILayout.Width(32));
                    GUILayout.EndHorizontal( );

                    GUILayout.BeginHorizontal( );
                    GUILayout.Box("PWM spd", GUILayout.Width(96));
                    pwmSpeed = ( int )GUILayout.HorizontalSlider(pwmSpeed, 0, Instruments.InstrumentInstance.PWMSPEED_MAX - 1);
                    GUILayout.Box(pwmSpeed.ToString( ), GUILayout.Width(32));
                    GUILayout.EndHorizontal( );

                    if (pwmStart != instrument.pulseWidthMin ||
                        pwmEnd != instrument.pulseWidthMax ||
                        pwmSpeed != instrument.pulseWidthPanSpeed)
                    {
                        Instruments.InstrumentInstance ins = instrument;
                        ins.pulseWidthMin      = pwmStart;
                        ins.pulseWidthMax      = pwmEnd;
                        ins.pulseWidthPanSpeed = pwmSpeed;
                        instruments.presets [keyboard.currentInstrument] = ins;
                        FileManagement.fileModified = true;
                    }
                    break;

                case Instruments.InstrumentInstance.Wave.Sample:
                    if (GUILayout.Button("Load sample"))
                    {
                        Instruments.InstrumentInstance ins = instrument;
                        if (fileMan.LoadSample(ref ins.waveTable, ref ins.waveTableSampleRate))
                        {
                            instruments.presets [keyboard.currentInstrument] = ins;
                            FileManagement.fileModified = true;
                        }
                    }

                    if (instrument.waveTable != null && instrument.waveTable.Length > 0)
                    {
                        bool loopSamp = instrument.loopSample;

                        GUILayout.BeginHorizontal( );
                        GUILayout.Box(instrument.waveTable.Length + " samples (" + instrument.waveTableSampleRate + "Hz)");
                        loopSamp = GUILayout.Toggle(loopSamp, "Loop");
                        GUILayout.EndHorizontal( );

                        GUILayout.BeginHorizontal( );

                        int relNote = instrument.sampleRelNote;

                        if (GUILayout.Button("--"))
                        {
                            relNote -= 12;
                        }
                        if (GUILayout.Button("-"))
                        {
                            relNote--;
                        }

                        VirtualKeyboard.Note currNote = (VirtualKeyboard.Note)(relNote % 12 + 1);
                        GUILayout.Box(currNote.ToString().Replace('s', '#') + (relNote / 12).ToString());

                        if (GUILayout.Button("+"))
                        {
                            relNote++;
                        }
                        if (GUILayout.Button("++"))
                        {
                            relNote += 12;
                        }

                        if (instrument.sampleRelNote != relNote || loopSamp)
                        {
                            Instruments.InstrumentInstance ins = instrument;
                            ins.sampleRelNote = relNote;
                            ins.loopSample    = loopSamp;

                            instruments.presets[keyboard.currentInstrument] = ins;
                            FileManagement.fileModified = true;
                        }
                        //GUILayout.Toggle()
                        GUILayout.EndHorizontal( );
                    }

                    break;
                }
            }
            break;
        }

        GUILayout.EndVertical( );

        GUILayout.EndHorizontal( );
        GUILayout.EndArea( );
    }
示例#13
0
        public void Draw()
        {
            if (!mShowOverlay)
            {
                return;
            }
            GUI.depth = 0;
            GUI.skin  = HighLogic.Skin;

            // Draw Satellite Selector
            if (mEnabled && mSatelliteFragment.Satellite != null)
            {
                GUILayout.BeginArea(PositionSatellite, AbstractWindow.Frame);
                {
                    mSatelliteFragment.Draw();
                }
                GUILayout.EndArea();
            }

            // Hide the targetInfoWindow if we don't have a selected antenna
            if (mAntennaFragment.Antenna == null)
            {
                mTargetInfos.Hide();
            }

            // Draw Antenna Selector
            mAntennaFragment.triggerMouseOverListEntry = PositionAntenna.Contains(Event.current.mousePosition) && mEnabled;

            if (mEnabled && mSatelliteFragment.Satellite != null && mAntennaFragment.Antenna != null)
            {
                GUILayout.BeginArea(PositionAntenna, AbstractWindow.Frame);
                {
                    mAntennaFragment.Draw();
                }
                GUILayout.EndArea();
            }


            // Switch the background from map view to tracking station
            Texture2D backgroundImage = mTextures.Background;

            if (this.onTrackingStation)
            {
                backgroundImage = mTextures.BackgroundLeft;
            }


            // TODO: Fix textures
            // Draw Toolbar
            GUI.DrawTexture(Position, backgroundImage);
            GUILayout.BeginArea(Position);
            {
                GUILayout.BeginHorizontal();
                {
                    if (this.onTrackingStation)
                    {
                        if (GUILayout.Button("", StyleStatusButton, GUILayout.Width(mTextures.SatButton.width * GameSettings.UI_SCALE), GUILayout.Height(mTextures.SatButton.height * GameSettings.UI_SCALE)))
                        {
                            OnClickStatus();
                        }
                        if (GUILayout.Button(TextureTypeButton, Button, GUILayout.Width(mTextures.OmniDish.width * GameSettings.UI_SCALE), GUILayout.Height(mTextures.OmniDish.height * GameSettings.UI_SCALE)))
                        {
                            OnClickType();
                        }
                        if (GUILayout.Button(TextureReachButton, Button, GUILayout.Width(mTextures.Cone.width * GameSettings.UI_SCALE), GUILayout.Height(mTextures.Cone.height * GameSettings.UI_SCALE)))
                        {
                            OnClickReach();
                        }
                        if (GUILayout.Button(TextureComButton, Button, GUILayout.Width(mTextures.Path.width * GameSettings.UI_SCALE), GUILayout.Height(mTextures.Path.height * GameSettings.UI_SCALE)))
                        {
                            OnClickCompath();
                        }
                    }
                    else
                    {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button(TextureComButton, Button, GUILayout.Width(mTextures.Path.width * GameSettings.UI_SCALE), GUILayout.Height(mTextures.Path.height * GameSettings.UI_SCALE)))
                        {
                            OnClickCompath();
                        }
                        if (GUILayout.Button(TextureReachButton, Button, GUILayout.Width(mTextures.Cone.width * GameSettings.UI_SCALE), GUILayout.Height(mTextures.Cone.height * GameSettings.UI_SCALE)))
                        {
                            OnClickReach();
                        }
                        if (GUILayout.Button(TextureTypeButton, Button, GUILayout.Width(mTextures.OmniDish.width * GameSettings.UI_SCALE), GUILayout.Height(mTextures.OmniDish.height * GameSettings.UI_SCALE)))
                        {
                            OnClickType();
                        }
                        if (GUILayout.Button("", StyleStatusButton, GUILayout.Width(mTextures.SatButton.width * GameSettings.UI_SCALE), GUILayout.Height(mTextures.SatButton.height * GameSettings.UI_SCALE)))
                        {
                            OnClickStatus();
                        }
                    }
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndArea();
        }
示例#14
0
    void OnGUI()
    {
        if (!Application.isPlaying)
        {
            Start();
        }

        if (!ShowOptionsOnGUI)
        {
            return;
        }

        GUILayout.BeginArea(new Rect(10, 10, 200, 768));

        if (GUILayout.Button("Hard Edges"))
        {
            Filter = _2DFilter.HardEdges;
            Start();
        }
        else if (GUILayout.Button("Soft Edges"))
        {
            Filter           = _2DFilter.SoftEdges;
            outputResolution = OutputResolition.Internal2X;
            Start();
        }
        else if (GUILayout.Button("Interpolated"))
        {
            Filter = _2DFilter.Interpolated;
            Start();
        }
        else if (GUILayout.Button("Bicubic"))
        {
            Filter           = _2DFilter.Bicubic;
            outputResolution = OutputResolition.ScreenResolution;
            Start();
        }
        else if (GUILayout.Button("DDT"))
        {
            Filter           = _2DFilter.DDT;
            outputResolution = OutputResolition.ScreenResolution;
            Start();
        }

        else if (GUILayout.Button("2XSal"))
        {
            Filter           = _2DFilter._2XSal;
            outputResolution = OutputResolition.Internal2X;
            Start();
        }
        else if (GUILayout.Button("2XSal Level 2"))
        {
            Filter           = _2DFilter._2XSalLevel2;
            outputResolution = OutputResolition.Internal2X;
            Start();
        }
        else if (GUILayout.Button("XBR Level 2 Fast"))
        {
            Filter           = _2DFilter.XBRLevel2Fast;
            outputResolution = OutputResolition.ScreenResolution;
            Start();
        }
        else if (GUILayout.Button("XBR Level 2 No Blend"))
        {
            Filter           = _2DFilter.XBRLevel2NoBlend;
            outputResolution = OutputResolition.ScreenResolution;
            Start();
        }
        else if (GUILayout.Button("XBR Level 2 Small Details"))
        {
            Filter           = _2DFilter.XBRLevel2SmallDetails;
            outputResolution = OutputResolition.ScreenResolution;
            Start();
        }
        else if (GUILayout.Button("XBR Level 3"))
        {
            Filter           = _2DFilter.XBRLevel3;
            outputResolution = OutputResolition.ScreenResolution;
            Start();
        }
        else if (GUILayout.Button("2XBRZ"))
        {
            Filter           = _2DFilter._2XBRZ;
            outputResolution = OutputResolition.Internal2X;
            Start();
        }
        else if (GUILayout.Button("3XBRZ"))
        {
            Filter           = _2DFilter._3XBRZ;
            outputResolution = OutputResolition.Internal3X;
            Start();
        }
        else if (GUILayout.Button("4XBRZ"))
        {
            Filter           = _2DFilter._4XBRZ;
            outputResolution = OutputResolition.Internal4X;
            Start();
        }
        else if (GUILayout.Button("5XBRZ"))
        {
            Filter           = _2DFilter._5XBRZ;
            outputResolution = OutputResolition.Internal5X;
            Start();
        }
        else if (GUILayout.Button("6XBRZ"))
        {
            Filter           = _2DFilter._6XBRZ;
            outputResolution = OutputResolition.Internal6X;
            Start();
        }
        else if (GUILayout.Button("CRT Aperture"))
        {
            Filter           = _2DFilter.CRTAperture;
            outputResolution = OutputResolition.ScreenResolution;
            Start();
        }
        else if (GUILayout.Button("CRT Caligari"))
        {
            Filter           = _2DFilter.CRTCaligari;
            outputResolution = OutputResolition.ScreenResolution;
            Start();
        }
        else if (GUILayout.Button("CRT Hyllian"))
        {
            Filter           = _2DFilter.CRTHyllian;
            outputResolution = OutputResolition.ScreenResolution;
            Start();
        }
        GUILayout.Space(10);
        if (GUILayout.Button("Output Screen Resolution"))
        {
            outputResolution = OutputResolition.ScreenResolution;
            Start();
        }
        if (GUILayout.Button("Output Internal 1x Resolution"))
        {
            outputResolution = OutputResolition.Internal1X;
            Start();
        }
        if (GUILayout.Button("Output Internal 2x Resolution"))
        {
            outputResolution = OutputResolition.Internal2X;
            Start();
        }
        if (GUILayout.Button("Output Internal 3x Resolution"))
        {
            outputResolution = OutputResolition.Internal3X;
            Start();
        }
        if (GUILayout.Button("Output Internal 4x Resolution"))
        {
            outputResolution = OutputResolition.Internal4X;
            Start();
        }
        if (GUILayout.Button("Output Internal 5x Resolution"))
        {
            outputResolution = OutputResolition.Internal5X;
            Start();
        }
        if (GUILayout.Button("Output Internal 6x Resolution"))
        {
            outputResolution = OutputResolition.Internal6X;
            Start();
        }

        GUILayout.Label("Output resolution: " + (InternalResolution * passes));
        GUILayout.EndArea();
    }
示例#15
0
    private static void OnSceneGUI(SceneView sceneView)
    {
        if (!Application.isPlaying)
        {
            customSkin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene);

            Handles.BeginGUI();

            GUILayout.BeginArea(new Rect(10, 10, 100, 100));

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            GUILayout.Label("GRIDVIEW", customSkin.label);

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            EditorGUI.BeginChangeCheck();

            if (!isEnabled && GUILayout.Button("ON", customSkin.button))
            {
                isEnabled = true;
            }

            if (isEnabled && GUILayout.Button("OFF", customSkin.button))
            {
                isEnabled = false;
            }

            if (EditorGUI.EndChangeCheck())
            {
                //Caso haja alguma alteração, irá ser salva automaticamente.
                EditorPrefs.SetBool("grid_Enabled", isEnabled);
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.EndArea();
            Handles.EndGUI();

            if (isEnabled)
            {
                //Para que o grid não fique transparente em cima de uma objeto.
                Handles.zTest = UnityEngine.Rendering.CompareFunction.LessEqual;

                for (int i1 = 0; i1 < rooms; i1++)
                {
                    for (int i2 = 0; i2 < floors; i2++) //A quantidade maxima de andares é de 8.
                    {
                        gridPositionY = gridSpacingY * i2;

                        Vector3 lowerLeftStartPoint = GetLowerLeftDrawPoint(blocksWide, blocksHigh, i1);

                        float lineLenght = blocksWide * gridSpacingX;

                        for (int xLine = 0; xLine <= blocksHigh; xLine++)
                        {
                            Vector3 vFrom = lowerLeftStartPoint + new Vector3(0f, 0f, (xLine * gridSpacingZ));
                            Vector3 vTo   = vFrom + new Vector3(lineLenght, 0f, 0f);
                            Handles.DrawLine(vFrom, vTo);
                        }

                        lineLenght = blocksHigh * gridSpacingZ;

                        for (int yLine = 0; yLine <= blocksWide; yLine++)
                        {
                            Vector3 hFrom = lowerLeftStartPoint + new Vector3((yLine * gridSpacingX), 0f, 0f);
                            Vector3 hTo   = hFrom + new Vector3(0f, 0f, lineLenght);
                            Handles.DrawLine(hFrom, hTo);
                        }
                    }
                }
            }
        }
    }
示例#16
0
    // Updates progress bar.
    void OnGUI()
    {
        if (_active != this)
        {
            return;
        }

        // Optionally create an overlay for our progress bar to use, separate from the loading screen.
        if (progressBarEmpty != null && progressBarFull != null)
        {
            if (progressBarOverlayHandle == OpenVR.k_ulOverlayHandleInvalid)
            {
                progressBarOverlayHandle = GetOverlayHandle("progressBar", progressBarTransform != null ? progressBarTransform : transform, progressBarWidthInMeters);
            }

            if (progressBarOverlayHandle != OpenVR.k_ulOverlayHandleInvalid)
            {
                var progress = (async != null) ? async.progress : 0.0f;

                // Use the full bar size for everything.
                var w = progressBarFull.width;
                var h = progressBarFull.height;

                // Create a separate render texture so we can composite the full image on top of the empty one.
                if (renderTexture == null)
                {
                    renderTexture = new RenderTexture(w, h, 0);
                    renderTexture.Create();
                }

                var prevActive = RenderTexture.active;
                RenderTexture.active = renderTexture;

                if (Event.current.type == EventType.Repaint)
                {
                    GL.Clear(false, true, Color.clear);
                }

                GUILayout.BeginArea(new Rect(0, 0, w, h));

                GUI.DrawTexture(new Rect(0, 0, w, h), progressBarEmpty);

                // Reveal the full bar texture based on progress.
                GUI.DrawTextureWithTexCoords(new Rect(0, 0, progress * w, h), progressBarFull, new Rect(0.0f, 0.0f, progress, 1.0f));

                GUILayout.EndArea();

                RenderTexture.active = prevActive;

                // Texture needs to be set every frame after it is updated since SteamVR makes a copy internally to a shared texture.
                var overlay = OpenVR.Overlay;
                if (overlay != null)
                {
                    var texture = new Texture_t();
                    texture.handle      = renderTexture.GetNativeTexturePtr();
                    texture.eType       = SteamVR.instance.textureType;
                    texture.eColorSpace = EColorSpace.Auto;
                    overlay.SetOverlayTexture(progressBarOverlayHandle, ref texture);
                }
            }
        }

                #if false
        // Draw loading screen and progress bar to 2d companion window as well.
        if (loadingScreen != null)
        {
            var screenAspect  = (float)Screen.width / Screen.height;
            var textureAspect = (float)loadingScreen.width / loadingScreen.height;

            float w, h;
            if (screenAspect < textureAspect)
            {
                // Clamp horizontally
                w = Screen.width * 0.9f;
                h = w / textureAspect;
            }
            else
            {
                // Clamp vertically
                h = Screen.height * 0.9f;
                w = h * textureAspect;
            }

            GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));

            var x = Screen.width / 2 - w / 2;
            var y = Screen.height / 2 - h / 2;
            GUI.DrawTexture(new Rect(x, y, w, h), loadingScreen);

            GUILayout.EndArea();
        }

        if (renderTexture != null)
        {
            var x = Screen.width / 2 - renderTexture.width / 2;
            var y = Screen.height * 0.9f - renderTexture.height;
            GUI.DrawTexture(new Rect(x, y, renderTexture.width, renderTexture.height), renderTexture);
        }
                #endif
    }
示例#17
0
    public void OnGUI()
    {
        GUILayout.BeginArea(
            m_screenRect,
            m_name,
            GUI.skin.window
            );
        GUILayout.BeginHorizontal();
        for (int parentIndex = 0; parentIndex < m_currentDirectoryParts.Length; ++parentIndex)
        {
            if (parentIndex == m_currentDirectoryParts.Length - 1)
            {
                GUILayout.Label(m_currentDirectoryParts[parentIndex], CentredText);
            }
            else if (GUILayout.Button(m_currentDirectoryParts[parentIndex]))
            {
                string parentDirectoryName = m_currentDirectory;
                for (int i = m_currentDirectoryParts.Length - 1; i > parentIndex; --i)
                {
                    parentDirectoryName = Path.GetDirectoryName(parentDirectoryName);
                }
                SetNewDirectory(parentDirectoryName);
            }
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        m_scrollPosition = GUILayout.BeginScrollView(
            m_scrollPosition,
            false,
            true,
            GUI.skin.horizontalScrollbar,
            GUI.skin.verticalScrollbar,
            GUI.skin.box
            );
        m_selectedDirectory = GUILayoutx.SelectionList(
            m_selectedDirectory,
            m_directoriesWithImages,
            DirectoryDoubleClickCallback
            );
        if (m_selectedDirectory > -1)
        {
            m_selectedFile = m_selectedNonMatchingDirectory = -1;
        }
        m_selectedNonMatchingDirectory = GUILayoutx.SelectionList(
            m_selectedNonMatchingDirectory,
            m_nonMatchingDirectoriesWithImages,
            NonMatchingDirectoryDoubleClickCallback
            );
        if (m_selectedNonMatchingDirectory > -1)
        {
            m_selectedDirectory = m_selectedFile = -1;
        }
        GUI.enabled    = BrowserType == FileBrowserType.File;
        m_selectedFile = GUILayoutx.SelectionList(
            m_selectedFile,
            m_filesWithImages,
            FileDoubleClickCallback
            );
        GUI.enabled = true;
        if (m_selectedFile > -1)
        {
            m_selectedDirectory = m_selectedNonMatchingDirectory = -1;
        }
        GUI.enabled = false;
        GUILayoutx.SelectionList(
            -1,
            m_nonMatchingFilesWithImages
            );
        GUI.enabled = true;
        GUILayout.EndScrollView();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Cancel", GUILayout.Width(50)))
        {
            m_callback(null);
        }
        if (BrowserType == FileBrowserType.File)
        {
            GUI.enabled = m_selectedFile > -1;
        }
        else
        {
            if (SelectionPattern == null)
            {
                GUI.enabled = m_selectedDirectory > -1;
            }
            else
            {
                GUI.enabled = m_selectedDirectory > -1 ||
                              (
                    m_currentDirectoryMatches &&
                    m_selectedNonMatchingDirectory == -1 &&
                    m_selectedFile == -1
                              );
            }
        }
        if (GUILayout.Button("Select", GUILayout.Width(50)))
        {
            if (BrowserType == FileBrowserType.File)
            {
                m_callback(Path.Combine(m_currentDirectory, m_files[m_selectedFile]));
            }
            else
            {
                if (m_selectedDirectory > -1)
                {
                    m_callback(Path.Combine(m_currentDirectory, m_directories[m_selectedDirectory]));
                }
                else
                {
                    m_callback(m_currentDirectory);
                }
            }
        }
        GUI.enabled = true;
        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        if (Event.current.type == EventType.Repaint)
        {
            SwitchDirectoryNow();
        }
    }
        public void OnGUI()
        {
            if (m_areaStyle == null)
            {
                m_areaStyle = new GUIStyle(UIUtils.TextArea);
                m_areaStyle.stretchHeight = true;
                m_areaStyle.stretchWidth  = true;
                m_areaStyle.fontSize      = (int)Constants.DefaultTitleFontSize;
            }

            if (m_buttonStyle == null)
            {
                m_buttonStyle = UIUtils.Button;
            }

            if (m_labelStyle == null)
            {
                m_labelStyle           = new GUIStyle(UIUtils.Label);
                m_labelStyle.alignment = TextAnchor.MiddleCenter;
                m_labelStyle.wordWrap  = true;
            }

            m_area.x = (int)(0.5f * UIUtils.CurrentWindow.CameraInfo.width);
            m_area.y = (int)(0.5f * UIUtils.CurrentWindow.CameraInfo.height);

            GUILayout.BeginArea(m_area, m_content, m_areaStyle);
            {
                EditorGUILayout.BeginVertical();
                {
                    EditorGUILayout.Separator();
                    EditorGUILayout.LabelField(m_currentMessage, m_labelStyle);

                    EditorGUILayout.Separator();
                    EditorGUILayout.Separator();
                    EditorGUILayout.BeginHorizontal();
                    {
                        if (GUILayout.Button(m_yesStr, m_buttonStyle))
                        {
                            if (OnConfirmationSelectedEvt != null)
                            {
                                OnConfirmationSelectedEvt(true, m_shader, m_material);
                            }

                            if (m_autoDeactivate)
                            {
                                Deactivate();
                            }
                        }

                        if (GUILayout.Button(m_noStr, m_buttonStyle))
                        {
                            if (OnConfirmationSelectedEvt != null)
                            {
                                OnConfirmationSelectedEvt(false, m_shader, m_material);
                            }
                            if (m_autoDeactivate)
                            {
                                Deactivate();
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.EndVertical();
            }
            GUILayout.EndArea();
        }
示例#19
0
 public static ILayoutGUI BeginArea(this ILayoutGUI self, Rect rect)
 {
     GUILayout.BeginArea(rect);
     return(self);
 }
示例#20
0
        static void OnSceneGUI(SceneView sceneView)
        {
            // Hotkey select active camera
            if (Event.current.shift && Event.current.keyCode == KeyCode.C && Event.current.type == EventType.keyDown)
            {
                SelectCameraTool();
                Event.current.Use();
                return;
            }

            // Display GUI notifications
            if (camTool && camTool.enabled && !camTool.QuietMode)
            {
                if (F3DCameraTool.Enabled)
                {
                    Handles.BeginGUI();

                    GUI.contentColor = Color.yellow;
                    GUILayout.BeginArea(new Rect(10, 10, 300, 100));

                    if (!camTool.PrimaryCamera)
                    {
                        GUILayout.Label("[CameraTool] Please set the primary camera first!");
                    }
                    else if (!camTool.SetPrimaryCameraPosition && !camTool.SetPrimaryCameraRotation && !camTool.SetSecondaryCameraPosition && !camTool.SetSecondaryCameraRotation)
                    {
                        GUILayout.Label("[CameraTool] Please set the options first!");
                    }
                    else
                    {
                        GUILayout.Label("[CameraTool]");
                    }

                    GUILayout.EndArea();
                    Handles.EndGUI();
                }
            }

            // Check for KeyCode.None as it acts as anykey
            if (camTool && camTool.ToggleKey != KeyCode.None && !Event.current.shift)
            {
                if (Event.current.keyCode == camTool.ToggleKey && Event.current.type == EventType.keyDown)
                {
                    F3DCameraTool.Enabled = !F3DCameraTool.Enabled;

                    if (F3DCameraTool.Enabled)
                    {
                        camTool.OnBecameActive();
                    }
                    else
                    {
                        camTool.OnBecameInactive();
                    }

                    if (camToolEditor != null)
                    {
                        camToolEditor.Repaint();
                    }

                    Event.current.Use();

                    // Repaint gameview to update GUI text in case the inspector is not visible
                    Assembly     assembly = typeof(UnityEditor.EditorWindow).Assembly;
                    Type         type     = assembly.GetType("UnityEditor.GameView");
                    EditorWindow gameview = EditorWindow.GetWindow(type);
                    if (gameview)
                    {
                        gameview.Focus();
                    }
                }
            }
        }
示例#21
0
 public static ILayoutGUI BeginArea(this ILayoutGUI self, Rect rect, Texture image, GUIStyle style)
 {
     GUILayout.BeginArea(rect, image, style);
     return(self);
 }
示例#22
0
文件: VRView.cs 项目: qipa/EditorVR
        void OnGUI()
        {
            if (beforeOnGUI != null)
            {
                beforeOnGUI(this);
            }

            var rect = guiRect;

            rect.x      = 0;
            rect.y      = 0;
            rect.width  = position.width;
            rect.height = position.height;
            guiRect     = rect;
            var cameraRect = EditorGUIUtility.PointsToPixels(guiRect);

            PrepareCameraTargetTexture(cameraRect);

            m_Camera.cullingMask = m_CullingMask.HasValue ? m_CullingMask.Value.value : UnityEditor.Tools.visibleLayers;

            DoDrawCamera(guiRect);

            Event e = Event.current;

            if (m_ShowDeviceView)
            {
                if (e.type == EventType.Repaint)
                {
                    GL.sRGBWrite = (QualitySettings.activeColorSpace == ColorSpace.Linear);
                    var renderTexture = customPreviewCamera && customPreviewCamera.targetTexture ? customPreviewCamera.targetTexture : m_TargetTexture;
                    GUI.BeginGroup(guiRect);
                    GUI.DrawTexture(guiRect, renderTexture, ScaleMode.StretchToFill, false);
                    GUI.EndGroup();
                    GL.sRGBWrite = false;
                }
            }

            GUILayout.BeginArea(guiRect);
            {
                if (GUILayout.Button("Toggle Device View", EditorStyles.toolbarButton))
                {
                    m_ShowDeviceView = !m_ShowDeviceView;
                }

                if (m_CustomPreviewCamera)
                {
                    GUILayout.FlexibleSpace();
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();
                        m_UseCustomPreviewCamera = GUILayout.Toggle(m_UseCustomPreviewCamera, "Use Presentation Camera");
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndArea();

            if (afterOnGUI != null)
            {
                afterOnGUI(this);
            }
        }
示例#23
0
        public FadeArea BeginFadeArea(bool open, string id, float minHeight, GUIStyle areaStyle)
        {
            if (editor == null)
            {
                Debug.LogError("You need to set the 'EditorGUIx.editor' variable before calling this function");
                return(null);
            }

            if (stretchStyle == null)
            {
                stretchStyle = new GUIStyle();
                stretchStyle.stretchWidth = true;
                //stretchStyle.padding = new RectOffset (0,0,4,14);
                //stretchStyle.margin = new RectOffset (0,0,4,4);
            }

            if (stack == null)
            {
                stack = new Stack <FadeArea>();
            }

            if (fadeAreas == null)
            {
                fadeAreas = new Dictionary <string, FadeArea> ();
            }

            if (!fadeAreas.ContainsKey(id))
            {
                fadeAreas.Add(id, new FadeArea(open));
            }

            FadeArea fadeArea = fadeAreas[id];

            stack.Push(fadeArea);

            fadeArea.open = open;

            //Make sure the area fills the full width
            areaStyle.stretchWidth = true;

            Rect lastRect = fadeArea.lastRect;

            if (!fancyEffects)
            {
                fadeArea.value   = open ? 1F : 0F;
                lastRect.height -= minHeight;
                lastRect.height  = open ? lastRect.height : 0;
                lastRect.height += minHeight;
            }
            else
            {
                //GUILayout.Label (lastRect.ToString ()+"\n"+fadeArea.tmp.ToString (),EditorStyles.miniLabel);
                lastRect.height  = lastRect.height < minHeight ? minHeight : lastRect.height;
                lastRect.height -= minHeight;
                float faded = Hermite(0F, 1F, fadeArea.value);
                lastRect.height *= faded;
                lastRect.height += minHeight;
                lastRect.height  = Mathf.Round(lastRect.height);
                //lastRect.height *= 2;
                //if (Event.current.type == EventType.Repaint) {
                //	isLayout = false;
                //}
            }

            Rect gotLastRect = GUILayoutUtility.GetRect(new GUIContent(), areaStyle, GUILayout.Height(lastRect.height));

            //The clipping area, also drawing background
            GUILayout.BeginArea(lastRect, areaStyle);

            Rect newRect = EditorGUILayout.BeginVertical();

            if (Event.current.type == EventType.Repaint || Event.current.type == EventType.ScrollWheel)
            {
                newRect.x            = gotLastRect.x;
                newRect.y            = gotLastRect.y;
                newRect.width        = gotLastRect.width;         //stretchWidthRect.width;
                newRect.height      += areaStyle.padding.top + areaStyle.padding.bottom;
                fadeArea.currentRect = newRect;

                if (fadeArea.lastRect != newRect)
                {
                    //@Fix - duplicate
                    //fadeArea.lastUpdate = Time.realtimeSinceStartup;
                    editor.Repaint();
                }

                fadeArea.Switch();
            }
            if (Event.current.type == EventType.Repaint)
            {
                float value       = fadeArea.value;
                float targetValue = open ? 1F : 0F;

                float newRectHeight = fadeArea.lastRect.height;
                float deltaHeight   = 400F / newRectHeight;

                float deltaTime = Mathf.Clamp(Time.realtimeSinceStartup - fadeAreas[id].lastUpdate, 0.00001F, 0.05F);

                deltaTime *= Mathf.Lerp(deltaHeight * deltaHeight * 0.01F, 0.8F, 0.9F);

                fadeAreas[id].lastUpdate = Time.realtimeSinceStartup;

                //Useless, but fun feature
                if (Event.current.shift)
                {
                    deltaTime *= 0.05F;
                }

                if (Mathf.Abs(targetValue - value) > 0.001F)
                {
                    float time = Mathf.Clamp01(deltaTime * speed);
                    value += time * Mathf.Sign(targetValue - value);
                    editor.Repaint();
                }
                else
                {
                    value = Mathf.Round(value);
                }

                fadeArea.value = Mathf.Clamp01(value);

                //if (oldValue != value) {
                //	editor.Repaint ();
                //}
            }

            if (fade)
            {
                Color c = GUI.color;
                fadeArea.preFadeColor = c;
                c.a      *= fadeArea.value;
                GUI.color = c;
            }

            fadeArea.open = open;

            //GUILayout.Label ("Alpha : "+fadeArea.value);
            //GUILayout.Label ("Alpha : "+fadeArea.value);GUILayout.Label ("Alpha : "+fadeArea.value);GUILayout.Label ("Alpha : "+fadeArea.value);GUILayout.Label ("Alpha : "+fadeArea.value);

            /*GUILayout.Label ("Testing");
            *  GUILayout.Label ("Testing");
            *       GUILayout.Label ("Testing");
            *               GUILayout.Label ("Testing");*/


            return(fadeArea);
        }
示例#24
0
 private void StartBox(float height)
 {
     GUILayout.BeginArea(new Rect(Screen.width - width - 10, (Screen.height - height) / 2f, width, height), GUI.skin.box);
     GUILayout.BeginVertical();
 }
示例#25
0
    public void OnGUI()
    {
        #region Events
        if (EditorWindow.focusedWindow == this)
        {
            Event e = Event.current; // the current event

            switch (e.type)
            {
            //this Event makes it posible todo Copy and Paste
            case EventType.ValidateCommand:

                //Debug.Log("CommandName: " + e.commandName);
                if (e.commandName == "Paste")
                {
                    currentLine.Append(clipboard);     // paste from clipboard
                }
                else if (e.commandName == "Copy")
                {
                    clipboard = currentLine.ToString();     // set new clipboard
                }

                e.Use();     // use the event
                Repaint();
                break;

            case EventType.KeyDown:
                switch (e.keyCode)
                {
                case KeyCode.Backspace:
                    if (currentLine.Length > 0)        // fixes so you cant remove nothing
                    {
                        currentLine = currentLine.Remove(currentLine.Length - 1, 1);
                    }
                    break;

                case KeyCode.Return:

                    if (currentLine.Length == 0)         // dont execute nothing, and/or make a new empty line
                    {
                        return;
                    }

                    previousCommands.Add("> " + currentLine.ToString());
                    CommandDiscovery.Build().Invoke(currentLine.ToString());         // sorry for changing, but i added a function that gets All the Project Assemblies inside this unity project, but if we cant get an Assembly we can manualy add it
                    currentLine = currentLine.Remove(0, currentLine.Length);

                    if (ScrollToBottomOnNewCommand)                                     // scrolls the scrollView to the bottom so we can see what we executed :)
                    {
                        scrollPosition = new Vector2(scrollPosition.x, float.MaxValue); // <- this actualy works :D
                    }
                    break;

                default:
                    currentLine = currentLine.Append(e.character);

                    if (ScrollToBottomOnNewCommand)                                     // scrolls the scrollView to the bottom so we can see what we typed :)
                    {
                        scrollPosition = new Vector2(scrollPosition.x, float.MaxValue); // <- this actualy works :D
                    }
                    break;
                }

                //Debug.Log("Current Keycode: " + Event.current.keyCode.ToString() + " Character: " +
                //          Event.current.character);
                currentLine.Replace("\n", "");
                currentLine.Replace("\0", "");

                e.Use();
                this.Repaint();
                break;

            case EventType.KeyUp:
                e.Use();
                break;
            }
        }
        #endregion

        #region GUILayout
        //GUI.skin = layout; //globaly sets the GUISkin

        #region Mini ToolBar
        //TODO: make the toolbar using the custom GUISkin, instead of default unity
        EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
        if (GUILayout.Button("Clear", EditorStyles.toolbarButton, GUILayout.Width(45f)))
        {
            ClearLog();
        }

        if (GUILayout.Button("Save", EditorStyles.toolbarButton, GUILayout.Width(45f)))
        {
            //save not added atm
        }

        ConsoleLogEnabled = GUILayout.Toggle(ConsoleLogEnabled, "Console Log", EditorStyles.toolbarButton, GUILayout.Width(100f));

        GUILayout.FlexibleSpace();

        EditorGUILayout.EndHorizontal();
        #endregion

        #region ScrollArea
        Rect ContentRect = new Rect(0, 16, position.width, position.height - 16); // 16 + 16 = 32   and 3 from the left.
        GUILayout.BeginArea(ContentRect);

        scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, this.layout.horizontalScrollbar, this.layout.verticalScrollbar, this.layout.scrollView);
        GUILayout.BeginVertical();

        foreach (var previous in previousCommands)
        {
            GUILayout.Label(previous, this.layout.label);
        }

        GUILayout.Label("> " + currentLine.ToString(), this.layout.label);

        GUILayout.EndVertical();
        GUILayout.EndScrollView();
        GUILayout.EndArea();

        #endregion

        #endregion
    }
    void OnGUI()
    {
        float buttonX     = 0;
        float buttonY     = 0;
        float buttonW     = 200;
        float spaceHeight = 30;

        GUILayout.BeginArea(new Rect(buttonX, buttonY, buttonW, Screen.height));
        GUILayout.BeginVertical();

        GUILayout.Space(spaceHeight);

        if (GUILayout.Button("Play Anim", GUILayout.Height(m_debugMenuButtonH)))
        {
            BMLData data = new BMLData();
            StartCoroutine(TestPlayAnimation("ChrBrad@Idle01_ChopBoth01", data));
        }

        if (GUILayout.Button("Play Anim w/Start", GUILayout.Height(m_debugMenuButtonH)))
        {
            BMLData data = new BMLData();
            data.hasStart = true;
            data.start    = 1;
            StartCoroutine(TestPlayAnimation("ChrBrad@Idle01_ChopBoth01", data));
        }

        if (GUILayout.Button("Play Anim w/Stroke", GUILayout.Height(m_debugMenuButtonH)))
        {
            BMLData data = new BMLData();
            data.hasStroke = true;
            data.stroke    = 3;
            StartCoroutine(TestPlayAnimation("ChrBrad@Idle01_ChopBoth01", data));
        }

        if (GUILayout.Button("Play Anim w/End", GUILayout.Height(m_debugMenuButtonH)))
        {
            BMLData data = new BMLData();
            data.hasEnd = true;
            data.end    = 5;
            StartCoroutine(TestPlayAnimation("ChrBrad@Idle01_ChopBoth01", data));
        }

        if (GUILayout.Button("Gaze Camera", GUILayout.Height(m_debugMenuButtonH)))
        {
            StartCoroutine(TestGazeCamera());
        }


        foreach (int i in faceUnits)
        {
            GUILayout.BeginHorizontal();

            GUILayout.Label(string.Format(@"au_{0}:", i), GUILayout.Width(40));

            float newSlider = GUILayout.HorizontalSlider(m_faceSliders[i], 0, 1);
            if (newSlider != m_faceSliders[i])
            {
                m_faceSliders[i] = newSlider;

                string side;
                switch (m_faceBothLeftRight[i])
                {
                case 0: side = "both"; break;

                case 1: side = "left"; break;

                case 2: side = "right"; break;

                default: side = ""; break;
                }

                StartCoroutine(TestSetFaceAnimationImmediate(i, side, m_faceSliders[i]));
            }

            m_faceBothLeftRight[i] = GUILayout.SelectionGrid(m_faceBothLeftRight[i], m_faceBothLeftRightText, 3);

            GUILayout.EndHorizontal();
        }


        GUILayout.Space(spaceHeight);

        if (GUILayout.Button("Reset", GUILayout.Height(m_debugMenuButtonH)))
        {
            StartCoroutine(TestReset());
        }

        GUILayout.EndVertical();
        GUILayout.EndArea();

        string     testStatusLabel = m_testStatusLabel.Replace("@time", string.Format("{0:f2}", Time.time - m_testStatusStartTime));
        TextAnchor origAnchor      = GUI.skin.label.alignment;

        GUI.skin.label.alignment = TextAnchor.UpperCenter;
        Rect rectLabel = new Rect(0.0f, 0.1f, 1.0f, 1.0f);

        GUI.Label(VHGUI.ScaleToRes(ref rectLabel), testStatusLabel);
        GUI.skin.label.alignment = origAnchor;
    }
示例#27
0
    // Play specified level
    // @level: path to level

    /*
     * Will be more polished
     * void startLevelPlay(string levelPath) {
     *  // Load the level
     *
     *
     * }
     */

    void OnGUI()
    {
        /*
         * // TODO: delete these two buttons, exists only to test disabling gui
         * if (controller.showGUI && GUILayout.Button("Hide GUI"))
         * {
         *  controller.showGUI = false;
         * }
         * if(!controller.showGUI && GUILayout.Button("Show GUI"))
         * {
         *  controller.showGUI = true;
         * }
         * // TODO: delete these buttons
         */

        if (controller.showGUI && (!controller.playingGame && !(playObj.GetComponent <playTrack>().getPlay3() || playObj.GetComponent <playTrack>().getPlayLevel())))
        {
            // Create the level Menu
            if (levelMenuToggle)
            {
                int levelMenuWidth  = 200;
                int levelMenuHeight = 300;
                GUILayout.BeginArea(new Rect((Screen.width / 2) - (levelMenuWidth / 2), (Screen.height / 2) - (levelMenuHeight / 2), levelMenuWidth, levelMenuHeight), GUI.skin.box);

                GUILayout.BeginHorizontal("box");
                GUILayout.Label("Level Settings");
                if (GUILayout.Button("X"))
                {
                    levelMenuToggle = false;
                }
                GUILayout.EndHorizontal();

                GUILayout.Label("Level Name");
                levelName = GUILayout.TextField(levelName, maxNameLength);

                GUILayout.Label("Win Conditions");
                dontMove = GUILayout.Toggle(dontMove, "Don't Move");
                // Toggle the others
                if (dontMove)
                {
                    collectKeys = false;
                    goToTarget  = false;
                }

                collectKeys = GUILayout.Toggle(collectKeys, "Collect Keys");
                // Toggle the others
                if (collectKeys)
                {
                    dontMove   = false;
                    goToTarget = false;
                }

                goToTarget = GUILayout.Toggle(goToTarget, "Move to Target");
                // Toggle the others
                if (goToTarget)
                {
                    dontMove    = false;
                    collectKeys = false;
                }

                else if (!dontMove && !collectKeys && !goToTarget)
                {
                    dontMove = true;
                }

                GUILayout.Label("Level Time");
                String fromText    = GUILayout.TextField((controller.timerStart).ToString(), 3);
                float  placeHolder = 0;

                // Check to see if a number before setting
                if (float.TryParse(fromText, out placeHolder))
                {
                    controller.timerStart = float.Parse(fromText);
                }

                else if (fromText == "")
                {
                    controller.timerStart = 0;
                }

                GUILayout.Label("Level Instruction");
                instruction = GUILayout.TextField(instruction, maxInstructionLength);

                if (GUILayout.Button("Reset Settings"))
                {
                    if (settingsChanged())
                    {
                        settingsReset = true;
                    }
                }

                GUILayout.EndArea();
            }
            if (settingsReset)
            {
                GUILayout.BeginArea(new Rect((Screen.width / 2) - (210 / 2), (Screen.height / 2) - (60 / 2), 230, 80), GUI.skin.box);

                GUILayout.Label("Are you sure you would like to reset the settings?");
                GUILayout.BeginHorizontal("box");
                if (GUILayout.Button("Confirm"))
                {
                    resetSettings();
                    settingsReset = false; // hide menu
                }
                if (GUILayout.Button("Cancel"))
                {
                    settingsReset = false; // hide menu
                }
                GUILayout.EndHorizontal();
                GUILayout.EndArea();
            }

            if (objectError)
            {
                GUILayout.BeginArea(new Rect((Screen.width / 2) - (210 / 2), (Screen.height / 2) - (60 / 2), 210, 60), GUI.skin.box);
                GUILayout.Label("ERROR: Object capacity reached");
                if (GUILayout.Button("Close"))
                {
                    objectError = false;
                }
                GUILayout.EndArea();
            }
            if (GUI.Button(new Rect(10, Screen.height - 30, 80, 20), "Add Object"))
            {
                createObject();
            }
            if (GUI.Button(new Rect(100, Screen.height - 30, 120, 20), "Delete All Objects"))
            {
                // open the delete objects confirmation box if there are objects to delete
                if (controller.objectList.Count > 0)
                {
                    deleteObjects = true;
                }
            }
            if (deleteObjects)
            {
                GUILayout.BeginArea(new Rect((Screen.width / 2) - (210 / 2), (Screen.height / 2) - (60 / 2), 230, 80), GUI.skin.box);

                GUILayout.Label("Are you sure you would like to delete all objects?");
                GUILayout.BeginHorizontal("box");
                if (GUILayout.Button("Confirm"))
                {
                    deleteAllObjects();
                    deleteObjects = false; // hide menu
                }
                if (GUILayout.Button("Cancel"))
                {
                    deleteObjects = false; // hide menu
                }
                GUILayout.EndHorizontal();
                GUILayout.EndArea();
            }

            // Button to reset the level
            if (GUI.Button(new Rect(Screen.width - 200, 0, 90, 20), "Reset Level"))
            {
                // if the background or settings properties are changed or are if there are any objects
                if (levelChanged())
                {
                    levelReset = true;
                }
            }
            if (levelReset)
            {
                GUILayout.BeginArea(new Rect((Screen.width / 2) - (210 / 2), (Screen.height / 2) - (60 / 2), 230, 80), GUI.skin.box);

                GUILayout.Label("Are you sure you would like to reset the level?");
                GUILayout.BeginHorizontal("box");
                if (GUILayout.Button("Confirm"))
                {
                    resetLevel();
                    levelReset = false; // hide menu
                }
                if (GUILayout.Button("Cancel"))
                {
                    levelReset = false; // hide menu
                }
                GUILayout.EndHorizontal();
                GUILayout.EndArea();
            }
        }
        if (controller.showGUI && !(playObj.GetComponent <playTrack>().getPlay3() || playObj.GetComponent <playTrack>().getPlayLevel()))
        {
            // Play/Pause Button
            if (GUI.Button(new Rect(Screen.width - 100, 0, 80, 20), buttonSymbol))
            {
                // Change from edit to play
                if (buttonSymbol == "▶")
                {
                    buttonSymbol = "| |";

                    // Make a list of all hostile objects
                    hostileObjects.Clear();
                    foreach (GameObject g in controller.objectList)
                    {
                        if ((g.GetComponentsInChildren <objectProperties>())[0].isHostile)
                        {
                            hostileObjects.Add(g);
                        }
                    }

                    controllableObjects.Clear();
                    foreach (GameObject g in controller.objectList)
                    {
                        if ((g.GetComponentsInChildren <objectProperties>())[0].controllable)
                        {
                            controllableObjects.Add(g);
                        }
                    }

                    saveObjects();

                    // Set game variables
                    keyAmount      = 0;
                    keysSaved      = false;
                    positionsSaved = false;
                    goalLocations.Clear();
                    startingLocation.Clear();
                    keyLocations.Clear();


                    controller.playingGame   = true;
                    Physics2D.autoSimulation = true;

                    // Refresh the background music
                    audioSource = background.GetComponent <AudioSource>();
                    hasSound    = background.GetComponent <changeBackground>().hasSound;

                    if (hasSound)
                    {
                        audioSource.Play();
                    }
                }

                // Change from play to edit
                else if (buttonSymbol == "| |")
                {
                    buttonSymbol             = "▶";
                    controller.playingGame   = false;
                    Physics2D.autoSimulation = false;

                    // reset the position of all objects
                    resetObjects();

                    if (hasSound)
                    {
                        audioSource.Pause();
                    }
                }
            }
        }


        // Play instruction
        if (controller.playingGame && (controller.timerStart - controller.timeLeft < 3) && instruction != "")
        {
            int instrWidth  = instruction.Length * 9;
            int instrHeight = 25;
            var setCentered = GUI.skin.GetStyle("Label");


            GUILayout.BeginArea(new Rect((Screen.width / 2) - (instrWidth / 2), (Screen.height / 2) - (instrHeight / 2), instrWidth, instrHeight), GUI.skin.box);
            GUILayout.Label(instruction);
            GUILayout.EndArea();
        }

        // Create Timer
        if (controller.hasTimer && controller.playingGame)
        {
            GUILayout.BeginArea(new Rect(Screen.width - 100, 25, 80, 20), GUI.skin.box);
            GUILayout.Label((controller.timeLeft).ToString());
            GUILayout.EndArea();
            trackReset = true;
        }

        // Reset Timer
        if (!(controller.hasTimer && controller.playingGame) && trackReset)
        {
            controller.resetTimer();
            trackReset = false;
        }
    }
示例#28
0
    public void OnGUI()
    {
        if (!this.IsVisible || PhotonNetwork.connectionStateDetailed != PeerState.Joined)
        {
            return;
        }

        if (this.Skin != null)
        {
            GUI.skin = this.Skin;
        }

        if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return))
        {
            if (GUI.GetNameOfFocusedControl() == "ChatInput")
            {
                if (!string.IsNullOrEmpty(this.inputLine))
                {
                    this.photonView.RPC("Chat", PhotonTargets.All, this.inputLine);
                }
                this.inputLine = "";
                GUI.FocusControl("");
                return; // printing the now modified list would result in an error. to avoid this, we just skip this single frame
            }
            else
            {
                GUI.FocusControl("ChatInput");
            }
        }

        GUI.SetNextControlName("");
        GUILayout.BeginArea(this.GuiRect);

        scrollPos = GUILayout.BeginScrollView(scrollPos);
        GUILayout.FlexibleSpace();
        for (int i = 0; i < messages.Count; i++)
        {
            GUILayout.Label(messages[i]);
        }
        GUILayout.EndScrollView();

        GUILayout.BeginHorizontal();
        GUI.SetNextControlName("ChatInput");
        inputLine = GUILayout.TextField(inputLine);


        if (UnityEngine.Event.current.type == EventType.Repaint)
        {
            if (GUI.GetNameOfFocusedControl() == "ChatInput")
            {
                if (inputLine == placeholder)
                {
                    inputLine = "";
                }
            }
            else
            {
                if (inputLine == "")
                {
                    inputLine = placeholder;
                }
            }
        }

        // Send button
        //        if (GUILayout.Button("Send", GUILayout.ExpandWidth(false)))
//        {
//            this.photonView.RPC("Chat", PhotonTargets.All, this.inputLine);
//            this.inputLine = "";
//            GUI.FocusControl("");
//        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }
示例#29
0
 private void DrawButtons()
 {
     GUILayout.BeginArea(new Rect(5, 40, position.width - 10, position.height - 40));
     try
     {
         EditorWindowTools.DrawHorizontalLine();
         EditorGUILayout.HelpBox("Welcome to the Dialogue System for Unity!\n\nThe buttons below are shortcuts to commonly-used functions. You can find even more in Tools > Pixel Crushers > Dialogue System.", MessageType.None);
         EditorWindowTools.DrawHorizontalLine();
         GUILayout.Label("Help", EditorStyles.boldLabel);
         GUILayout.BeginHorizontal();
         try
         {
             if (GUILayout.Button(new GUIContent("Quick\nStart\n", "Open Quick Start tutorial"), GUILayout.Width(ButtonWidth)))
             {
                 Application.OpenURL("http://www.pixelcrushers.com/dialogue_system/manual2x/html/quick_start.html");
             }
             if (GUILayout.Button(new GUIContent("\nManual\n", "Open online manual"), GUILayout.Width(ButtonWidth)))
             {
                 Application.OpenURL("http://www.pixelcrushers.com/dialogue_system/manual2x/html/");
             }
             if (GUILayout.Button(new GUIContent("\nVideos\n", "Open video tutorial list"), GUILayout.Width(ButtonWidth)))
             {
                 Application.OpenURL("http://www.pixelcrushers.com/dialogue-system-tutorials/");
             }
             if (GUILayout.Button(new GUIContent("Scripting\nReference\n", "Open scripting & API reference"), GUILayout.Width(ButtonWidth)))
             {
                 Application.OpenURL("http://www.pixelcrushers.com/dialogue_system/manual2x/html/scripting.html");
             }
             if (GUILayout.Button(new GUIContent("\nForum\n", "Go to the Pixel Crushers forum"), GUILayout.Width(ButtonWidth)))
             {
                 Application.OpenURL("http://www.pixelcrushers.com/phpbb");
             }
         }
         finally
         {
             GUILayout.EndHorizontal();
         }
         EditorWindowTools.DrawHorizontalLine();
         GUILayout.Label("Wizards & Resources", EditorStyles.boldLabel);
         GUILayout.BeginHorizontal();
         try
         {
             if (GUILayout.Button(new GUIContent("Dialogue\nEditor\n", "Open the Dialogue Editor window"), GUILayout.Width(ButtonWidth)))
             {
                 PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow.OpenDialogueEditorWindow();
             }
             if (GUILayout.Button(new GUIContent("Dialogue\nManager\nWizard", "Configure a Dialogue Manager, the component that coordinates all Dialogue System activity"), GUILayout.Width(ButtonWidth)))
             {
                 DialogueManagerWizard.Init();
             }
             if (GUILayout.Button(new GUIContent("Player\nSetup\nWizard", "Configure a player GameObject to work with the Dialogue System"), GUILayout.Width(ButtonWidth)))
             {
                 PlayerSetupWizard.Init();
             }
             if (GUILayout.Button(new GUIContent("NPC\nSetup\nWizard", "Configure a non-player character or other interactive GameObject to work with the Dialogue System"), GUILayout.Width(ButtonWidth)))
             {
                 NPCSetupWizard.Init();
             }
             if (GUILayout.Button(new GUIContent("Free\nExtras\n", "Go to the Dialogue System free extras website"), GUILayout.Width(ButtonWidth)))
             {
                 Application.OpenURL("http://www.pixelcrushers.com/dialogue-system-extras/");
             }
         }
         finally
         {
             GUILayout.EndHorizontal();
         }
         EditorWindowTools.DrawHorizontalLine();
     }
     finally
     {
         GUILayout.EndArea();
     }
 }
示例#30
0
        void OnGUI()
        {
            if (!showGUI)
            {
                return;
            }

            GUILayout.BeginArea(new Rect(10 + offsetX, 40 + offsetY, 215, 9999));
            if (!NetworkClient.isConnected && !NetworkServer.active)
            {
                if (!NetworkClient.active)
                {
                    // LAN Host
                    if (Application.platform != RuntimePlatform.WebGLPlayer)
                    {
                        if (GUILayout.Button("LAN Host"))
                        {
                            manager.StartHost();
                        }
                    }

                    // LAN Client + IP
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("LAN Client"))
                    {
                        manager.StartClient();
                    }
                    manager.networkAddress = GUILayout.TextField(manager.networkAddress);
                    GUILayout.EndHorizontal();

                    // LAN Server Only
                    if (Application.platform == RuntimePlatform.WebGLPlayer)
                    {
                        // cant be a server in webgl build
                        GUILayout.Box("(  WebGL cannot be server  )");
                    }
                    else
                    {
                        if (GUILayout.Button("LAN Server Only"))
                        {
                            manager.StartServer();
                        }
                    }
                }
                else
                {
                    // Connecting
                    GUILayout.Label("Connecting to " + manager.networkAddress + "..");
                    if (GUILayout.Button("Cancel Connection Attempt"))
                    {
                        manager.StopClient();
                    }
                }
            }
            else
            {
                // server / client status message
                if (NetworkServer.active)
                {
                    GUILayout.Label("Server: active. Transport: " + Transport.activeTransport);
                }
                if (NetworkClient.isConnected)
                {
                    GUILayout.Label("Client: address=" + manager.networkAddress);
                }
            }

            // client ready
            if (NetworkClient.isConnected && !ClientScene.ready)
            {
                if (GUILayout.Button("Client Ready"))
                {
                    ClientScene.Ready(NetworkClient.connection);

                    if (ClientScene.localPlayer == null)
                    {
                        ClientScene.AddPlayer();
                    }
                }
            }

            // stop
            if (NetworkServer.active || NetworkClient.isConnected)
            {
                if (GUILayout.Button("Stop"))
                {
                    manager.StopHost();
                }
            }

            GUILayout.EndArea();
        }