Ejemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        Actor editActor = target as Actor;

        Actor.ActionSource[] immTypeVal  = Enum.GetValues(typeof(Actor.ActionSource)) as Actor.ActionSource[];
        string[]             immTypeName = Enum.GetNames(typeof(Actor.ActionSource));
        for (int i = 0; i < immTypeName.Length; i++)
        {
            immTypeName[i] += '\t';
        }

        Actor.Position[] posVal  = Enum.GetValues(typeof(Actor.Position)) as Actor.Position[];
        string[]         posName = Enum.GetNames(typeof(Actor.Position));
        for (int i = 0; i < posName.Length; i++)
        {
            posName[i] += '\t';
        }

        immunityList = new SelectionList <Actor.ActionSource>(immTypeVal, immTypeName);
        positionList = new SelectionList <Actor.Position>(posVal, posName);

        #region Name, and HP
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Name");
        actName = GUILayout.TextField(editActor.actorName);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Max Hit Points");
        maxHP = EditorGUILayout.IntSlider(maxHP, 1, 10000);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Current Hit Points");
        currentHP = EditorGUILayout.IntSlider(currentHP, 0, maxHP);
        EditorGUILayout.EndHorizontal();
        #endregion

        #region Position
        editPosition = EditorGUILayout.Foldout(editPosition, "Position");
        if (editPosition)
        {
            boardPos = positionList.RadioList("", boardPos, 2);
        }
        #endregion

        #region Damage
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Damage");
        dmg = EditorGUILayout.IntSlider(dmg, 0, 180);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Effect");
        EditorGUILayout.EnumFlagsField(effect);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Damage Type");
        EditorGUILayout.EnumFlagsField(dmgType);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Attack type");
        EditorGUILayout.EnumFlagsField(targetType);
        EditorGUILayout.EndHorizontal();
        #endregion

        #region Immunities
        editImmunity = EditorGUILayout.Foldout(editImmunity, "Immunities");
        if (editImmunity)
        {
            immunities = immunityList.CheckboxList("Immunities", immunities, 2);
        }
        #endregion

        #region AI
        editAI = EditorGUILayout.Foldout(editAI, "AI Options");
        if (editAI)
        {
            derivedStats = AssetDatabase.LoadAssetAtPath("Assets/DerivedProperties.asset", typeof(DerivedStatList)) as DerivedStatList;
            if (derivedStats == null)
            {
                derivedStats = ScriptableObject.CreateInstance <DerivedStatList>();
                AssetDatabase.CreateAsset(derivedStats, "Assets/DerivedProperties.asset");
                AssetDatabase.SaveAssets();
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Chance to Hit");
            chanceToHit = EditorGUILayout.IntSlider(chanceToHit, 0, 100);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Inititive");
            init  = EditorGUILayout.IntSlider(init, 5, 100);
            init  = init / 5;
            init *= 5;
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("AI Targeting Filters");
            EditorGUILayout.LabelField("Filter order does matter (Ordered top to bottom)");
            EditorGUILayout.Separator();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Name", GUILayout.MaxWidth(80));
            EditorGUILayout.LabelField("Expression");
            EditorGUILayout.EndHorizontal();

            FilterLayout();

            EditorGUILayout.Separator();
            bool added = false;
            if (GUILayout.Button("Add Filter"))
            {
                added = true;
                AddButtonOnClick();
            }

            if (GUI.changed || added)
            {
                EditorUtility.SetDirty(derivedStats);
                serializedObject.ApplyModifiedProperties();
                AssetDatabase.SaveAssets();
            }
        }
        #endregion

        #region Assignment
        editActor.actorName          = actName;
        editActor.boardPosition      = boardPos;
        editActor.maxHitPoints       = maxHP;
        editActor.damage             = dmg;
        editActor.actionEffect       = effect;
        editActor.actionEffectSource = dmgType;
        editActor.immunities         = immunities;
        editActor.actionTarget       = targetType;
        editActor.percentChanceToHit = chanceToHit;
        editActor.initiative         = init;
        editActor.hitPoints          = currentHP;
        #endregion
    }
Ejemplo n.º 2
0
        void DrawStyles()
        {
            GUILayout.Space(14);
            GUILayout.Label("Rendering");

            // Opacity
            DrawNullableRow("opacity", (enabled) =>
            {
                return(EditorGUILayout.Slider("Opacity", CurrentStyle.opacity, 0, 1f));
            });

            // zIndex
            DrawNullableRow("zIndex", (enabled) =>
            {
                return(EditorGUILayout.IntField("Z Index", CurrentStyle.zIndex));
            });

            // Visibility
            DrawNullableRow("visibility", (enabled) =>
            {
                return(EditorGUILayout.Toggle("Visibility", CurrentStyle.visibility));
            });

            // Pointer Events
            DrawNullableRow("pointerEvents", (enabled) =>
            {
                return(EditorGUILayout.EnumPopup("PointerEvents", CurrentStyle.pointerEvents));
            });



            GUILayout.Space(14);

            // Box Shadow
            DrawNullableRow("boxShadow", (enabled) =>
            {
                EditorGUILayout.BeginVertical();
                GUILayout.Label("Box Shadow");

                var tempShadow = CurrentStyle.boxShadow ?? new ShadowDefinition();

                tempShadow.blur   = EditorGUILayout.FloatField("Blur", tempShadow.blur);
                tempShadow.offset = EditorGUILayout.Vector2Field("Offset", tempShadow.offset);
                tempShadow.spread = EditorGUILayout.Vector2Field("Spread", tempShadow.spread);
                tempShadow.color  = EditorGUILayout.ColorField("Color", tempShadow.color);

                EditorGUILayout.EndVertical();

                return(tempShadow);
            });


            GUILayout.Space(14);
            GUILayout.Label("Graphic");


            // Background color
            DrawNullableRow("backgroundColor", (enabled) =>
            {
                return(EditorGUILayout.ColorField("Background color", CurrentStyle.backgroundColor));
            });



            // Border Width
            DrawFloatRowWithNaN(CurrentLayout.BorderWidth, 0, (enabled, appropriateValue) =>
            {
                var prop2 = EditorGUILayout.IntField("Border Width", (int)appropriateValue);
                CurrentLayout.BorderWidth = enabled ? prop2 : float.NaN;
            });

            // Border color
            DrawNullableRow("borderColor", (enabled) =>
            {
                return(EditorGUILayout.ColorField("Border color", CurrentStyle.borderColor));
            });

            // Border radius
            DrawNullableRow("borderRadius", (enabled) =>
            {
                return(EditorGUILayout.IntField("Border radius", CurrentStyle.borderRadius));
            });


            GUILayout.Space(14);
            GUILayout.Label("Font");

            // Font size
            GUILayout.BeginHorizontal();
            GUILayout.Label("Font size", GUILayout.Width(150));
            CurrentStyle.fontSize = DrawYogaValue(CurrentStyle.fontSize);
            GUILayout.EndHorizontal();

            // Font style
            DrawNullableRow("fontStyle", (enabled) =>
            {
                return(EditorGUILayout.EnumFlagsField("Font style", CurrentStyle.fontStyle));
            });

            // Text Overflow
            DrawNullableRow("textOverflow", (enabled) =>
            {
                return(EditorGUILayout.EnumPopup("Text Overflow", CurrentStyle.textOverflow));
            });

            // Text Overflow
            DrawNullableRow("textAlign", (enabled) =>
            {
                return(EditorGUILayout.EnumPopup("Text Align", CurrentStyle.textAlign));
            });

            // Font color
            DrawNullableRow("color", (enabled) =>
            {
                return(EditorGUILayout.ColorField("Font color", CurrentStyle.color));
            });

            // Text wrap
            DrawNullableRow("textWrap", (enabled) =>
            {
                return(EditorGUILayout.Toggle("Text wrap", CurrentStyle.textWrap));
            });

            // Direction
            var prop1 = EditorGUILayout.EnumPopup("Direction", CurrentLayout.StyleDirection);

            CurrentLayout.StyleDirection = (YogaDirection)prop1;



            GUILayout.Space(14);
            GUILayout.Label("Transform");

            //// Translate
            //DrawNullableRow("translate", (enabled) =>
            //{
            //    return EditorGUILayout.Vector2Field("Translate", CurrentStyle.translate);
            //});

            // Pivot
            //DrawNullableRow("pivot", (enabled) =>
            //{
            //    return EditorGUILayout.Vector2Field("Pivot", CurrentStyle.pivot);
            //});

            // Scale
            DrawNullableRow("scale", (enabled) =>
            {
                return(EditorGUILayout.Vector2Field("Scale", CurrentStyle.scale));
            });

            // Rotation
            DrawNullableRow("rotate", (enabled) =>
            {
                return(EditorGUILayout.FloatField("Rotation", CurrentStyle.rotate));
            });
        }
Ejemplo n.º 3
0
    public override void OnInspectorGUI()
    {
        ServerSettings settings = (ServerSettings)target;

        Undo.RecordObject(settings, "Edit PhotonServerSettings");
        settings.HostType     = (ServerSettings.HostingOption)EditorGUILayout.EnumPopup("Hosting", settings.HostType);
        EditorGUI.indentLevel = 1;

        switch (settings.HostType)
        {
        case ServerSettings.HostingOption.BestRegion:
        case ServerSettings.HostingOption.PhotonCloud:
            // region selection
            if (settings.HostType == ServerSettings.HostingOption.PhotonCloud)
            {
                settings.PreferredRegion = (CloudRegionCode)EditorGUILayout.EnumPopup("Region", settings.PreferredRegion);
            }
            else     // Bestregion
            {
                string _regionFeedback = "Prefs:" + ServerSettings.BestRegionCodeInPreferences.ToString();

                // the NameServer does not have a region itself. it's global (although it has regional instances)
                if (PhotonNetwork.connected && PhotonNetwork.Server != ServerConnection.NameServer)
                {
                    _regionFeedback = "Current:" + PhotonNetwork.CloudRegion + " " + _regionFeedback;
                }

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel(" ");
                Rect rect        = GUILayoutUtility.GetRect(new GUIContent(_regionFeedback), "Label");
                int  indentLevel = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;
                EditorGUI.LabelField(rect, _regionFeedback);
                EditorGUI.indentLevel = indentLevel;

                rect.x    += rect.width - 39;
                rect.width = 39;

                rect.height -= 2;
                if (GUI.Button(rect, "Reset", EditorStyles.miniButton))
                {
                    ServerSettings.ResetBestRegionCodeInPreferences();
                }
                EditorGUILayout.EndHorizontal();


                // Dashboard region settings
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("Regions");
                Rect rect2 = GUILayoutUtility.GetRect(new GUIContent("Online WhiteList"), "Label");
                if (!string.IsNullOrEmpty(settings.AppID))
                {
                    int indentLevel2 = EditorGUI.indentLevel;
                    EditorGUI.indentLevel = 0;
                    EditorGUI.LabelField(rect2, "Online WhiteList");
                    EditorGUI.indentLevel = indentLevel2;

                    rect2.x    += rect2.width - 80;
                    rect2.width = 80;

                    rect2.height -= 2;
                    if (GUI.Button(rect2, "Dashboard", EditorStyles.miniButton))
                    {
                        Application.OpenURL("https://www.photonengine.com/en-US/Dashboard/Manage/" + settings.AppID);
                    }
                }
                else
                {
                    GUI.Label(rect2, "n/a");
                }

                EditorGUILayout.EndHorizontal();


                EditorGUI.indentLevel++;
                                #if UNITY_2017_3_OR_NEWER
                CloudRegionFlag valRegions = (CloudRegionFlag)EditorGUILayout.EnumFlagsField(" ", settings.EnabledRegions);
                                #else
                CloudRegionFlag valRegions = (CloudRegionFlag)EditorGUILayout.EnumMaskField(" ", settings.EnabledRegions);
                                #endif

                if (valRegions != settings.EnabledRegions)
                {
                    settings.EnabledRegions = valRegions;
                    this.showMustHaveRegion = valRegions == 0;
                }
                if (this.showMustHaveRegion)
                {
                    EditorGUILayout.HelpBox("You should enable at least two regions for 'Best Region' hosting.", MessageType.Warning);
                }

                EditorGUI.indentLevel--;
            }

            // appid
            string valAppId = EditorGUILayout.TextField("AppId", settings.AppID);
            if (valAppId != settings.AppID)
            {
                settings.AppID = valAppId.Trim();
            }
            if (!ServerSettings.IsAppId(settings.AppID))
            {
                EditorGUILayout.HelpBox("PUN needs an AppId (GUID).\nFind it online in the Dashboard.", MessageType.Warning);
            }

            // protocol
            ConnectionProtocol valProtocol = settings.Protocol;
            valProtocol       = (ConnectionProtocol)EditorGUILayout.EnumPopup("Protocol", valProtocol);
            settings.Protocol = (ConnectionProtocol)valProtocol;
                #if UNITY_WEBGL
            EditorGUILayout.HelpBox("WebGL always use Secure WebSockets as protocol.\nThis setting gets ignored in current export.", MessageType.Warning);
                #endif
            break;

        case ServerSettings.HostingOption.SelfHosted:
            // address and port (depends on protocol below)
            bool hidePort = false;
            if (settings.Protocol == ConnectionProtocol.Udp && (settings.ServerPort == 4530 || settings.ServerPort == 0))
            {
                settings.ServerPort = 5055;
            }
            else if (settings.Protocol == ConnectionProtocol.Tcp && (settings.ServerPort == 5055 || settings.ServerPort == 0))
            {
                settings.ServerPort = 4530;
            }
                #if RHTTP
            if (settings.Protocol == ConnectionProtocol.RHttp)
            {
                settings.ServerPort = 0;
                hidePort            = true;
            }
                #endif
            settings.ServerAddress = EditorGUILayout.TextField("Server Address", settings.ServerAddress);
            settings.ServerAddress = settings.ServerAddress.Trim();
            if (!hidePort)
            {
                settings.ServerPort = EditorGUILayout.IntField("Server Port", settings.ServerPort);
            }
            // protocol
            valProtocol       = settings.Protocol;
            valProtocol       = (ConnectionProtocol)EditorGUILayout.EnumPopup("Protocol", valProtocol);
            settings.Protocol = (ConnectionProtocol)valProtocol;
                #if UNITY_WEBGL
            EditorGUILayout.HelpBox("WebGL always use Secure WebSockets as protocol.\nThis setting gets ignored in current export.", MessageType.Warning);
                #endif

            // appid
            settings.AppID = EditorGUILayout.TextField("AppId", settings.AppID);
            settings.AppID = settings.AppID.Trim();
            break;

        case ServerSettings.HostingOption.OfflineMode:
            EditorGUI.indentLevel = 0;
            EditorGUILayout.HelpBox("In 'Offline Mode', the client does not communicate with a server.\nAll settings are hidden currently.", MessageType.Info);
            break;

        case ServerSettings.HostingOption.NotSet:
            EditorGUI.indentLevel = 0;
            EditorGUILayout.HelpBox("Hosting is 'Not Set'.\nConnectUsingSettings() will not be able to connect.\nSelect another option or run the PUN Wizard.", MessageType.Info);
            break;

        default:
            DrawDefaultInspector();
            break;
        }

        if (PhotonEditor.CheckPunPlus())
        {
            settings.Protocol = ConnectionProtocol.Udp;
            EditorGUILayout.HelpBox("You seem to use PUN+.\nPUN+ only supports reliable UDP so the protocol is locked.", MessageType.Info);
        }



        // CHAT SETTINGS
        if (PhotonEditorUtils.HasChat)
        {
            GUILayout.Space(5);
            EditorGUI.indentLevel = 0;
            EditorGUILayout.LabelField("Photon Chat Settings");
            EditorGUI.indentLevel = 1;
            string valChatAppid = EditorGUILayout.TextField("Chat AppId", settings.ChatAppID);
            if (valChatAppid != settings.ChatAppID)
            {
                settings.ChatAppID = valChatAppid.Trim();
            }
            if (!ServerSettings.IsAppId(settings.ChatAppID))
            {
                EditorGUILayout.HelpBox("Photon Chat needs an AppId (GUID).\nFind it online in the Dashboard.", MessageType.Warning);
            }

            EditorGUI.indentLevel = 0;
        }



        // VOICE SETTINGS
        if (PhotonEditorUtils.HasVoice)
        {
            GUILayout.Space(5);
            EditorGUI.indentLevel = 0;
            EditorGUILayout.LabelField("Photon Voice Settings");
            EditorGUI.indentLevel = 1;
            switch (settings.HostType)
            {
            case ServerSettings.HostingOption.BestRegion:
            case ServerSettings.HostingOption.PhotonCloud:
                // voice appid
                string valVoiceAppId = EditorGUILayout.TextField("Voice AppId", settings.VoiceAppID);
                if (valVoiceAppId != settings.VoiceAppID)
                {
                    settings.VoiceAppID = valVoiceAppId.Trim();
                }
                if (!ServerSettings.IsAppId(settings.VoiceAppID))
                {
                    EditorGUILayout.HelpBox("Photon Voice needs an AppId (GUID).\nFind it online in the Dashboard.", MessageType.Warning);
                }
                break;

            case ServerSettings.HostingOption.SelfHosted:
                if (settings.VoiceServerPort == 0)
                {
                    settings.VoiceServerPort = 5055;
                }
                settings.VoiceServerPort = EditorGUILayout.IntField("Server Port UDP", settings.VoiceServerPort);
                break;

            case ServerSettings.HostingOption.OfflineMode:
            case ServerSettings.HostingOption.NotSet:
                break;
            }
            EditorGUI.indentLevel = 0;
        }



        // PUN Client Settings
        GUILayout.Space(5);
        EditorGUI.indentLevel = 0;
        EditorGUILayout.LabelField("Client Settings");
        EditorGUI.indentLevel = 1;
        //EditorGUILayout.LabelField("game version");
        settings.JoinLobby             = EditorGUILayout.Toggle("Auto-Join Lobby", settings.JoinLobby);
        settings.EnableLobbyStatistics = EditorGUILayout.Toggle("Enable Lobby Stats", settings.EnableLobbyStatistics);

        // Pun Logging Level
        PhotonLogLevel _PunLogging = (PhotonLogLevel)EditorGUILayout.EnumPopup("Pun Logging", settings.PunLogging);
        if (EditorApplication.isPlaying && PhotonNetwork.logLevel != _PunLogging)
        {
            PhotonNetwork.logLevel = _PunLogging;
        }
        settings.PunLogging = _PunLogging;

        // Network Logging Level
        DebugLevel _DebugLevel = (DebugLevel)EditorGUILayout.EnumPopup("Network Logging", settings.NetworkLogging);
        if (EditorApplication.isPlaying && settings.NetworkLogging != _DebugLevel)
        {
            settings.NetworkLogging = _DebugLevel;
        }
        settings.NetworkLogging = _DebugLevel;


        //EditorGUILayout.LabelField("automaticallySyncScene");
        //EditorGUILayout.LabelField("autoCleanUpPlayerObjects");
        //EditorGUILayout.LabelField("lobby stats");
        //EditorGUILayout.LabelField("sendrate / serialize rate");
        //EditorGUILayout.LabelField("quick resends");
        //EditorGUILayout.LabelField("max resends");
        //EditorGUILayout.LabelField("enable crc checking");


        // Application settings
        GUILayout.Space(5);
        EditorGUI.indentLevel = 0;
        EditorGUILayout.LabelField("Build Settings");
        EditorGUI.indentLevel = 1;

        settings.RunInBackground = EditorGUILayout.Toggle("Run In Background", settings.RunInBackground);


        // RPC-shortcut list
        GUILayout.Space(5);
        EditorGUI.indentLevel = 0;
        SerializedObject   sObj  = new SerializedObject(target);
        SerializedProperty sRpcs = sObj.FindProperty("RpcList");
        EditorGUILayout.PropertyField(sRpcs, true);
        sObj.ApplyModifiedProperties();

        GUILayout.BeginHorizontal();
        GUILayout.Space(20);
        if (GUILayout.Button("Refresh RPCs"))
        {
            PhotonEditor.UpdateRpcList();
            Repaint();
        }
        if (GUILayout.Button("Clear RPCs"))
        {
            PhotonEditor.ClearRpcList();
        }
        if (GUILayout.Button("Log HashCode"))
        {
            Debug.Log("RPC-List HashCode: " + RpcListHashCode() + ". Make sure clients that send each other RPCs have the same RPC-List.");
        }
        GUILayout.Space(20);
        GUILayout.EndHorizontal();


        //SerializedProperty sp = serializedObject.FindProperty("RpcList");
        //EditorGUILayout.PropertyField(sp, true);

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);     // even in Unity 5.3+ it's OK to SetDirty() for non-scene objects.
        }
    }
Ejemplo n.º 4
0
    protected override void OnGUI()
    {
        base.OnGUI();

        pos = EditorGUILayout.BeginScrollView(pos);

        if (GUILayout.Button("这是一个按钮"))
        {
            Debug.Log("Click Button");
        }
        EditorGUILayout.LabelField("空格");
        EditorGUILayout.Separator();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("这是一个默认Lable");
        EditorGUILayout.LabelField("这是高300,宽50的Label", GUILayout.Width(300), GUILayout.Height(50));
        EditorGUILayout.LabelField("这是一个拾色器");
        EditorGUILayout.ColorField(Color.white);
        EditorGUILayout.LabelField("Bounds");
        bounds = EditorGUILayout.BoundsField(bounds);
        EditorGUILayout.LabelField("BoundsInt");
        boundsInt = EditorGUILayout.BoundsIntField(boundsInt);
        EditorGUILayout.LabelField("AnimationCurve");
        curve = EditorGUILayout.CurveField(curve);

        EditorGUILayout.LabelField("<color=#ff0000>注意比对延迟设置和直接设置的区别</color>", Style);
        EditorGUILayout.Space();

        toggle     = EditorGUILayout.Toggle("Toggle", toggle);
        toggleLeft = EditorGUILayout.ToggleLeft("ToggleLeft", toggleLeft);

        //double
        EditorGUILayout.LabelField("延迟设置" + delayedDou.ToString());
        delayedDou = EditorGUILayout.DelayedDoubleField("DelayedDouble", delayedDou);
        EditorGUILayout.LabelField("直接设置" + dou.ToString());
        dou        = EditorGUILayout.DoubleField("Double", dou);
        delayedInt = EditorGUILayout.DelayedIntField("DelayedInt", delayedInt);
        //int
        i         = EditorGUILayout.IntField("Int", i);
        sliderInt = EditorGUILayout.IntSlider(sliderInt, 0, 100);

        //text
        delayedText = EditorGUILayout.DelayedTextField("DelayedText", delayedText);
        text        = EditorGUILayout.TextField("Text", text);
        password    = EditorGUILayout.PasswordField("Password", password);
        EditorGUILayout.LabelField("TextArea");
        textArea = EditorGUILayout.TextArea(textArea);
        //float
        delayedFloat = EditorGUILayout.DelayedFloatField("DelayedFloat", delayedFloat);
        f            = EditorGUILayout.FloatField("Float", f);
        fSlider      = EditorGUILayout.Slider("FloatSlider", fSlider, 0, 10);
        fKnob        = EditorGUILayout.Knob(new Vector2(100, 100), fKnob, 0, 10, "Knob", Color.blue, Color.red, true);
        longvalue    = EditorGUILayout.LongField("Long", longvalue);

        //vector
        v2    = EditorGUILayout.Vector2Field("Vector2", v2);
        v2Int = EditorGUILayout.Vector2IntField("Vector2Int", v2Int);

        v3    = EditorGUILayout.Vector3Field("Vector3", v3);
        v3Int = EditorGUILayout.Vector3IntField("Vector3Int", v3Int);

        v4 = EditorGUILayout.Vector4Field("Vector4", v4);

        EditorGUILayout.LabelField("枚举Field");
        m_Flags = (ExampleFlagsEnum)EditorGUILayout.EnumFlagsField(m_Flags);

        EditorGUILayout.LabelField("注意两者的区别");
        m_Flags = (ExampleFlagsEnum)EditorGUILayout.EnumPopup(m_Flags);

        gradient = EditorGUILayout.GradientField("Gradient", gradient);

        go   = (GameObject)EditorGUILayout.ObjectField("GameObject", go, typeof(GameObject), true);
        clip = (AnimationClip)EditorGUILayout.ObjectField("Clip", clip, typeof(AnimationClip), true);

        EditorGUILayout.LabelField("Rect");
        rect = EditorGUILayout.RectField(rect);
        EditorGUILayout.LabelField("RectInt");
        rectInt = EditorGUILayout.RectIntField(rectInt);


        EditorGUILayout.HelpBox("这是一个信息Box", MessageType.Info);
        EditorGUILayout.HelpBox("这是一个警告Box", MessageType.Warning);
        EditorGUILayout.HelpBox("这是一个错误Box", MessageType.Error);

        EditorGUILayout.SelectableLabel("SelectableLabel");


        EditorGUILayout.EndScrollView();
    }
Ejemplo n.º 5
0
        private void DrawSelectNameAndPlatform()
        {
            EditorGUILayout.Space();
            EditorGUILayout.HelpBox("This wizard will help you set up and register a simple extension service. MRTK Services are similar to traditional Monobehaviour singletons but with more robust access and lifecycle control. Scripts can access services through the MRTK's service provider interface. For more information about services, click the link below.", MessageType.Info);

            GUIContent buttonContent = new GUIContent();

            buttonContent.image   = EditorGUIUtility.IconContent("_Help").image;
            buttonContent.text    = " Services Documentation";
            buttonContent.tooltip = servicesDocumentationURL;

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

            if (GUILayout.Button(buttonContent, GUILayout.MaxWidth(docLinkWidth)))
            {
                Application.OpenURL(servicesDocumentationURL);
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Choose a name for your service.", EditorStyles.miniLabel);

            creator.ServiceName = EditorGUILayout.TextField("Service Name", creator.ServiceName);

            bool readyToProgress = creator.ValidateName(errors);

            foreach (string error in errors)
            {
                EditorGUILayout.HelpBox(error, MessageType.Error);
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Choose which platforms your service will support.", EditorStyles.miniLabel);

            creator.Platforms = (SupportedPlatforms)EditorGUILayout.EnumFlagsField("Platforms", creator.Platforms);
            readyToProgress  &= creator.ValidatePlatforms(errors);
            foreach (string error in errors)
            {
                EditorGUILayout.HelpBox(error, MessageType.Error);
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Choose a namespace for your service.", EditorStyles.miniLabel);

            creator.Namespace = EditorGUILayout.TextField("Namespace", creator.Namespace);
            readyToProgress  &= creator.ValidateNamespace(errors);
            foreach (string error in errors)
            {
                EditorGUILayout.HelpBox(error, MessageType.Error);
            }

            EditorGUILayout.Space();

            GUI.color = readyToProgress ? enabledColor : disabledColor;
            if (GUILayout.Button("Next") && readyToProgress)
            {
                creator.Stage = ExtensionServiceCreator.CreationStage.ChooseOutputFolders;
                creator.StoreState();
            }
        }
        void OnGUI()
        {
            // Frame rate tracking
            if (Event.current.type == EventType.Repaint)
            {
                AnimationHelper.UpdateTime();
            }

            GUILayout.Space(9);

            SidekickSettings settings = commonContext.Settings;


            EditorGUI.BeginChangeCheck();
            InspectionConnection newConnectionMode = (InspectionConnection)GUILayout.Toolbar((int)settings.InspectionConnection, new string[] { "Local", "Remote" }, new GUIStyle("LargeButton"));

            if (EditorGUI.EndChangeCheck())
            {
                SetConnectionMode(newConnectionMode);
            }

            settings.SearchTerm = searchField2.OnGUI(settings.SearchTerm);
            GUILayout.Space(3);
            EditorGUI.BeginChangeCheck();
#if UNITY_2017_3_OR_NEWER
            // EnumMaskField became EnumFlagsField in 2017.3
            settings.GetGameObjectFlags = (InfoFlags)EditorGUILayout.EnumFlagsField("Display", settings.GetGameObjectFlags);
#else
            settings.GetGameObjectFlags = (InfoFlags)EditorGUILayout.EnumMaskField("Display", settings.GetGameObjectFlags);
#endif
            if (EditorGUI.EndChangeCheck())
            {
                if (!string.IsNullOrEmpty(commonContext.SelectionManager.SelectedPath)) // Valid path?
                {
                    commonContext.APIManager.SendToPlayers(new GetGameObjectRequest(commonContext.SelectionManager.SelectedPath, commonContext.Settings.GetGameObjectFlags, commonContext.Settings.IncludeInherited));
                }
            }

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

            if (gameObjectResponse != null)
            {
                string activeSearchTerm = settings.SearchTerm;

                foreach (ComponentDescription component in gameObjectResponse.Components)
                {
                    SidekickEditorGUI.DrawSplitter();
                    GUIStyle style = new GUIStyle(EditorStyles.foldout);
                    style.fontStyle = FontStyle.Bold;

                    Texture    icon       = IconLookup.GetIcon(component.TypeFullName);
                    GUIContent content    = new GUIContent(component.TypeShortName, icon, "Object Map ID: " + component.Guid.ToString());
                    float      labelWidth = EditorGUIUtility.labelWidth; // Cache label width
                    // Temporarily set the label width to full width so the icon is not squashed with long strings
                    EditorGUIUtility.labelWidth = position.width / 2f;

                    bool wasComponentExpanded = !settings.CollapsedTypeNames.Contains(component.TypeFullName);
                    bool isComponentExpanded  = wasComponentExpanded;
                    if (SidekickEditorGUI.DrawHeaderWithFoldout(content, isComponentExpanded))
                    {
                        isComponentExpanded = !isComponentExpanded;
                    }
                    EditorGUIUtility.labelWidth = labelWidth; // Restore label width
                    if (isComponentExpanded != wasComponentExpanded)
                    {
                        if (isComponentExpanded == false)
                        {
                            // Not expanded, so collapse it
                            settings.CollapsedTypeNames.Add(component.TypeFullName);
                        }
                        else
                        {
                            // Expanded, remove it from collapse list
                            settings.CollapsedTypeNames.Remove(component.TypeFullName);
                        }
                    }

                    if (isComponentExpanded)
                    {
                        foreach (var field in component.Fields)
                        {
                            if (!string.IsNullOrEmpty(activeSearchTerm) && !field.VariableName.Contains(activeSearchTerm, StringComparison.InvariantCultureIgnoreCase))
                            {
                                // Active search term not matched, skip it
                                continue;
                            }

                            if (settings.IgnoreObsolete && (field.Attributes & VariableAttributes.Obsolete) == VariableAttributes.Obsolete)
                            {
                                // Skip obsolete entries if that setting is enabled
                                continue;
                            }
                            EditorGUI.BeginChangeCheck();
                            object newValue = VariableDrawer.Draw(component, field, OnOpenObjectPicker);
                            if (EditorGUI.EndChangeCheck() && (field.Attributes & VariableAttributes.ReadOnly) == VariableAttributes.None && field.DataType != DataType.Unknown)
                            {
                                if (newValue != field.Value)
                                {
                                    field.Value = newValue;
                                    commonContext.APIManager.SendToPlayers(new SetVariableRequest(component.Guid, field));
                                }

                                //Debug.Log("Value changed in " + field.VariableName);
                            }
                        }
                        foreach (var property in component.Properties)
                        {
                            if (!string.IsNullOrEmpty(activeSearchTerm) && !property.VariableName.Contains(activeSearchTerm, StringComparison.InvariantCultureIgnoreCase))
                            {
                                // Active search term not matched, skip it
                                continue;
                            }

                            if (settings.IgnoreObsolete && (property.Attributes & VariableAttributes.Obsolete) == VariableAttributes.Obsolete)
                            {
                                // Skip obsolete entries if that setting is enabled
                                continue;
                            }

                            EditorGUI.BeginChangeCheck();
                            object newValue = VariableDrawer.Draw(component, property, OnOpenObjectPicker);
                            if (EditorGUI.EndChangeCheck() && (property.Attributes & VariableAttributes.ReadOnly) == VariableAttributes.None && property.DataType != DataType.Unknown)
                            {
                                if (newValue != property.Value)
                                {
                                    property.Value = newValue;
                                    commonContext.APIManager.SendToPlayers(new SetVariableRequest(component.Guid, property));
                                }
                                //Debug.Log("Value changed in " + property.VariableName);
                            }
                        }

                        GUIStyle   expandButtonStyle = new GUIStyle(GUI.skin.button);
                        RectOffset padding           = expandButtonStyle.padding;
                        padding.left              = 0;
                        padding.right             = 1;
                        expandButtonStyle.padding = padding;

                        GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
                        labelStyle.alignment = TextAnchor.MiddleRight;
                        GUIStyle normalButtonStyle = new GUIStyle(GUI.skin.button);
                        normalButtonStyle.padding   = normalButtonStyle.padding.SetLeft(100);
                        normalButtonStyle.alignment = TextAnchor.MiddleLeft;

                        foreach (var method in component.Methods)
                        {
                            if (!string.IsNullOrEmpty(activeSearchTerm) && !method.MethodName.Contains(activeSearchTerm, StringComparison.InvariantCultureIgnoreCase))
                            {
                                // Active search term not matched, skip it
                                continue;
                            }

                            if (settings.IgnoreObsolete && (method.MethodAttributes & MethodAttributes.Obsolete) == MethodAttributes.Obsolete)
                            {
                                // Skip obsolete entries if that setting is enabled
                                continue;
                            }

                            GUILayout.BeginHorizontal();
                            if (method.ReturnType == DataType.Void)
                            {
                                labelStyle.normal.textColor = Color.grey;
                            }
                            else if ((method.ReturnTypeAttributes & VariableAttributes.IsValueType) == VariableAttributes.IsValueType)
                            {
                                labelStyle.normal.textColor = new Color(0, 0, 1);
                            }
                            else
                            {
                                labelStyle.normal.textColor = new Color32(255, 130, 0, 255);
                            }

                            string displayText = method.MethodName + " (" + method.ParameterCount + ")";

                            if ((method.MethodAttributes & MethodAttributes.Static) == MethodAttributes.Static)
                            {
                                displayText += " [Static]";
                            }

                            if (GUILayout.Button(displayText, normalButtonStyle))
                            {
                                List <WrappedVariable> defaultArguments = new List <WrappedVariable>();

                                for (int i = 0; i < method.ParameterCount; i++)
                                {
                                    //Type type = DataTypeHelper.GetSystemTypeFromWrappedDataType(method.Parameters[i].DataType);

                                    WrappedParameter parameter = method.Parameters[i];
                                    defaultArguments.Add(new WrappedVariable(parameter));
                                }

                                commonContext.APIManager.SendToPlayers(new InvokeMethodRequest(component.Guid, method.MethodName, defaultArguments.ToArray()));
                            }

                            Rect lastRect = GUILayoutUtility.GetLastRect();
                            lastRect.xMax = normalButtonStyle.padding.left;
                            GUI.Label(lastRect, TypeUtility.NameForType(method.ReturnType), labelStyle);

                            if (method.ParameterCount > 0)
                            {
                                bool wasMethodExpanded = (method.Equals(expandedMethod));
                                bool isMethodExpanded  = GUILayout.Toggle(wasMethodExpanded, "▼", expandButtonStyle, GUILayout.Width(20));
                                GUILayout.EndHorizontal();

                                if (isMethodExpanded != wasMethodExpanded)                                 // has changed
                                {
                                    if (isMethodExpanded)
                                    {
                                        expandedMethod = method;
                                        arguments      = new List <WrappedVariable>(method.ParameterCount);
                                        for (int i = 0; i < method.ParameterCount; i++)
                                        {
                                            WrappedParameter parameter = method.Parameters[i];
                                            arguments.Add(new WrappedVariable(parameter));
                                        }
                                    }
                                    else
                                    {
                                        expandedMethod = null;
                                        arguments      = null;
                                    }
                                }
                                else if (isMethodExpanded)
                                {
                                    EditorGUI.indentLevel++;
                                    foreach (var argument in arguments)
                                    {
                                        argument.Value = VariableDrawer.Draw(null, argument, OnOpenObjectPicker);
                                        //argument.Value = VariableDrawer.DrawIndividualVariable(null, argument, argument.VariableName, DataTypeHelper.GetSystemTypeFromWrappedDataType(argument.DataType), argument.Value, OnOpenObjectPicker);
                                    }

                                    Rect buttonRect = GUILayoutUtility.GetRect(new GUIContent(), GUI.skin.button);
                                    buttonRect = EditorGUI.IndentedRect(buttonRect);

                                    if (GUI.Button(buttonRect, "Fire"))
                                    {
                                        commonContext.APIManager.SendToPlayers(new InvokeMethodRequest(component.Guid, method.MethodName, arguments.ToArray()));
                                    }
                                    EditorGUI.indentLevel--;

                                    GUILayout.Space(10);
                                }
                            }
                            else
                            {
                                GUILayout.EndHorizontal();
                            }
                        }
                    }
                }
                SidekickEditorGUI.DrawSplitter();
            }
            EditorGUILayout.EndScrollView();

            DrawOutputBox();
        }
 public static System.Enum EnumMaskField(GUIContent label, System.Enum enumValue)
 {
     return(EditorGUILayout.EnumFlagsField(label, enumValue));
 }
Ejemplo n.º 8
0
        private void InspectRules(IList <BundleBuilderData.BundleSplitRule> rules)
        {
            Block("Rules", () =>
            {
                var rulesCount = rules.Count;
                if (rulesCount > 0)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Asset Types", GUILayout.Width(80f));
                    EditorGUILayout.LabelField("Match Type", GUILayout.Width(80f));
                    EditorGUILayout.LabelField("Keyword", GUILayout.MinWidth(80f), GUILayout.ExpandWidth(true));
                    EditorGUILayout.LabelField("Exclude?", GUILayout.Width(50f));
                    GUILayout.Space(20f);
                    EditorGUILayout.EndHorizontal();
                }

                for (var i = 0; i < rulesCount; i++)
                {
                    var rule = rules[i];
                    EditorGUILayout.BeginHorizontal();
                    EditorGUI.BeginChangeCheck();
                    rule.assetTypes =
                        (BundleAssetTypes)EditorGUILayout.EnumFlagsField(rule.assetTypes, GUILayout.Width(80f));
                    rule.type = (BundleBuilderData.BundleSplitType)EditorGUILayout.EnumPopup(rule.type,
                                                                                             GUILayout.Width(80f));
                    rule.keyword = EditorGUILayout.TextField(rule.keyword, GUILayout.MinWidth(80f),
                                                             GUILayout.ExpandWidth(true));
                    rule.exclude = EditorGUILayout.Toggle(rule.exclude, GUILayout.Width(50f));
                    EditorGUI.BeginDisabledGroup(rule.exclude);
                    EditorGUI.EndDisabledGroup();
                    if (EditorGUI.EndChangeCheck())
                    {
                        _data.MarkAsDirty();
                    }

                    GUI.color    = Color.red;
                    var rect     = EditorGUILayout.GetControlRect(false, GUILayout.Width(20f));
                    rect.y      -= 2f;
                    rect.height += 1f;
                    if (GUI.Button(rect, Text("delete.rule", "X", "删除规则")))
                    {
                        if (EditorUtility.DisplayDialog("删除", $"确定删除规则?", "确定", "取消"))
                        {
                            Defer(() =>
                            {
                                rules.Remove(rule);
                                _data.MarkAsDirty();
                            });
                        }
                    }

                    GUI.color = _GUIColor;
                    EditorGUILayout.EndHorizontal();
                }
            }, () =>
            {
                GUI.color    = Color.green;
                var rect     = EditorGUILayout.GetControlRect(false, GUILayout.Width(20f));
                rect.y      -= 2f;
                rect.height += 1f;
                if (GUI.Button(rect, Text("add.rule", "+", "添加分包分片规则")))
                {
                    Defer(() =>
                    {
                        rules.Add(new BundleBuilderData.BundleSplitRule());
                        _data.MarkAsDirty();
                    });
                }

                GUI.color = _GUIColor;
            });
        }
Ejemplo n.º 9
0
        public override bool OnGUI()
        {
            if (base.OnGUI())
            {
                EditorGUI.BeginChangeCheck();
                canvasKun.renderMode = (RenderMode)EditorGUILayout.EnumPopup(Styles.RenderMode, canvasKun.renderMode);
                using (new EditorGUI.IndentLevelScope())
                {
                    switch (canvasKun.renderMode)
                    {
                    case RenderMode.ScreenSpaceOverlay:
                        canvasKun.pixelPerfect  = EditorGUILayout.Toggle(Styles.PixelPerfect, canvasKun.pixelPerfect);
                        canvasKun.sortingOrder  = EditorGUILayout.IntField(Styles.SortOrder, canvasKun.sortingOrder);
                        canvasKun.targetDisplay = EditorGUILayout.Popup(Styles.TargetDisplay, canvasKun.targetDisplay, Styles.Displays);
                        break;

                    case RenderMode.ScreenSpaceCamera:
                        canvasKun.pixelPerfect = EditorGUILayout.Toggle(Styles.PixelPerfect, canvasKun.pixelPerfect);

                        CameraDisplay(Styles.RenderCamera);

                        canvasKun.sortingOrder = EditorGUILayout.IntField(Styles.SortOrder, canvasKun.sortingOrder);
                        break;

                    case RenderMode.WorldSpace:

                        CameraDisplay(Styles.EventCamera);

                        if (SortingLayerKun.layers == null)
                        {
                            EditorGUILayout.TextField(Styles.SortingLayer, canvasKun.sortingLayerName);
                        }
                        else
                        {
                            string[] names = new string[SortingLayerKun.layers.Length];
                            for (var i = 0; i < names.Length; i++)
                            {
                                names[i] = SortingLayerKun.layers[i].name;
                            }

                            int id = -1;
                            for (var i = 0; i < SortingLayerKun.layers.Length; i++)
                            {
                                if (SortingLayerKun.layers[i].id == canvasKun.sortingLayerID)
                                {
                                    id = i;
                                    break;
                                }
                            }
                            id = EditorGUILayout.Popup(Styles.SortingLayer, id, names);
                            if (id != -1)
                            {
                                canvasKun.sortingLayerID   = SortingLayerKun.layers[id].id;
                                canvasKun.sortingLayerName = names[id];
                            }
                        }
                        break;
                    }
                }
#if UNITY_2019_1_OR_NEWER
                canvasKun.additionalShaderChannels = (AdditionalCanvasShaderChannels)EditorGUILayout.EnumFlagsField(Styles.AdditionalCanvasShaderChannels, canvasKun.additionalShaderChannels);
#else
                canvasKun.additionalShaderChannels = (AdditionalCanvasShaderChannels)EditorGUILayout.EnumMaskField(Styles.AdditionalCanvasShaderChannels, canvasKun.additionalShaderChannels);
#endif
                if (EditorGUI.EndChangeCheck())
                {
                    canvasKun.dirty = true;
                }
            }
            return(true);
        }
Ejemplo n.º 10
0
    void OnGUI()
    {
        if (target == null)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            bool createNew = GUILayout.Button("Create new BitAnimator", GUILayout.MinHeight(40), GUILayout.MaxWidth(180));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            if (createNew)
            {
                GameObject animatorGO = new GameObject("New Animator");
                target = animatorGO.AddComponent <BitAnimator>();
                target.animatorObject = animatorGO.AddComponent <Animator>();
                AudioSource audioSource = animatorGO.AddComponent <AudioSource>();
                audioSource.minDistance  = 10;
                audioSource.volume       = 0.25f;
                audioSource.dopplerLevel = 0;
                audioSource.spatialize   = false;
                GameObject targetGO = GameObject.CreatePrimitive(PrimitiveType.Cube);
                targetGO.transform.parent = animatorGO.transform;
                DestroyImmediate(targetGO.GetComponent <BoxCollider>());
                target.targetObject    = targetGO;
                Selection.activeObject = target;
            }
            else
            {
                BitAnimator[] bitAnimators = Resources.FindObjectsOfTypeAll <BitAnimator>();
                if (bitAnimators.Length > 0)
                {
                    GUILayout.FlexibleSpace();
                    target = (BitAnimator)EditorGUILayout.ObjectField("BitAnimator", target, typeof(BitAnimator), true);
                    GUILayout.Label("Or select exists animator:");
                    scroll = GUILayout.BeginScrollView(scroll, EditorStyles.helpBox);
                    selectedBitAnimator = GUILayout.SelectionGrid(selectedBitAnimator, bitAnimators.Select(c =>
                    {
                        AudioSource audio = c.GetComponentInChildren <AudioSource>();
                        return(c.gameObject.name + (c.audioClip != null ? " | " + c.audioClip.name : ""));
                    }).ToArray(), 1, EditorStyles.radioButton);
                    GUILayout.EndScrollView();
                    if (selectedBitAnimator >= 0)
                    {
                        Selection.activeObject = bitAnimators[selectedBitAnimator];
                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Open", GUILayout.MinHeight(40), GUILayout.MaxWidth(180)))
                        {
                            target = bitAnimators[selectedBitAnimator];
                            selectedBitAnimator = -1;
                        }
                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();
                    }
                }
                GUILayout.FlexibleSpace();
            }
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        else if (target.recordSlots.Count == 0)
        {
            target = (BitAnimator)EditorGUILayout.ObjectField("BitAnimator", target, typeof(BitAnimator), true);
            EditorGUILayout.HelpBox("This window only for visualization. Setup BitAnimator in the inspector window", MessageType.Info);
        }
        else
        {
            openSettings = EditorGUILayout.Foldout(openSettings, "Show settings", true);
            if (openSettings)
            {
                EditorGUI.indentLevel += 1;
                target   = (BitAnimator)EditorGUILayout.ObjectField("BitAnimator", target, typeof(BitAnimator), true);
                mode     = (ComputeProgram.VisualizationMode)EditorGUILayout.EnumFlagsField("Visualization modes", mode);
                scale    = EditorGUILayout.Slider("Scale", scale, 1, 30);
                multiply = Mathf.Pow(10.0f, EditorGUILayout.Slider("Multiply Log", Mathf.Log10(multiply), -5, 5));
                EditorGUILayout.LabelField(String.Format("Multiply = {0:F6}, AutoMultiply = {1:F6}, RMS = {2:F6}, Max = {3:F6}, Median = {4:F6}", multiply, autoMultiply, rms, maximum, median));
                if ((mode & ComputeProgram.VisualizationMode.RuntimeNormalize) != 0)
                {
                    autoNormilizeSpeed = EditorGUILayout.Slider("AutoNormilize Speed", autoNormilizeSpeed, 0, 50);
                }
                smoothFrequency = EditorGUILayout.Slider("FrequencySmooth", smoothFrequency, 0, 1);
                using (new EditorGUI.DisabledScope(audio == null || animation == null))
                {
                    if (audio != null && audio.clip != null)
                    {
                        EditorGUI.BeginChangeCheck();
                        time = audio.time;
                        time = EditorGUILayout.Slider("Animation play time", time, 0, audio.clip.length);
                        if (animation != null)
                        {
                            AnimationState anim = animation["BitAnimator.RuntimeAnimation"];
                            anim.speed = audio.pitch;
                            if (EditorGUI.EndChangeCheck())
                            {
                                bool oldState = anim.enabled;
                                anim.enabled = true;
                                audio.time   = time;
                                anim.time    = time;
                                animation.Sample();
                                anim.enabled = oldState;
                            }
                            else if (Mathf.Abs(anim.time - audio.time) > 0.05f)
                            {
                                anim.time = audio.time;
                            }
                        }
                        else if (EditorGUI.EndChangeCheck())
                        {
                            audio.time = time;
                        }
                    }
                    else
                    {
                        time = EditorGUILayout.Slider("Sound clip play time", time, 0, 0);
                    }
                    GUILayout.BeginHorizontal();
                    if (audio != null && animation != null)
                    {
                        if (audio.isPlaying)
                        {
                            if (GUILayout.Button("Pause", GUILayout.MaxWidth(128)))
                            {
                                audio.Pause();
                                animation.Stop();
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("Play", GUILayout.MaxWidth(128)))
                            {
                                audio.Play();
                                animation.Play();
                                animation["BitAnimator.RuntimeAnimation"].time = audio.time;
                            }
                        }
                    }
                    else
                    {
                        GUILayout.Button("Play", GUILayout.MaxWidth(128));
                    }

                    if (GUILayout.Button("Reset view", GUILayout.MaxWidth(128)))
                    {
                        ResetView();
                    }

                    if (BPM > 0)
                    {
                        GUILayout.Label("BPM: " + BPM);
                    }
                    GUILayout.EndHorizontal();
                }
                if (target != null)
                {
                    if (target.core != null)
                    {
                        //volumeCurve = EditorGUILayout.CurveField(volumeCurve);

                        /*if (GUILayout.Button("Decimation test", GUILayout.MaxWidth(128)))
                         * {
                         *
                         *  AnimationClip clip = AssetDatabase.LoadAssetAtPath<AnimationClip>(target.animationAssetPath);
                         *  EditorCurveBinding[] b = AnimationUtility.GetCurveBindings(clip);
                         *  AnimationCurve curve = AnimationUtility.GetEditorCurve(clip, b[1]);
                         *  StringBuilder str = new StringBuilder();
                         *  Keyframe[] keyframes = curve.keys;
                         *  //float rmsQuality = -(float)Math.Log(Math.Max(0.001, target.quality), Math.E) / 8.0f;
                         *  var values = keyframes.Select(k => (double)k.value);
                         *  double mean = values.Sum() / keyframes.Length;
                         *  double sd = Math.Sqrt(values.Select(v => (v - mean) * (v - mean)).Sum() / keyframes.Length);
                         *  double rms = Math.Sqrt(values.Select(v => v * v).Sum() / keyframes.Length);
                         *  double avg_sqrV = 0, v1 = 0;
                         *  foreach (double v in values)
                         *  {
                         *      double dv = v - v1;
                         *      avg_sqrV += dv * dv;
                         *      v1 = v;
                         *  }
                         *  avg_sqrV = Math.Sqrt(avg_sqrV / keyframes.Length);
                         *  str.AppendLine(String.Format("[Original] Mean = {0:F4}, SD = {1:F4}, RMS = {2:F4}, v^2 = {3:F4}, Count = {4}", mean, sd, rms, avg_sqrV, keyframes.Length));
                         *
                         *  float rq = Mathf.Pow(10.0f, -6.0f * target.quality * target.quality - 1.0f);
                         *  keyframes = target.core.DecimateAnimationCurve(curve.keys, rq).Where(k => k != null).Single();
                         *  values = keyframes.Select(k => (double)k.value);
                         *  mean = values.Sum() / keyframes.Length;
                         *  sd = Math.Sqrt(values.Select(v => (v - mean) * (v - mean)).Sum() / keyframes.Length);
                         *  rms = Math.Sqrt(values.Select(v => v * v).Sum() / keyframes.Length);
                         *  avg_sqrV = 0; v1 = 0;
                         *  foreach (double v in values)
                         *  {
                         *      double dv = v - v1;
                         *      avg_sqrV += dv * dv;
                         *      v1 = v;
                         *  }
                         *  avg_sqrV = Math.Sqrt(avg_sqrV / keyframes.Length);
                         *  str.AppendLine(String.Format("[Deciamated] Quality = {0}, Mean = {1:F4}, SD = {2:F4}, RMS = {3:F4}, v^2 = {4:F4}, Count = {5}", rq, mean, sd, rms, avg_sqrV, keyframes.Length));
                         *  curve.keys = keyframes;
                         *  Debug.Log(str);
                         *  AnimationUtility.SetEditorCurve(clip, b[0], curve);
                         *  AssetDatabase.SaveAssets();
                         *  AssetDatabase.Refresh();
                         * }*/
                        if (GUILayout.Button("Get BPM", GUILayout.MaxWidth(128)))
                        {
                            BPM = target.core.GetBPM();
                        }
                        EditorGUI.BeginChangeCheck();
                        plotGraphic = (PlotGraphic)EditorGUILayout.EnumPopup("Plot graphic", plotGraphic);
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (texture == null)
                            {
                                texture = new RenderTexture(512, 256, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
                                texture.enableRandomWrite = true;
                                texture.Create();
                                target.core.texture = texture;
                            }
                            target.core.RenderBPM(texture);
                            autoMultiply = 1.0f / rms;
                        }
                        if (texture != null)
                        {
                            if (Event.current.type == EventType.Repaint)
                            {
                                box = GUILayoutUtility.GetRect(position.width, position.height);
                                GUI.Box(box, texture);

                                int w = Mathf.FloorToInt(box.width / 8.0f) * 8;
                                int h = Mathf.FloorToInt(box.height / 8.0f) * 8;
                                if (texture.width != w || texture.height != h)
                                {
                                    texture.Release();
                                    texture = new RenderTexture(w, h, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
                                    texture.enableRandomWrite = true;
                                    texture.Create();
                                    target.core.texture = texture;
                                }
                            }
                            else
                            {
                                GUILayout.Box(texture, GUILayout.MinWidth(32), GUILayout.MinHeight(32), GUILayout.MaxWidth(2048), GUILayout.MaxHeight(2048));
                            }
                        }
                    }
                }
                int vram = SystemInfo.graphicsMemorySize;
                GUILayout.Label(string.Format("Available VRAM: {0:F3}GB | Used: {1:F3}GB", vram / 1024.0f, target != null && target.core != null ? target.core.UsedVRAM / 1024.0f / 1024.0f / 1024.0f : 0), EditorStyles.boldLabel);
                EditorGUI.indentLevel -= 1;
            }
            else if (texture != null)
            {
                if (Event.current.type == EventType.Repaint)
                {
                    Rect rect = GUILayoutUtility.GetRect(position.width, position.height);
                    GUI.Box(rect, texture);

                    int w = Mathf.FloorToInt(rect.width / 8.0f) * 8;
                    int h = Mathf.FloorToInt(rect.height / 8.0f) * 8;
                    if (texture.width != w || texture.height != h)
                    {
                        texture.Release();
                        texture = new RenderTexture(w, h, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
                        texture.enableRandomWrite = true;
                        texture.Create();
                        target.core.texture = texture;
                    }
                }
                else
                {
                    GUILayout.Box(texture, GUILayout.MinWidth(32), GUILayout.MinHeight(32), GUILayout.MaxWidth(2048), GUILayout.MaxHeight(2048));
                }
            }
            EditorGUIUtility.AddCursorRect(box, MouseCursor.SlideArrow);
            if (Event.current.type == EventType.MouseDown)
            {
                mouseDown = Event.current.mousePosition;
            }
            else if (Event.current.type == EventType.MouseUp)
            {
                mouseDown = -Vector2.one;
            }
            else if (Event.current.type == EventType.MouseDrag && box.Contains(mouseDown))
            {
                if (mouseDown.x >= 0 && audio != null)
                {
                    audio.time -= Event.current.delta.x / box.width * scale;
                    if (animation != null)
                    {
                        AnimationState anim  = animation["BitAnimator.RuntimeAnimation"];
                        bool           state = anim.enabled;
                        anim.enabled = true;
                        anim.time    = audio.time;
                        animation.Sample();
                        anim.enabled = state;
                    }
                    Event.current.Use();
                }
            }
            else if (Event.current.type == EventType.MouseMove)
            {
                pos = Event.current.mousePosition;
                if (box.Contains(pos))
                {
                    pos -= box.position;
                }
                else
                {
                    pos = Vector2.zero;
                }

                /*if (plotGraphic == PlotGraphic.BPM)
                 * {
                 *  float offset = (box.width - texture.width) / 2.0f;
                 *  pos.x -= offset;
                 *  BPM = Mathf.FloorToInt(pos.x / texture.width * 256 + 40);
                 *  Event.current.Use();
                 * }*/
            }
            else if (Event.current.type == EventType.ScrollWheel)
            {
                if (box.Contains(Event.current.mousePosition))
                {
                    scale *= Event.current.delta.y < 0 ? 1.125f : 1.0f / 1.125f;
                    Event.current.Use();
                }
            }
        }
    }
Ejemplo n.º 11
0
        internal override void OnGUI()
        {
            scroll = EditorGUILayout.BeginScrollView(scroll);
            //todo cache general settings to reduce lookup
            GUILayout.BeginHorizontal(GitGUI.Styles.BigTitle, GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.Label(GitGUI.IconContent("SceneAsset Icon", "Unity Settings"), GUILayout.Height(18));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(GitGUI.Contents.Help, GitGUI.Styles.IconButton))
            {
                GitLinks.GoTo(GitLinks.SettingsUniGitSettings);
            }
            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
            GUILayout.EndHorizontal();


            if (gitSettings != null)
            {
                bool save      = false;
                bool updateGit = false;

                EditorGUI.BeginChangeCheck();
                gitSettings.AutoStage = EditorGUILayout.Toggle(GitGUI.GetTempContent("Auto Stage", "Auto stage changes for committing when an asset is modified"), gitSettings.AutoStage);
                gitSettings.AutoFetch = EditorGUILayout.Toggle(GitGUI.GetTempContent("Auto Fetch", "Auto fetch repository changes when possible. This will tell you about changes to the remote repository without having to pull. This only works with the Credentials Manager."), gitSettings.AutoFetch);
                save |= EditorGUI.EndChangeCheck();

                EditorGUI.BeginChangeCheck();
                gitSettings.ProjectStatusOverlayDepth = EditorGUILayout.DelayedIntField(GitGUI.GetTempContent("Project Status Overlay Depth", "The maximum depth at which overlays will be shown in the Project Window. This means that folders at levels higher than this will not be marked as changed. -1 indicates no limit"), gitSettings.ProjectStatusOverlayDepth);
                gitSettings.ShowEmptyFolders          = EditorGUILayout.Toggle(GitGUI.GetTempContent("Show Empty Folders", "Show status for empty folder meta files and auto stage them, if 'Auto stage' option is enabled."), gitSettings.ShowEmptyFolders);
                GUIContent threadingContent = GitGUI.GetTempContent("Use Threading", "When Should Threading be used. In staging, unstaging or status retrival.");
                if ((gitSettings.Threading.IsFlagSet(GitSettingsJson.ThreadingType.Stage) || gitSettings.Threading.IsFlagSet(GitSettingsJson.ThreadingType.Unstage)) && lfsManager.Installed && lfsManager.CheckInitialized())
                {
                    threadingContent.image   = GitGUI.Textures.WarrningIconSmall;
                    threadingContent.tooltip = "Threaded 'Stage' and 'Unstage' are disabled when Git LFS is enabled.";
                }
                gitSettings.Threading = (GitSettingsJson.ThreadingType)EditorGUILayout.EnumFlagsField(threadingContent, gitSettings.Threading);

                gitSettings.UseGavatar            = EditorGUILayout.Toggle(GitGUI.GetTempContent("Use Gavatar", "Load Gavatars based on the committer's email address."), gitSettings.UseGavatar);
                gitSettings.MaxCommitTextAreaSize = EditorGUILayout.DelayedFloatField(GitGUI.GetTempContent("Max Commit Text Area Size", "The maximum height the commit text area can expand to."), gitSettings.MaxCommitTextAreaSize);
                GUIContent detectRenamesContent = GitGUI.GetTempContent("Detect Renames", "Detect Renames. This will make UniGit detect rename changes of files. Note that this feature is not always working as expected do the the modular updating and how Git itself works.");
                if (gitSettings.LazyMode)
                {
                    detectRenamesContent.image   = GitGUI.Textures.WarrningIconSmall;
                    detectRenamesContent.tooltip = "Rename Detection will not work properly in preview with lazy update, altho they WILL still be detected by Git internally.";
                }
                gitSettings.DetectRenames = (GitSettingsJson.RenameTypeEnum)EditorGUILayout.EnumFlagsField(detectRenamesContent, gitSettings.DetectRenames);
                if (EditorGUI.EndChangeCheck())
                {
                    save      = true;
                    updateGit = true;
                }

                EditorGUI.BeginChangeCheck();
                gitSettings.UseSimpleContextMenus = EditorGUILayout.Toggle(GitGUI.GetTempContent("Use Simple Context Menus", "Use Unity's default context menu on Diff window, instead of the UniGit one (with icons and animations)."), gitSettings.UseSimpleContextMenus);
                gitSettings.LazyMode                     = EditorGUILayout.Toggle(GitGUI.GetTempContent("Lazy Update Mode", "Without lazy mode, git status is updated on each assembly reload, leaving and entering play mode, staging, unstaging and any asset change."), gitSettings.LazyMode);
                gitSettings.TrackSystemFiles             = EditorGUILayout.Toggle(GitGUI.GetTempContent("Track System Files", "Should files and folders be tracked that are outside the 'Assets' folder? This should definitely be used if lazy mode is on."), gitSettings.TrackSystemFiles);
                gitSettings.UseUnityConsole              = EditorGUILayout.Toggle(GitGUI.GetTempContent("Use Unity's Console", "Show Info, Warning and Error messages in Unity's builtin console instead of the Git Log."), gitSettings.UseUnityConsole);
                gitSettings.AnimationType                = (GitSettingsJson.AnimationTypeEnum)EditorGUILayout.EnumFlagsField(GitGUI.GetTempContent("Animation Types", "Which animation are allowed?"), gitSettings.AnimationType);
                gitSettings.CreateFoldersForDriftingMeta = EditorGUILayout.Toggle(GitGUI.GetTempContent("Create Missing Meta Folders", "Create Missing Folders for .meta files. If a .meta folder is merged but the folder is not present, create it."), gitSettings.CreateFoldersForDriftingMeta);

                save |= EditorGUI.EndChangeCheck();

                if (save)
                {
                    gitSettings.MarkDirty();
                }
                if (updateGit)
                {
                    gitManager.MarkDirty();
                }
            }

            GUILayout.BeginHorizontal(GitGUI.Styles.BigTitle, GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.Label(GitGUI.IconContent("UnityEditor.SceneHierarchyWindow", "Git Settings"), GUILayout.Height(18));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(GitGUI.Contents.Help, GitGUI.Styles.IconButton))
            {
                GitLinks.GoTo(GitLinks.SettingsGitSettings);
            }
            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
            GUILayout.EndHorizontal();

            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.TextField(new GUIContent("Repository Path"), paths.RepoPath);
            EditorGUI.EndDisabledGroup();

            GUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(GitGUI.GetTempContent("Main Path"));
            if (GUILayout.Button("Select Main Repository Path", EditorStyles.miniButton))
            {
                settingsManager.ShowChooseMainRepositoryPathPopup(settingsWindow);
                GUIUtility.ExitGUI();
            }
            GUILayout.EndHorizontal();

            string currentConfigFolder = gitManager.GetCurrentDotGitFolder();

            if (Directory.Exists(currentConfigFolder))
            {
                using (Configuration c = Configuration.BuildFrom(currentConfigFolder))
                {
                    EditorGUILayout.LabelField(GitGUI.GetTempContent("User"), EditorStyles.boldLabel);
                    EditorGUI.indentLevel = 1;
                    GitGUI.DoConfigStringField(c, GitGUI.GetTempContent("Name", "Your full name to be recorded in any newly created commits."), "user.name", "");
                    GitGUI.DoConfigStringField(c, GitGUI.GetTempContent("Email", "Your email address to be recorded in any newly created commits."), "user.email", "");
                    EditorGUI.indentLevel = 0;

                    EditorGUILayout.LabelField(GitGUI.GetTempContent("Core"), EditorStyles.boldLabel);
                    EditorGUI.indentLevel = 1;
                    GitGUI.DoConfigToggle(c, GitGUI.GetTempContent("Auto LF line endings", "Setting this variable to 'true' is the same as setting the text attribute to 'auto' on all files and core.eol to 'crlf'. Set to true if you want to have CRLF line endings in your working directory and the repository has LF line endings. "), "core.autocrlf", true);
                    GitGUI.DoConfigToggle(c, GitGUI.GetTempContent("Bare", "If true this repository is assumed to be bare and has no working directory associated with it. If this is the case a number of commands that require a working directory will be disabled, such as git-add[1] or git-merge[1]."), "core.bare", false);
                    GitGUI.DoConfigToggle(c, GitGUI.GetTempContent("Symlinks", "If false, symbolic links are checked out as small plain files that contain the link text. git-update-index[1] and git-add[1] will not change the recorded type to regular file. Useful on filesystems like FAT that do not support symbolic links."), "core.symlinks", false);
                    GitGUI.DoConfigToggle(c, GitGUI.GetTempContent("Ignore Case", "If true, this option enables various workarounds to enable Git to work better on filesystems that are not case sensitive, like FAT. For example, if a directory listing finds 'makefile' when Git expects 'Makefile', Git will assume it is really the same file, and continue to remember it as 'Makefile'."), "core.ignorecase", true);
                    GitGUI.DoConfigToggle(c, GitGUI.GetTempContent("Logal Reference Updates", "Enable the reflog."), "core.logallrefupdates", true);
                    GitGUI.DoConfigIntSlider(c, GitGUI.GetTempContent("Compression", "An integer -1..9, indicating a default compression level. -1 is the zlib default. 0 means no compression, and 1..9 are various speed/size tradeoffs, 9 being slowest."), -1, 9, "core.compression", -1);
                    GitGUI.DoConfigStringField(c, GitGUI.GetTempContent("Big File Threshold", "Files larger than this size are stored deflated, without attempting delta compression. Storing large files without delta compression avoids excessive memory usage, at the slight expense of increased disk usage. Additionally files larger than this size are always treated as binary."), "core.bigFileThreshold", "512m");
                    EditorGUI.indentLevel = 0;

                    EditorGUILayout.LabelField(GitGUI.GetTempContent("Branch"), EditorStyles.boldLabel);
                    EditorGUI.indentLevel = 1;
                    GitGUI.DoConfigStringsField(c, GitGUI.GetTempContent("Auto Setup Rebase", "When a new branch is created with git branch or git checkout that tracks another branch, this variable tells Git to set up pull to rebase instead of merge."), "branch.autoSetupRebase", autoRebaseOptions, "never");
                    EditorGUI.indentLevel = 0;

                    EditorGUILayout.LabelField(GitGUI.GetTempContent("Diff"), EditorStyles.boldLabel);
                    EditorGUI.indentLevel = 1;
                    GitGUI.DoConfigToggle(c, GitGUI.GetTempContent("Renames", "Whether and how Git detects renames. If set to 'false', rename detection is disabled. If set to 'true', basic rename detection is enabled. "), "diff.renames", true);
                    GitGUI.DoConfigIntField(c, GitGUI.GetTempContent("Rename Limit", "The number of files to consider when performing the copy/rename detection. Use -1 for unlimited"), "diff.renameLimit", -1);
                    EditorGUI.indentLevel = 0;

                    EditorGUILayout.LabelField(GitGUI.GetTempContent("HTTP"), EditorStyles.boldLabel);
                    EditorGUI.indentLevel = 1;
                    GitGUI.DoConfigToggle(c, GitGUI.GetTempContent("Verify SSL Crtificate", "Whether to verify the SSL certificate when fetching or pushing over HTTPS."), "http.sslVerify", true);
                    string oldPath = c.GetValueOrDefault <string>("http.sslCAInfo");
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel(GitGUI.GetTempContent("SSL Certificate File", "File containing the certificates to verify the peer with when fetching or pushing over HTTPS."));
                    if (GUILayout.Button(GitGUI.GetTempContent(oldPath), "TE ToolbarDropDown"))
                    {
                        EditorGUI.BeginChangeCheck();
                        string newPath = EditorUtility.OpenFilePanelWithFilters("Certificate", string.IsNullOrEmpty(oldPath) ? Application.dataPath : Path.GetFullPath(oldPath), new string[] { "", "cer", "", "pom", "", "crt" });
                        if (oldPath != newPath)
                        {
                            c.Set("http.sslCAInfo", newPath);
                        }
                    }

                    EditorGUILayout.EndHorizontal();
                    EditorGUI.indentLevel = 0;
                }
            }

            GUILayout.BeginHorizontal(GitGUI.Styles.BigTitle, GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.Label(GitGUI.IconContent("IN LockButton on", "Git Ignore"), GUILayout.Height(18));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(GitGUI.Contents.Help, GitGUI.Styles.IconButton))
            {
                GitLinks.GoTo(GitLinks.SettingsGitIgnoreHelp);
            }
            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
            GUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(GitGUI.IconContent("IN LockButton on", "Open Git Ignore File")))
            {
                OpenGitIgnore();
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndScrollView();
        }
Ejemplo n.º 12
0
        void DrawLightSettings()
        {
            settings.DrawColor();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(m_AdditionalLightData.intensity, s_Styles.lightIntensity);
            m_AdditionalLightData.lightUnit.enumValueIndex = (int)LightIntensityUnitPopup(m_LightShape);
            EditorGUILayout.EndHorizontal();

            // Only display reflector option if it make sense
            if (m_LightShape == LightShape.Spot)
            {
                var spotLightShape = (SpotLightShape)m_AdditionalLightData.spotLightShape.enumValueIndex;
                if ((spotLightShape == SpotLightShape.Cone || spotLightShape == SpotLightShape.Pyramid) &&
                    m_AdditionalLightData.lightUnit.enumValueIndex == (int)PunctualLightUnit.Lumen)
                {
                    EditorGUILayout.PropertyField(m_AdditionalLightData.enableSpotReflector, s_Styles.enableSpotReflector);
                }
            }

            settings.DrawBounceIntensity();

            settings.DrawLightmapping();

            EditorGUI.BeginChangeCheck(); // For GI we need to detect any change on additional data and call SetLightDirty

            // No cookie with area light (maybe in future textured area light ?)
            if (!HDAdditionalLightData.IsAreaLight(m_AdditionalLightData.lightTypeExtent))
            {
                settings.DrawCookie();

                // When directional light use a cookie, it can control the size
                if (settings.cookie != null && m_LightShape == LightShape.Directional)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(m_AdditionalLightData.shapeWidth, s_Styles.cookieSizeX);
                    EditorGUILayout.PropertyField(m_AdditionalLightData.shapeHeight, s_Styles.cookieSizeY);
                    EditorGUI.indentLevel--;
                }
            }

            if (m_AdditionalLightData.showAdditionalSettings.boolValue)
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Additional Settings", EditorStyles.boldLabel);
                EditorGUI.indentLevel++;
                var hdPipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline;
                using (new EditorGUI.DisabledScope(!hdPipeline.asset.renderPipelineSettings.supportLightLayers))
                {
                    m_AdditionalLightData.lightLayers.intValue = Convert.ToInt32(EditorGUILayout.EnumFlagsField(s_Styles.lightLayer, (LightLayerEnum)m_AdditionalLightData.lightLayers.intValue));
                }
                EditorGUILayout.PropertyField(m_AdditionalLightData.affectDiffuse, s_Styles.affectDiffuse);
                EditorGUILayout.PropertyField(m_AdditionalLightData.affectSpecular, s_Styles.affectSpecular);
                if (m_LightShape != LightShape.Directional)
                {
                    EditorGUILayout.PropertyField(m_AdditionalLightData.fadeDistance, s_Styles.fadeDistance);
                }
                EditorGUILayout.PropertyField(m_AdditionalLightData.lightDimmer, s_Styles.lightDimmer);
                EditorGUILayout.PropertyField(m_AdditionalLightData.volumetricDimmer, s_Styles.volumetricDimmer);
                if (m_LightShape != LightShape.Directional)
                {
                    EditorGUILayout.PropertyField(m_AdditionalLightData.applyRangeAttenuation, s_Styles.applyRangeAttenuation);
                }

                // Emissive mesh for area light only
                if (HDAdditionalLightData.IsAreaLight(m_AdditionalLightData.lightTypeExtent))
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(m_AdditionalLightData.displayAreaLightEmissiveMesh, s_Styles.displayAreaLightEmissiveMesh);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_UpdateAreaLightEmissiveMeshComponents = true;
                    }
                }

                EditorGUI.indentLevel--;
            }

            if (EditorGUI.EndChangeCheck())
            {
                m_UpdateAreaLightEmissiveMeshComponents       = true;
                m_AdditionalLightData.fadeDistance.floatValue = Mathf.Max(m_AdditionalLightData.fadeDistance.floatValue, 0.01f);
                ((Light)target).SetLightDirty(); // Should be apply only to parameter that's affect GI, but make the code cleaner
            }
        }
        void OnGUI()
        {
            _isReady    = _mainTask == null || _mainTask.IsCompleted;
            GUI.enabled = _isReady;

            EditorGUILayout.Separator();

            EditorGUILayout.BeginVertical();
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Service Provider Selected: ");
                GUILayout.Label(_serviceProvider != null ? _serviceProvider.GetType().Name : "NONE");
                EditorGUILayout.EndHorizontal();
                foreach (var entry in _listServiveProviders)
                {
                    if (
                        _serviceProvider.GetType() != entry.instance.GetType() &&
                        GUILayout.Button($"Switch To { entry.name }")
                        )
                    {
                        _serviceProvider = entry.instance;
                        _key             = null;
                    }
                }
            }
            EditorGUILayout.EndVertical();

            _scroll_window = EditorGUILayout.BeginScrollView(_scroll_window);
            {
                GUILayout.BeginVertical("- SETTINGS -", "window");
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("REGION BOTTOM LEFT CORNER:");

                        //GUILayout.FlexibleSpace();

                        GUILayout.Label("latitude:", GUILayout.Width(60f));
                        _settings.start.latitude = Mathf.Clamp(
                            EditorGUILayout.FloatField(_settings.start.latitude, GUILayout.Width(60f)),
                            -90f,
                            90f
                            );

                        GUILayout.Label("longitude:", GUILayout.Width(60f));
                        _settings.start.longitude = Mathf.Clamp(
                            EditorGUILayout.FloatField(_settings.start.longitude, GUILayout.Width(60f)),
                            -180f,
                            180f
                            );
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("REGION UPPER RIGHT CORNER:");

                        //GUILayout.FlexibleSpace();

                        GUILayout.Label("latitude:", GUILayout.Width(60f));
                        _settings.end.latitude = Mathf.Clamp(
                            EditorGUILayout.FloatField(_settings.end.latitude, GUILayout.Width(60f)),
                            -90f,
                            90f
                            );

                        GUILayout.Label("longitude:", GUILayout.Width(60f));
                        _settings.end.longitude = Mathf.Clamp(
                            EditorGUILayout.FloatField(_settings.end.longitude, GUILayout.Width(60f)),
                            -180f,
                            180f
                            );
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();
                        GUILayout.Label("(move region)");
                        float w = _settings.end.longitude - _settings.start.longitude;
                        float h = _settings.end.latitude - _settings.start.latitude;
                        if (GUILayout.Button("<", GUILayout.Width(30f)))
                        {
                            _settings.start.longitude -= w;
                            _settings.end.longitude   -= w;
                        }
                        if (GUILayout.Button("^", GUILayout.Width(30f)))
                        {
                            _settings.start.latitude += h;
                            _settings.end.latitude   += h;
                        }
                        if (GUILayout.Button("v", GUILayout.Width(30f)))
                        {
                            _settings.start.latitude -= h;
                            _settings.end.latitude   -= h;
                        }
                        if (GUILayout.Button(">", GUILayout.Width(30f)))
                        {
                            _settings.start.longitude += w;
                            _settings.end.longitude   += w;
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.PrefixLabel("Resolution:");

                        //GUILayout.FlexibleSpace();

                        //calculate meters per degree:
                        double metersPerDegreeLatitude;
                        double metersPerDegreeLongitude;
                        {
                            Coordinate middlePoint = _settings.start + ((_settings.end - _settings.start) * 0.5f);
                            metersPerDegreeLatitude = _core.HaversineDistance(
                                new Coordinate {
                                latitude  = _settings.start.latitude,
                                longitude = middlePoint.longitude
                            },
                                new Coordinate {
                                latitude  = _settings.end.latitude,
                                longitude = middlePoint.longitude
                            }
                                ) / _settings.resolution.latitude;
                            metersPerDegreeLongitude = _core.HaversineDistance(
                                new Coordinate {
                                latitude  = middlePoint.latitude,
                                longitude = _settings.start.longitude
                            },
                                new Coordinate {
                                latitude  = middlePoint.latitude,
                                longitude = _settings.end.longitude
                            }
                                ) / _settings.resolution.longitude;
                        }

                        GUILayout.Label("latitude:", GUILayout.Width(60f));
                        _settings.resolution.latitude = Mathf.Clamp(
                            EditorGUILayout.IntField(_settings.resolution.latitude, GUILayout.Width(60f)),
                            1,
                            int.MaxValue
                            );
                        GUILayout.Label($"({ metersPerDegreeLatitude.ToString("0.##") } [m])");

                        GUILayout.Label("longitude:", GUILayout.Width(60f));
                        _settings.resolution.longitude = Mathf.Clamp(
                            EditorGUILayout.IntField(_settings.resolution.longitude, GUILayout.Width(60f)),
                            1,
                            int.MaxValue
                            );
                        GUILayout.Label($"({ metersPerDegreeLongitude.ToString("0.##") } [m])");
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Max Coordinates Per Request");
                        settings.maxCoordinatesPerRequest = EditorGUILayout.IntField(settings.maxCoordinatesPerRequest);
                    }
                    EditorGUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();



                GUILayout.FlexibleSpace();



                GUILayout.BeginVertical("- PROCESS -", "window");
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("api key: ", GUILayout.ExpandWidth(false));
                    _key = GUILayout.PasswordField(_key != null ? _key : "", '*');
                    GUILayout.EndHorizontal();

                    //start button:
                    if (GUILayout.Button("START HTTP REQUESTS", GUILayout.Height(EditorGUIUtility.singleLineHeight * 2f)))
                    {
                        string filePath = EditorUtility.SaveFilePanel(
                            $"Save data file",
                            _core.GetFolderPath(),
                            _core.GetFileNamePrefix(
                                _settings.start,
                                _settings.end,
                                _settings.resolution
                                ),
                            "csv"
                            );
                        if (filePath.Length != 0)
                        {
                            _taskTicket = new Ticket <float>(0f);
                            _mainTask   = _core.GetElevationData(
                                filePath:                       filePath,
                                serviceProvider:                _serviceProvider,
                                apikey:                         _key,
                                ticket:                         _taskTicket,
                                start:                          _settings.start,
                                end:                            _settings.end,
                                resolution:                     _settings.resolution,
                                maxCoordinatesPerRequest:       _settings.maxCoordinatesPerRequest,
                                this.Repaint,
                                () =>
                            {
                                if (_onFinished == EOnFinished.createImage)
                                {
                                    _core.WriteImageFile(
                                        filePath.Replace(".csv", ".png"),
                                        _settings.resolution.longitude,
                                        _settings.resolution.latitude,
                                        _createImageSettings.offset,
                                        _createImageSettings.lerp
                                        );
                                }

                                //flash editor window (will it even does that?)
                                EditorWindow.GetWindow <MainWindow>().Show();
                            },
                                _logTraffic
                                );
                        }
                        else
                        {
                            Debug.Log("Cancelled by user");
                        }
                    }

                    bool working = _mainTask != null && _mainTask.Status != TaskStatus.RanToCompletion && _mainTask.Status != TaskStatus.Canceled;

                    //progress bar:
                    if (working)
                    {
                        bool b = GUI.enabled;
                        GUI.enabled = true;
                        EditorGUI.ProgressBar(EditorGUILayout.GetControlRect(), _taskTicket.value, "progress");
                        GUI.enabled = b;
                    }

                    //abort button:
                    bool abortingInProgress = working && _taskTicket.invalid;
                    GUI.enabled = _isReady == false && abortingInProgress == false;
                    {
                        string abortButtonLabel = abortingInProgress ? "Aborting..." : "Abort";
                        if (GUILayout.Button(abortButtonLabel))
                        {
                            _taskTicket.Invalidate();
                        }
                    }
                    GUI.enabled = _isReady;

                    //toggles
                    {
                        bool GUIenabled = GUI.enabled;
                        GUI.enabled = true;
                        {
                            //log traffic toggle:
                            _logTraffic = EditorGUILayout.Toggle("log traffic:", _logTraffic);

                            //do on finished:
                            _onFinished = (EOnFinished)EditorGUILayout.EnumFlagsField("On Finished:", _onFinished);
                        }
                        GUI.enabled = GUIenabled;
                    }
                }
                GUILayout.EndVertical();



                GUILayout.FlexibleSpace();



                GUILayout.BeginVertical("- TOOLS -", "window");
                {
                    //tools are (should be) independent from http process, so make sure GUI is enabled:
                    GUI.enabled = true;

                    //
                    if (GUILayout.Button("Create Image", GUILayout.Height(EditorGUIUtility.singleLineHeight * 2f)))
                    {
                        CreateImageWindow.CreateWindow(this);
                    }
                }
                GUILayout.EndVertical();
                EditorGUILayout.Separator();
            }
            EditorGUILayout.EndScrollView();
            EditorGUILayout.Separator();
        }
    void OnGui()
    {
#if UNITY_EDITOR
        Type = (TriggerVolumeType)EditorGUILayout.EnumFlagsField(Type);
#endif
    }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            WearableDebugProvider provider = (WearableDebugProvider)fieldInfo.GetValue(property.serializedObject.targetObject);

            EditorGUI.BeginProperty(position, label, property);

            EditorGUILayout.HelpBox(DESCRIPTION_BOX, MessageType.None);
            EditorGUILayout.Space();

            // Virtual device config
            if (provider.ConnectedDevice.HasValue)
            {
                EditorGUILayout.HelpBox(string.Format(DEVICE_CONFIG_FIELDS_DISABLED_BOX_FORMAT, DISCONNECT_LABEL), MessageType.Info);
            }

            using (new EditorGUI.DisabledScope(provider.ConnectedDevice.HasValue))
            {
                // Device properties
                EditorGUILayout.IntSlider(
                    property.FindPropertyRelative(RSSI_FIELD),
                    WearableConstants.MINIMUM_RSSI_VALUE,
                    WearableConstants.MAXIMUM_RSSI_VALUE,
                    WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);

                EditorGUILayout.Separator();
                EditorGUILayout.PropertyField(
                    property.FindPropertyRelative(DEVICE_NAME_FIELD),
                    WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                EditorGUILayout.PropertyField(
                    property.FindPropertyRelative(UID_FIELD),
                    WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);

                // draw product and variant types based on ids
                var productIdProp = property.FindPropertyRelative(PRODUCT_ID_FIELD);
                _productType = WearableTools.GetProductType((ProductId)productIdProp.intValue);
                var variantProp = property.FindPropertyRelative(VARIANT_ID_FIELD);

                EditorGUI.BeginChangeCheck();
                _productType = (ProductType)EditorGUILayout.EnumPopup(
                    PRODUCT_TYPE_LABEL,
                    _productType
                    );
                if (EditorGUI.EndChangeCheck())
                {
                    // if we have changed the product, we need to reset the variants
                    productIdProp.intValue        = (int)WearableTools.GetProductId(_productType);
                    variantProp.intValue          = 0;
                    _editorVariantOptionsAreDirty = true;
                }

                if (_editorVariantOptionsAreDirty)
                {
                    _editorVariantMap             = GetVariantMap(_productType);
                    _editorVariantOptions         = _editorVariantMap.Keys.ToArray();
                    _editorVariantOptionsAreDirty = false;
                }

                string variantName = GetNameForProductAndVariantId(_productType, (byte)variantProp.intValue);
                var    optionIndex = Array.IndexOf(_editorVariantOptions, variantName);
                _editorVariantIndex = EditorGUILayout.Popup(
                    VARIANT_TYPE_LABEL,
                    optionIndex >= 0 ? optionIndex : 0,
                    _editorVariantOptions
                    );

                variantProp.intValue = _editorVariantMap[_editorVariantOptions[_editorVariantIndex]];

                // Firmware simulation
                EditorGUILayout.PropertyField(
                    property.FindPropertyRelative(FIRMWARE_VERSION_FIELD),
                    WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                var firmwareSufficient = property.FindPropertyRelative(BOSE_AR_ENABLED_FIELD);
                var firmwareAvailable  = property.FindPropertyRelative(FIRMWARE_UPDATE_AVAILABLE_FIELD);
                EditorGUILayout.PropertyField(firmwareSufficient, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                EditorGUILayout.PropertyField(firmwareAvailable, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);

                if (firmwareSufficient.boolValue)
                {
                    if (firmwareAvailable.boolValue)
                    {
                        EditorGUILayout.HelpBox(FIRMWARE_UPDATE_AVAILABLE_BOX, MessageType.Info);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox(FIRMWARE_GOOD_BOX, MessageType.Info);
                    }
                }
                else
                {
                    if (firmwareAvailable.boolValue)
                    {
                        EditorGUILayout.HelpBox(FIRMWARE_UPDATE_REQUIRED_BOX, MessageType.Warning);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox(FIRMWARE_DEVICE_NOT_SUPPORTED_BOX, MessageType.Error);
                    }
                }

                // Secure pairing
                var acceptSecurePairing = property.FindPropertyRelative(ACCEPT_SECURE_PAIRING_FIELD);
                EditorGUILayout.PropertyField(acceptSecurePairing, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                if (acceptSecurePairing.boolValue)
                {
                    EditorGUILayout.HelpBox(SECURE_PAIRING_ACCEPTED_BOX, MessageType.Info);
                }
                else
                {
                    EditorGUILayout.HelpBox(SECURE_PAIRING_REJECTED_BOX, MessageType.Error);
                }

                // Sensor and gesture availability
                var sensorFlagsProp      = property.FindPropertyRelative(SENSOR_FLAGS_FIELD);
                var sensorFlagsEnumValue = EditorGUILayout.EnumFlagsField(sensorFlagsProp.displayName, provider.AvailableSensors);
                sensorFlagsProp.intValue = (int)Convert.ChangeType(sensorFlagsEnumValue, typeof(SensorFlags));

                var gestureFlagsProp      = property.FindPropertyRelative(GESTURE_FLAGS_FIELD);
                var gestureFlagsEnumValue = EditorGUILayout.EnumFlagsField(gestureFlagsProp.displayName, provider.AvailableGestures);
                gestureFlagsProp.intValue = (int)Convert.ChangeType(gestureFlagsEnumValue, typeof(GestureFlags));
            }
            EditorGUILayout.Space();

            // Simulated delay
            var delayProp = property.FindPropertyRelative(DELAY_TIME_FIELD);

            EditorGUILayout.PropertyField(delayProp, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
            if (delayProp.floatValue < 0.0f)
            {
                delayProp.floatValue = 0.0f;
            }

            EditorGUILayout.Space();

            // Device status, ANR, and CNC via dynamic info
            GUILayoutTools.LineSeparator();
            EditorGUILayout.PropertyField(property.FindPropertyRelative(DYNAMIC_DEVICE_INFO_FIELD), WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
            GUILayoutTools.LineSeparator();

            DynamicDeviceInfo dynamicDeviceInfo = provider.GetDynamicDeviceInfo();
            DeviceStatus      status            = dynamicDeviceInfo.deviceStatus;

            using (new EditorGUI.DisabledScope(!provider.ConnectedDevice.HasValue))
            {
                bool serviceSuspended = status.GetFlagValue(DeviceStatusFlags.SensorServiceSuspended);

                // Service suspended
                using (new EditorGUI.DisabledScope(serviceSuspended))
                {
                    // Only allow selecting a reason if the service isn't suspended
                    _sensorServiceSuspendedReason = (SensorServiceSuspendedReason)EditorGUILayout.EnumPopup(
                        SENSOR_SERVICE_SUSPENSION_REASON_LABEL,
                        _sensorServiceSuspendedReason,
                        WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                }

                if (serviceSuspended)
                {
                    bool shouldResume = GUILayout.Button(RESUME_SENSOR_SERVICE_LABEL, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                    if (shouldResume)
                    {
                        provider.SimulateSensorServiceResumed();
                    }
                }
                else
                {
                    bool shouldSuspend = GUILayout.Button(SUSPEND_SENSOR_SERVICE_LABEL, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                    if (shouldSuspend)
                    {
                        provider.SimulateSensorServiceSuspended(_sensorServiceSuspendedReason);
                    }
                }
            }

            EditorGUILayout.Space();

            // Movement simulation
            SerializedProperty simulateMovementProperty = property.FindPropertyRelative(MOVEMENT_SIMULATION_MODE_FIELD);

            EditorGUILayout.PropertyField(simulateMovementProperty, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
            var simulatedMovementMode = (WearableDebugProvider.MovementSimulationMode)simulateMovementProperty.enumValueIndex;

            if (simulatedMovementMode == WearableDebugProvider.MovementSimulationMode.ConstantRate)
            {
                SerializedProperty rotationTypeProperty = property.FindPropertyRelative(ROTATION_TYPE_FIELD);
                EditorGUILayout.PropertyField(rotationTypeProperty, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);

                string rotationType = rotationTypeProperty.enumNames[rotationTypeProperty.enumValueIndex];
                if (rotationType == ROTATION_TYPE_EULER)
                {
                    EditorGUILayout.HelpBox(EULER_RATE_BOX, MessageType.None);
                    EditorGUILayout.PropertyField(property.FindPropertyRelative(EULER_SPIN_RATE_FIELD), WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                }
                else if (rotationType == ROTATION_TYPE_AXIS_ANGLE)
                {
                    EditorGUILayout.HelpBox(AXIS_ANGLE_BOX, MessageType.None);
                    SerializedProperty axisAngleProperty = property.FindPropertyRelative(AXIS_ANGLE_SPIN_RATE_FIELD);
                    Vector4            previousValue     = axisAngleProperty.vector4Value;
                    Vector4            newValue          = EditorGUILayout.Vector3Field(
                        AXIS_LABEL,
                        new Vector3(previousValue.x, previousValue.y, previousValue.z),
                        WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                    if (newValue.sqrMagnitude < float.Epsilon)
                    {
                        newValue.x = 1.0f;
                    }

                    newValue.w = EditorGUILayout.FloatField(RATE_LABEL, previousValue.w, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                    axisAngleProperty.vector4Value = newValue;
                }
            }
            else if (simulatedMovementMode == WearableDebugProvider.MovementSimulationMode.MobileDevice)
            {
                EditorGUILayout.HelpBox(USE_SIMULATED_MOVEMENT_MOBILE_DEVICE_HELP_BOX, MessageType.Info);
            }

            // Gesture triggers
            GUILayout.Label(GESTURES_LABEL, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
            for (int i = 0; i < WearableConstants.GESTURE_IDS.Length; i++)
            {
                GestureId gesture = WearableConstants.GESTURE_IDS[i];

                if (gesture == GestureId.None)
                {
                    continue;
                }

                using (new EditorGUI.DisabledScope(
                           !(provider.GetCachedDeviceConfiguration().GetGestureConfig(gesture).isEnabled&&
                             EditorApplication.isPlaying)))
                {
                    bool shouldTrigger = GUILayout.Button(Enum.GetName(typeof(GestureId), gesture), WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                    if (shouldTrigger)
                    {
                        provider.SimulateGesture(gesture);
                    }
                }
            }

            // Disconnect button
            EditorGUILayout.Space();
            using (new EditorGUI.DisabledScope(!provider.ConnectedDevice.HasValue))
            {
                bool shouldDisconnect = GUILayout.Button(DISCONNECT_LABEL, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                if (shouldDisconnect)
                {
                    provider.SimulateDisconnect();
                }
            }

            // Debug Logging
            GUI.changed = false;
            var debugLoggingProp = property.FindPropertyRelative(DEBUG_LOGGING_FIELD);

            EditorGUILayout.PropertyField(debugLoggingProp, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
            if (Application.isPlaying && GUI.changed)
            {
                var activeProvider = WearableControl.Instance.ActiveProvider;
                if (activeProvider != null)
                {
                    activeProvider.ConfigureDebugLogging();
                }
            }

            EditorGUI.EndProperty();
        }
Ejemplo n.º 16
0
    //重写OnInspectorGUI方法,当激活此面板区域时调用
    public override void OnInspectorGUI()
    {
        //加入此句,不影响原在Inspector绘制的元素
        // base.OnInspectorGUI();

        //获取指定脚本对象
        m_Target           = target as BuildingSO;
        m_Target.hierarchy = EditorGUILayout.IntField("菜单中层级", m_Target.hierarchy);

        m_Target.objectName     = EditorGUILayout.DelayedTextField("建筑名称", m_Target.objectName);
        m_Target.buildingPrefab = EditorGUILayout.ObjectField("建筑预制", m_Target.buildingPrefab, typeof(GameObject), true) as GameObject;
        m_Target.lowSource      = EditorGUILayout.ObjectField("预览图", m_Target.lowSource, typeof(Sprite), true) as Sprite;
        m_Target.buildTime      = EditorGUILayout.FloatField("建造时间", m_Target.buildTime);
        //EditorGUILayout.PropertyField(cost,true);
        m_Target.dTime   = EditorGUILayout.FloatField("拆除时间", m_Target.dTime);
        m_Target.durable = EditorGUILayout.FloatField("耐久", m_Target.durable);

        m_Target.type = (BuildingSO.BuildType)EditorGUILayout.EnumFlagsField("特殊类型", m_Target.type);
        if (m_Target.type == BuildingSO.BuildType.collect)
        {
            m_Target.res = (ResourceType.AttributionType)EditorGUILayout.EnumFlagsField("采集的资源", m_Target.res);
            //  m_Target.res = EditorGUILayout.ObjectField("采集的资源", m_Target.res, typeof(ResourceType), true) as ResourceType;
            m_Target.collectNum      = EditorGUILayout.IntField("每个循环采集数量", m_Target.collectNum);
            m_Target.collectInterval = EditorGUILayout.FloatField("采集间隔", m_Target.collectInterval);
        }

        m_Target.showPosition = EditorGUILayout.BeginFoldoutHeaderGroup(m_Target.showPosition, "建造费用");
        if (m_Target.showPosition)
        {
            m_Target.costLength = EditorGUILayout.IntField("需资源种类数量", m_Target.costLength);
            if (m_Target.costLength > 0)
            {
                if (m_Target.costc == null)
                {
                    m_Target.costc = new BuildingSO.ResourcePrefab[m_Target.costLength];
                }
                else
                {
                    BuildingSO.ResourcePrefab[] c = new BuildingSO.ResourcePrefab[m_Target.costLength];
                    m_Target.costc.CopyTo(c, 0);
                    m_Target.costc = c;
                }

                for (int i = 0; i < m_Target.costLength; i++)
                {
                    m_Target.costc[i].type = EditorGUILayout.ObjectField("资源种类", m_Target.costc[i].type, typeof(ResourceType), true) as ResourceType;
                    m_Target.costc[i].num  = EditorGUILayout.IntField("资源数量", m_Target.costc[i].num);
                }
                if (m_Target.cost == null)
                {
                    m_Target.cost = new Dictionary <string, int>();
                }
                else
                {
                    m_Target.cost.Clear();
                }
                foreach (var c in m_Target.costc)
                {
                    if (c.type != null)
                    {
                        m_Target.cost.Add(c.type.resName, c.num);
                    }
                }
            }
            // showPosition = !showPosition;
        }
        //  EditorGUILayout.EndFoldoutHeaderGroup();
    }
Ejemplo n.º 17
0
    private JsonData CharacterModelPanel()
    {
        ObjectJsonData = CharacterModelList[selectedIndex];

        // 获得对应技能类
        Type characterModelClass = GetTypeWithAnotherAsm("CharacterModel");

        // 反射获得其所有属性
        PropertyInfo[] propertyInfos = characterModelClass.GetProperties();
        foreach (var propertyInfo in propertyInfos)
        {
            if (propertyInfo.GetSetMethod() == null)
            {
                continue;
            }

            if (propertyInfo.PropertyType == typeof(string))
            {
                if (!propertyInfo.Name.Contains("Description"))
                {
                    ObjectJsonData[propertyInfo.Name] = EditorGUILayout.TextField(propertyInfo.Name, ObjectJsonData.Get(propertyInfo.Name).ToString());
                }
                else
                {
                    EditorGUILayout.LabelField(propertyInfo.Name + ":");
                    ObjectJsonData[propertyInfo.Name] = EditorGUILayout.TextArea(ObjectJsonData.Get(propertyInfo.Name).ToString());
                }
                if (propertyInfo.Name.Contains("Name"))
                {
                    s[selectedIndex] = selectedIndex + ":" + CharacterModelList[selectedIndex][propertyInfo.Name].ToString();
                }
            }
            if (propertyInfo.PropertyType == typeof(float))
            {
                ObjectJsonData[propertyInfo.Name] = EditorGUILayout.FloatField(propertyInfo.Name, (float)(double)ObjectJsonData.Get(propertyInfo.Name, type: typeof(float)));
            }
            if (propertyInfo.PropertyType == typeof(int))
            {
                ObjectJsonData[propertyInfo.Name] = EditorGUILayout.IntField(propertyInfo.Name, (int)ObjectJsonData.Get(propertyInfo.Name, typeof(int)));
            }

            // 对整形数组的处理
            if (propertyInfo.PropertyType.IsArray && propertyInfo.PropertyType.GetElementType() == typeof(int))
            {
            }

            // 对技能列表的处理
            if (propertyInfo.PropertyType == typeof(List <BaseSkill>))
            {
                EditorGUILayout.LabelField("========List<BaseSkill>=========================");
                int maxCount = 1;
                try {
                    maxCount = ObjectJsonData[propertyInfo.Name].Count;
                } catch (Exception e) {
                    ObjectJsonData[propertyInfo.Name] = new JsonData();
                    ObjectJsonData[propertyInfo.Name].Add(0);
                }

                Debug.Log("maxCount:" + maxCount);

                if (GUILayout.Button("增加技能"))
                {
                    ObjectJsonData[propertyInfo.Name].Add(0);
                }

                for (int i = 0; i < maxCount; i++)
                {
                    ObjectJsonData[propertyInfo.Name][i] = EditorGUILayout.Popup((int)ObjectJsonData[propertyInfo.Name].Get(i, typeof(int)), GetAllSkillName());
                }

                EditorGUILayout.LabelField("============================================");
            }

            if (propertyInfo.PropertyType.BaseType == typeof(Enum))
            {
                if (propertyInfo.Name.Contains("TargetType"))
                {
                    // 多重枚举
                    ObjectJsonData[propertyInfo.Name] = (int)(UnitType)EditorGUILayout.EnumFlagsField(propertyInfo.Name, (UnitType)(int)ObjectJsonData.Get(propertyInfo.Name, typeof(int)));
                }
                else
                {
                    // 普通枚举
                    ObjectJsonData[propertyInfo.Name] = (int)(Enum.ToObject(propertyInfo.PropertyType, EditorGUILayout.EnumPopup(propertyInfo.Name, (Enum)Enum.ToObject(propertyInfo.PropertyType, (int)ObjectJsonData.Get(propertyInfo.Name, typeof(int))))));
                }
            }
        }
        return(ObjectJsonData);
    }
Ejemplo n.º 18
0
        private bool DrawField(Type type, ref object field, params GUILayoutOption[] options)
        {
            bool   datapointer = false;
            object newfield    = field;

            if (type == typeof(int))
            {
                newfield = EditorGUILayout.IntField((int)field, options);
            }
            else if (type == typeof(float))
            {
                newfield = EditorGUILayout.FloatField((float)field, options);
            }
            else if (type == typeof(double))
            {
                newfield = EditorGUILayout.DoubleField((double)field, options);
            }
            else if (type == typeof(long))
            {
                newfield = EditorGUILayout.LongField((long)field, options);
            }
            else if (type == typeof(Bounds))
            {
                newfield = EditorGUILayout.BoundsField((Bounds)field, options);
            }
            else if (type == typeof(Color))
            {
                newfield = EditorGUILayout.ColorField((Color)field, options);
            }
            else if (type == typeof(AnimationCurve))
            {
                newfield = EditorGUILayout.CurveField((AnimationCurve)field, options);
            }
            else if (type.IsEnum && type.GetCustomAttributes(typeof(FlagsAttribute), false).Any())
            {
                newfield = EditorGUILayout.EnumFlagsField("", (Enum)field, options);
            }
            else if (type.IsEnum)
            {
                newfield = EditorGUILayout.EnumPopup((Enum)field, options);
            }
            else if (type == typeof(Gradient))
            {
                newfield = EditorGUILayout.GradientField((Gradient)field, options);
            }
            else if (type == typeof(LayerMask))
            {
                newfield = EditorGUILayout.LayerField((LayerMask)field, options);
            }
            else if (typeof(DataTablePointer).IsAssignableFrom(type))
            {
                datapointer = DataTablePointerInspector.DrawStandalone((DataTablePointer)field);
            }
            else if (typeof(UnityEngine.Object).IsAssignableFrom(type))
            {
                newfield = EditorGUILayout.ObjectField((UnityEngine.Object)field, type, false, options);
            }
            else if (type == typeof(Rect))
            {
                newfield = EditorGUILayout.RectField((Rect)field, options);
            }
            else if (type == typeof(RectInt))
            {
                newfield = EditorGUILayout.RectIntField((RectInt)field, options);
            }
            else if (type == typeof(string))
            {
                newfield = EditorGUILayout.TextField((string)field, options);
            }
            else if (type == typeof(Vector2))
            {
                newfield = EditorGUILayout.Vector2Field("", (Vector2)field, options);
            }
            else if (type == typeof(Vector2Int))
            {
                newfield = EditorGUILayout.Vector2IntField("", (Vector2Int)field, options);
            }
            else if (type == typeof(Vector3))
            {
                newfield = EditorGUILayout.Vector3Field("", (Vector3)field, options);
            }
            else if (type == typeof(Vector3Int))
            {
                newfield = EditorGUILayout.Vector3IntField("", (Vector3Int)field, options);
            }
            else if (type == typeof(Vector4))
            {
                newfield = EditorGUILayout.Vector4Field("", (Vector4)field, options);
            }
            else
            {
                EditorGUILayout.LabelField("[Unable to edit]", options);
            }

            if (newfield != field)
            {
                field = newfield;
                return(true);
            }
            if (datapointer)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 19
0
 void OnGUI()
 {
     AgentType = (AgentCategory.eType)EditorGUILayout.EnumFlagsField("Type of this entity", AgentType);
 }
Ejemplo n.º 20
0
        void DrawHitBoxesList(vMeleeAttackObject attackObject)
        {
            if (attackObject != null && attackObject.hitBoxes != null)
            {
                for (int i = 0; i < attackObject.hitBoxes.Count; i++)
                {
                    try
                    {
                        GUILayout.BeginHorizontal();
                        if (attackObject.hitBoxes[i] != null && attackObject.hitBoxes[i].transform == attackObject.transform ||
                            (attackObject.GetComponent <vHitBox>() != null))
                        {
                            DestroyImmediate(attackObject.GetComponent <vHitBox>());
                            attackObject.hitBoxes.RemoveAt(i);
                            GUILayout.EndHorizontal();
                            break;
                        }
                        Color color = GUI.color;
                        GUI.color = seletedHitboxIndex == i ? new Color(1, 1, 0, 0.6f) : color;

                        if (GUILayout.Button("Hit Box " + (i + 1), EditorStyles.miniButton))
                        {
                            if (seletedHitboxIndex == i)
                            {
                                seletedHitboxIndex = -1;
                            }
                            else
                            {
                                seletedHitboxIndex = i;
                            }
                        }
                        GUI.color = color;
                        if (attackObject.hitBoxes.Count > 1 && GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20)))
                        {
                            if (attackObject.hitBoxes[i] != null && attackObject.hitBoxes[i].transform != attackObject.transform)
                            {
                                DestroyImmediate(attackObject.hitBoxes[i].gameObject);
                            }
                            attackObject.hitBoxes.RemoveAt(i);
                            GUILayout.EndHorizontal();
                            break;
                        }
                        GUILayout.EndHorizontal();
                    }
                    catch { }
                }
            }

            if (seletedHitboxIndex > -1 && seletedHitboxIndex < attackObject.hitBoxes.Count)
            {
                GUILayout.BeginVertical("box");
                var hitBox = attackObject.hitBoxes[seletedHitboxIndex];
                if (hitBox)
                {
                    EditorGUILayout.ObjectField("Selected Hit Box " + (seletedHitboxIndex + 1), hitBox, typeof(vHitBox), true);
                    //GUILayout.Box("Hit Settings", GUILayout.ExpandWidth(true));
                    hitBox.damagePercentage = EditorGUILayout.IntSlider("Damage Percentage", hitBox.damagePercentage, 0, 100);
#if UNITY_2017_3_OR_NEWER
                    hitBox.triggerType = (vHitBoxType)EditorGUILayout.EnumFlagsField("Trigger Type", hitBox.triggerType);
#else
                    hitBox.triggerType = (vHitBoxType)EditorGUILayout.EnumMaskField("Trigger Type", hitBox.triggerType);
#endif
                    if (GUI.changed)
                    {
                        EditorUtility.SetDirty(hitBox);
                    }
                }
                GUILayout.EndVertical();
            }

            GUILayout.Space(10);

            if (!inCreateHitBox && GUILayout.Button("Create New Hit Box", EditorStyles.miniButton))
            {
                inCreateHitBox   = true;
                damagePercentage = 100;
                triggerType      = vHitBoxType.Damage | vHitBoxType.Recoil;
            }
            if (inCreateHitBox)
            {
                GUILayout.Box("New Hit Box", GUILayout.ExpandWidth(true));
                damagePercentage = EditorGUILayout.IntSlider("Damage Percentage", damagePercentage, 0, 100);

#if UNITY_2017_3_OR_NEWER
                triggerType = (vHitBoxType)EditorGUILayout.EnumFlagsField("Trigger Type", triggerType);
#else
                triggerType = (vHitBoxType)EditorGUILayout.EnumMaskField("Trigger Type", triggerType);
#endif

                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Create", EditorStyles.miniButton, GUILayout.ExpandWidth(true)))
                {
                    var type      = typeof(BoxCollider);
                    var hitObject = new GameObject("hitBox", typeof(vHitBox), type);
                    hitObject.transform.localScale       = Vector3.one * 0.2f;
                    hitObject.transform.parent           = attackObject.transform;
                    hitObject.transform.localPosition    = Vector3.zero;
                    hitObject.transform.localEulerAngles = Vector3.zero;
                    var hitBox = hitObject.GetComponent <vHitBox>();
                    hitBox.damagePercentage = damagePercentage;
                    hitBox.triggerType      = triggerType;
                    attackObject.hitBoxes.Add(hitBox);
                    inCreateHitBox = false;
                }

                if (GUILayout.Button("Cancel", EditorStyles.miniButton, GUILayout.ExpandWidth(true)))
                {
                    inCreateHitBox = false;
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(10);
        }
Ejemplo n.º 21
0
 static void DrawGeneralAdvancedContent(SerializedHDLight serialized, Editor owner)
 {
     using (new EditorGUI.DisabledScope(!HDUtils.hdrpSettings.supportLightLayers))
     {
         serialized.serializedLightData.lightLayers.intValue = Convert.ToInt32(EditorGUILayout.EnumFlagsField(s_Styles.lightLayer, (LightLayerEnum)serialized.serializedLightData.lightLayers.intValue));
     }
 }
Ejemplo n.º 22
0
 void OnGUI()
 {
     PreferredTargets   = (AgentCategory.eType)EditorGUILayout.EnumFlagsField("Preferred Targets", PreferredTargets);
     DiscouragedTargets = (AgentCategory.eType)EditorGUILayout.EnumFlagsField("Discouraged Targets", DiscouragedTargets);
 }
Ejemplo n.º 23
0
 public static System.Enum CreateEnumFlagsField(string fieldName, System.Enum value)
 {
     return(EditorGUILayout.EnumFlagsField(value));
 }
		///Draws an Editor field for object of type directly
		public static object DrawEditorFieldDirect(GUIContent content, object value, Type t, FieldInfo field = null, object context = null, object[] attributes = null){
			
			if ( typeof(UnityObject).IsAssignableFrom(t) == false && t != typeof(Type) ) {
				//Check abstract
				if ( (value != null && value.GetType().IsAbstract) || (value == null && t.IsAbstract) ){
					EditorGUILayout.LabelField(content, new GUIContent(string.Format("Abstract ({0})", t.FriendlyName()) ) );
					return value;
				}

				//Auto create instance for some types
				if (value == null && t != typeof(object) && !t.IsAbstract && !t.IsInterface){
					if (t.GetConstructor(Type.EmptyTypes) != null || t.IsArray){
						if (t.IsArray){ value = Array.CreateInstance(t.GetElementType(), 0); }
						else { value = Activator.CreateInstance(t); }
					}
				}
			}

			//Check the type
            if ( typeof(UnityObject).IsAssignableFrom(t) ) {
                if (t == typeof(Component) && (value is Component)){
                    return ComponentField(content, (Component)value, typeof(Component));
                }
                return EditorGUILayout.ObjectField(content, (UnityObject)value, t, true);
		    }

			if (t == typeof(Type)){
				return Popup<Type>(content, (Type)value, UserTypePrefs.GetPreferedTypesList(true) );
			}

            if (t == typeof(string)){
				return EditorGUILayout.TextField(content, (string)value);
			}

			if (t == typeof(char)){
				var c = (char)value;
				var s = c.ToString();
				s = EditorGUILayout.TextField(content, s);
				return string.IsNullOrEmpty(s)? (char)c : (char)s[0];
			}

			if (t == typeof(bool)){
				return EditorGUILayout.Toggle(content, (bool)value);
			}

			if (t == typeof(int)){
				return EditorGUILayout.IntField(content, (int)value);
			}

			if (t == typeof(float)){
				return EditorGUILayout.FloatField(content, (float)value);
			}

			if (t == typeof(byte)){
				return Convert.ToByte( Mathf.Clamp(EditorGUILayout.IntField(content, (byte)value), 0, 255) );
			}

			if (t == typeof(Vector2)){
				return EditorGUILayout.Vector2Field(content, (Vector2)value);
			}

			if (t == typeof(Vector3)){
				return EditorGUILayout.Vector3Field(content, (Vector3)value);
			}

			if (t == typeof(Vector4)){
				return EditorGUILayout.Vector4Field(content, (Vector4)value);
			}

			if (t == typeof(Quaternion)){
				var quat = (Quaternion)value;
				var vec4 = new Vector4(quat.x, quat.y, quat.z, quat.w);
				vec4 = EditorGUILayout.Vector4Field(content, vec4);
				return new Quaternion(vec4.x, vec4.y, vec4.z, vec4.w);
			}

			if (t == typeof(Color)){
				return EditorGUILayout.ColorField(content, (Color)value);
			}

			if (t == typeof(Rect)){
				return EditorGUILayout.RectField(content, (Rect)value);
			}

			if (t == typeof(AnimationCurve)){
				return EditorGUILayout.CurveField(content, (AnimationCurve)value);
			}

			if (t == typeof(Bounds)){
				return EditorGUILayout.BoundsField(content, (Bounds)value);
			}

			if (t == typeof(LayerMask)){
				return LayerMaskField(content, (LayerMask)value);
			}
            
			if (t.IsSubclassOf(typeof(System.Enum))){
				if (t.IsDefined(typeof(FlagsAttribute), true)){
					return EditorGUILayout.EnumFlagsField(content, (System.Enum)value);
				}
				return EditorGUILayout.EnumPopup(content, (System.Enum)value);
			}

			if (typeof(IList).IsAssignableFrom(t)){
				return ListEditor(content, (IList)value, t, field, context, attributes);
			}

			if (typeof(IDictionary).IsAssignableFrom(t)){
				return DictionaryEditor(content, (IDictionary)value, t, field, context, attributes);
			}

			//show nested class members recursively
			if (value != null && (t.IsClass || t.IsValueType)){
				
				if (EditorGUI.indentLevel <= 8){
					GUILayout.BeginVertical();
					EditorGUILayout.LabelField(content, new GUIContent( string.Format("({0})", t.FriendlyName()) ) );
					EditorGUI.indentLevel ++;
					ReflectedObjectInspector(value);
					EditorGUI.indentLevel --;
					GUILayout.EndVertical();
				}
		
			} else {

				EditorGUILayout.LabelField(content, new GUIContent(string.Format("NonInspectable ({0})", t.FriendlyName()) ) );
			}
			
			return value;
		}
Ejemplo n.º 25
0
        void DrawStyles()
        {
            GUILayout.Space(14);
            GUILayout.Label("Rendering");

            // Opacity
            DrawNullableRow(CurrentStyle.opacity.HasValue, (enabled) =>
            {
                var prop             = EditorGUILayout.Slider("Opacity", CurrentStyle.opacity ?? CurrentStyle.resolved.opacity, 0, 1f);
                CurrentStyle.opacity = enabled ? (float?)prop : null;
            });

            // zOrder
            DrawNullableRow(CurrentStyle.zOrder.HasValue, (enabled) =>
            {
                var prop            = EditorGUILayout.IntField("Z Order", CurrentStyle.zOrder ?? CurrentStyle.resolved.zOrder);
                CurrentStyle.zOrder = enabled ? (int?)prop : null;
            });

            // Opacity
            DrawNullableRow(CurrentStyle.hidden.HasValue, (enabled) =>
            {
                var prop            = EditorGUILayout.Toggle("Hidden", CurrentStyle.hidden ?? CurrentStyle.resolved.hidden);
                CurrentStyle.hidden = enabled ? (bool?)prop : null;
            });

            // Interaction
            DrawNullableRow(CurrentStyle.interaction.HasValue, (enabled) =>
            {
                var prop = EditorGUILayout.EnumPopup("Interaction", CurrentStyle.interaction ?? CurrentStyle.resolved.interaction);
                CurrentStyle.interaction = enabled ? (InteractionType?)prop : null;
            });



            GUILayout.Space(14);

            // Box Shadow
            DrawNullableRow(CurrentStyle.boxShadow != null, (enabled) =>
            {
                EditorGUILayout.BeginVertical();
                GUILayout.Label("Box Shadow");

                if (!enabled)
                {
                    CurrentStyle.boxShadow = null;
                }
                else
                {
                    CurrentStyle.boxShadow = CurrentStyle.boxShadow ?? new ShadowDefinition();
                }

                var tempShadow = CurrentStyle.boxShadow ?? new ShadowDefinition();

                tempShadow.blur   = EditorGUILayout.FloatField("Blur", CurrentStyle.boxShadow?.blur ?? 0);
                tempShadow.offset = EditorGUILayout.Vector2Field("Offset", CurrentStyle.boxShadow?.offset ?? Vector2.zero);
                tempShadow.spread = EditorGUILayout.Vector2Field("Spread", CurrentStyle.boxShadow?.spread ?? Vector2.zero);
                tempShadow.color  = EditorGUILayout.ColorField("Color", CurrentStyle.boxShadow?.color ?? Color.black);

                EditorGUILayout.EndVertical();
            });


            GUILayout.Space(14);
            GUILayout.Label("Graphic");


            // Background color
            DrawNullableRow(CurrentStyle.backgroundColor.HasValue, (enabled) =>
            {
                var prop = EditorGUILayout.ColorField("Background color",
                                                      CurrentStyle.backgroundColor ?? CurrentStyle.resolved.backgroundColor ?? Color.white);
                CurrentStyle.backgroundColor = enabled ? (Color?)prop : null;
            });



            // Border Width
            DrawFloatRowWithNaN(CurrentLayout.BorderWidth, 0, (enabled, appropriateValue) =>
            {
                var prop2 = EditorGUILayout.IntField("Border Width", (int)appropriateValue);
                CurrentLayout.BorderWidth = enabled ? prop2 : float.NaN;
            });

            // Border color
            DrawNullableRow(CurrentStyle.borderColor.HasValue, (enabled) =>
            {
                var prop = EditorGUILayout.ColorField("Border color", CurrentStyle.borderColor ?? CurrentStyle.resolved.borderColor ?? Color.black);
                CurrentStyle.borderColor = enabled ? (Color?)prop : null;
            });

            // Border radius
            DrawNullableRow(CurrentStyle.borderRadius.HasValue, (enabled) =>
            {
                var prop = EditorGUILayout.IntField("Border radius", CurrentStyle.borderRadius ?? CurrentStyle.resolved.borderRadius);
                CurrentStyle.borderRadius = enabled ? (int?)prop : null;
            });


            GUILayout.Space(14);
            GUILayout.Label("Font");

            // Font size
            GUILayout.BeginHorizontal();
            GUILayout.Label("Font size", GUILayout.Width(150));
            CurrentStyle.fontSize = DrawYogaValue(CurrentStyle.fontSize);
            GUILayout.EndHorizontal();

            // Font style
            DrawNullableRow(CurrentStyle.fontStyle.HasValue, (enabled) =>
            {
                var prop = EditorGUILayout.EnumFlagsField("Font style", CurrentStyle.fontStyle ?? CurrentStyle.resolved.fontStyle);
                CurrentStyle.fontStyle = enabled ? (FontStyles?)prop : null;
            });

            // Text Overflow
            DrawNullableRow(CurrentStyle.textOverflow.HasValue, (enabled) =>
            {
                var prop = EditorGUILayout.EnumPopup("Text Overflow", CurrentStyle.textOverflow ?? CurrentStyle.resolved.textOverflow);
                CurrentStyle.textOverflow = enabled ? (TextOverflowModes?)prop : null;
            });

            // Font color
            DrawNullableRow(CurrentStyle.fontColor.HasValue, (enabled) =>
            {
                var prop = EditorGUILayout.ColorField("Font color", CurrentStyle.fontColor ?? CurrentStyle.resolved.fontColor);
                CurrentStyle.fontColor = enabled ? (Color?)prop : null;
            });

            // Text wrap
            DrawNullableRow(CurrentStyle.textWrap.HasValue, (enabled) =>
            {
                var prop = EditorGUILayout.Toggle("Text wrap", CurrentStyle.textWrap ?? CurrentStyle.resolved.textWrap);
                CurrentStyle.textWrap = enabled ? (bool?)prop : null;
            });

            // Direction
            var prop1 = EditorGUILayout.EnumPopup("Direction", CurrentLayout.StyleDirection);

            CurrentLayout.StyleDirection = (YogaDirection)prop1;



            GUILayout.Space(14);
            GUILayout.Label("Transform");

            // Translate
            DrawNullableRow(CurrentStyle.translate.HasValue, (enabled) =>
            {
                var prop = EditorGUILayout.Vector2Field("Translate", CurrentStyle.translate ?? CurrentStyle.resolved.translate);
                CurrentStyle.translate = enabled ? (Vector2?)prop : null;
            });

            // Translate Relative
            DrawNullableRow(CurrentStyle.translateRelative.HasValue, (enabled) =>
            {
                var prop = EditorGUILayout.Toggle("Translate relative", CurrentStyle.translateRelative ?? CurrentStyle.resolved.translateRelative);
                CurrentStyle.translateRelative = enabled ? (bool?)prop : null;
            });

            // Pivot
            DrawNullableRow(CurrentStyle.pivot.HasValue, (enabled) =>
            {
                var prop           = EditorGUILayout.Vector2Field("Pivot", CurrentStyle.pivot ?? CurrentStyle.resolved.pivot);
                CurrentStyle.pivot = enabled ? (Vector2?)prop : null;
            });

            // Scale
            DrawNullableRow(CurrentStyle.scale.HasValue, (enabled) =>
            {
                var prop           = EditorGUILayout.Vector2Field("Scale", CurrentStyle.scale ?? CurrentStyle.resolved.scale);
                CurrentStyle.scale = enabled ? (Vector2?)prop : null;
            });

            // Rotation
            DrawNullableRow(CurrentStyle.rotate.HasValue, (enabled) =>
            {
                var prop            = EditorGUILayout.FloatField("Rotation", CurrentStyle.rotate ?? CurrentStyle.resolved.rotate);
                CurrentStyle.rotate = enabled ? (float?)prop : null;
            });
        }
Ejemplo n.º 26
0
 public override void OnInspectorGUI()
 {
     inst.surfaceType = (Surface.SurfaceType)EditorGUILayout.EnumPopup("Surface Type", inst.surfaceType);
     inst.driveType   = (Surface.DriveType)EditorGUILayout.EnumFlagsField("Drive Type(s)", inst.driveType);
 }
Ejemplo n.º 27
0
        //...
        public static object DirectFieldControl(GUIContent content, object value, Type t, UnityEngine.Object unityObjectContext, object[] attributes, out bool handled, params GUILayoutOption[] options)
        {
            handled = true;

            //Check scene object type for UnityObjects. Consider Interfaces as scene object type. Assume that user uses interfaces with UnityObjects
            if (typeof(UnityObject).IsAssignableFrom(t) || t.IsInterface)
            {
                if (value == null || value is UnityObject)     //check this to avoid case of interface but no unityobject
                {
                    var isSceneObjectType = (typeof(Component).IsAssignableFrom(t) || t == typeof(GameObject) || t.IsInterface);
                    var newValue          = EditorGUILayout.ObjectField(content, (UnityObject)value, t, isSceneObjectType, options);
                    if (unityObjectContext != null && newValue != null)
                    {
                        if (!Application.isPlaying && EditorUtility.IsPersistent(unityObjectContext) && !EditorUtility.IsPersistent(newValue as UnityEngine.Object))
                        {
                            ParadoxNotion.Services.Logger.LogWarning("Assets can not have scene object references", "Editor", unityObjectContext);
                            newValue = value as UnityObject;
                        }
                    }
                    return(newValue);
                }
            }

            //Check Type second
            if (t == typeof(Type))
            {
                return(Popup <Type>(content, (Type)value, TypePrefs.GetPreferedTypesList(true), options));
            }

            //get real current type
            t = value != null?value.GetType() : t;

            //for these just show type information
            if (t.IsAbstract || t == typeof(object) || typeof(Delegate).IsAssignableFrom(t) || typeof(UnityEngine.Events.UnityEventBase).IsAssignableFrom(t))
            {
                EditorGUILayout.LabelField(content, new GUIContent(string.Format("({0})", t.FriendlyName())), options);
                return(value);
            }

            //create instance for value types
            if (value == null && t.RTIsValueType())
            {
                value = System.Activator.CreateInstance(t);
            }

            //create new instance with button for non value types
            if (value == null && !t.IsAbstract && !t.IsInterface && (t.IsArray || t.GetConstructor(Type.EmptyTypes) != null))
            {
                if (content != GUIContent.none)
                {
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel(content, GUI.skin.button);
                }
                if (GUILayout.Button("(null) Create", options))
                {
                    value = t.IsArray ? Array.CreateInstance(t.GetElementType(), 0) : Activator.CreateInstance(t);
                }
                if (content != GUIContent.none)
                {
                    GUILayout.EndHorizontal();
                }
                return(value);
            }


            ///----------------------------------------------------------------------------------------------


            if (t == typeof(string))
            {
                return(EditorGUILayout.TextField(content, (string)value, options));
            }

            if (t == typeof(char))
            {
                var c = (char)value;
                var s = c.ToString();
                s = EditorGUILayout.TextField(content, s, options);
                return(string.IsNullOrEmpty(s) ? (char)c : (char)s[0]);
            }

            if (t == typeof(bool))
            {
                return(EditorGUILayout.Toggle(content, (bool)value, options));
            }

            if (t == typeof(int))
            {
                return(EditorGUILayout.IntField(content, (int)value, options));
            }

            if (t == typeof(float))
            {
                return(EditorGUILayout.FloatField(content, (float)value, options));
            }

            if (t == typeof(byte))
            {
                return(Convert.ToByte(Mathf.Clamp(EditorGUILayout.IntField(content, (byte)value, options), 0, 255)));
            }

            if (t == typeof(long))
            {
                return(EditorGUILayout.LongField(content, (long)value, options));
            }

            if (t == typeof(double))
            {
                return(EditorGUILayout.DoubleField(content, (double)value, options));
            }

            if (t == typeof(Vector2))
            {
                return(EditorGUILayout.Vector2Field(content, (Vector2)value, options));
            }

            if (t == typeof(Vector2Int))
            {
                return(EditorGUILayout.Vector2IntField(content, (Vector2Int)value, options));
            }

            if (t == typeof(Vector3))
            {
                return(EditorGUILayout.Vector3Field(content, (Vector3)value, options));
            }

            if (t == typeof(Vector3Int))
            {
                return(EditorGUILayout.Vector3IntField(content, (Vector3Int)value, options));
            }

            if (t == typeof(Vector4))
            {
                return(EditorGUILayout.Vector4Field(content, (Vector4)value, options));
            }

            if (t == typeof(Quaternion))
            {
                var quat = (Quaternion)value;
                var vec4 = new Vector4(quat.x, quat.y, quat.z, quat.w);
                vec4 = EditorGUILayout.Vector4Field(content, vec4, options);
                return(new Quaternion(vec4.x, vec4.y, vec4.z, vec4.w));
            }

            if (t == typeof(Color))
            {
                var att       = attributes?.FirstOrDefault(a => a is ColorUsageAttribute) as ColorUsageAttribute;
                var hdr       = att != null ? att.hdr : false;
                var showAlpha = att != null ? att.showAlpha : true;
                return(EditorGUILayout.ColorField(content, (Color)value, true, showAlpha, hdr, options));
            }

            if (t == typeof(Gradient))
            {
                return(EditorGUILayout.GradientField(content, (Gradient)value, options));
            }

            if (t == typeof(Rect))
            {
                return(EditorGUILayout.RectField(content, (Rect)value, options));
            }

            if (t == typeof(AnimationCurve))
            {
                return(EditorGUILayout.CurveField(content, (AnimationCurve)value, options));
            }

            if (t == typeof(Bounds))
            {
                return(EditorGUILayout.BoundsField(content, (Bounds)value, options));
            }

            if (t == typeof(LayerMask))
            {
                return(LayerMaskField(content, (LayerMask)value, options));
            }

            if (t.IsSubclassOf(typeof(System.Enum)))
            {
                if (t.RTIsDefined(typeof(FlagsAttribute), true))
                {
                    return(EditorGUILayout.EnumFlagsField(content, (System.Enum)value, options));
                }
                return(EditorGUILayout.EnumPopup(content, (System.Enum)value, options));
            }

            handled = false;
            return(value);
        }
Ejemplo n.º 28
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        EditorGUI.BeginChangeCheck();

        enemyInfo.lifeState = (LifeState)EditorGUILayout.EnumFlagsField("LifeState", enemyInfo.lifeState);

        #region 链表-ActionTypeList0
        EditorGUI.indentLevel++;                                                                                     //缩进
        EditorGUILayout.BeginVertical(EditorStyles.helpBox);                                                         //白色方框,一般框住help文本内容
        {                                                                                                            //只是方便观看,没有实际作用
            openList0 = EditorGUILayout.Foldout(openList0, "BaseActionTypeList (" + baseActionTypeList.count + ")"); //收缩扩展框:有个小三角,朝右是收缩,朝下是展开

            if (openList0)
            {
                baseActionTypeList.DoLayoutList();//展开时显示列表
            }
        }
        EditorGUILayout.EndVertical();
        EditorGUI.indentLevel--;
        #endregion

        #region 链表-ActionTypeList1
        EditorGUI.indentLevel++;                                                                                                     //缩进
        EditorGUILayout.BeginVertical(EditorStyles.helpBox);                                                                         //白色方框,一般框住help文本内容
        {                                                                                                                            //只是方便观看,没有实际作用
            openList1 = EditorGUILayout.Foldout(openList1, "IntermediateActionTypeList (" + intermediateActionTypeList.count + ")"); //收缩扩展框:有个小三角,朝右是收缩,朝下是展开

            if (openList1)
            {
                intermediateActionTypeList.DoLayoutList();//展开时显示列表
            }
        }
        EditorGUILayout.EndVertical();
        EditorGUI.indentLevel--;
        #endregion

        #region 链表-ActionTypeList2
        EditorGUI.indentLevel++;                                                                                             //缩进
        EditorGUILayout.BeginVertical(EditorStyles.helpBox);                                                                 //白色方框,一般框住help文本内容
        {                                                                                                                    //只是方便观看,没有实际作用
            openList2 = EditorGUILayout.Foldout(openList2, "AdvancedActionTypeList (" + advancedActionTypeList.count + ")"); //收缩扩展框:有个小三角,朝右是收缩,朝下是展开

            if (openList2)
            {
                advancedActionTypeList.DoLayoutList();//展开时显示列表
            }
        }
        EditorGUILayout.EndVertical();
        EditorGUI.indentLevel--;
        #endregion

        #region 链表-PropertyList
        EditorGUILayout.BeginVertical(EditorStyles.helpBox);                                             //白色方框,一般框住help文本内容
        EditorGUI.indentLevel++;                                                                         //缩进
        {                                                                                                //只是方便观看,没有实际作用
            openList3 = EditorGUILayout.Foldout(openList3, "PropertyList (" + propertyList.count + ")"); //收缩扩展框:有个小三角,朝右是收缩,朝下是展开

            if (openList3)
            {
                propertyList.DoLayoutList();//展开时显示列表
            }
        }
        EditorGUI.indentLevel--;
        EditorGUILayout.EndVertical();
        #endregion

        if (EditorGUI.EndChangeCheck())     //与EditorGUI.BeginChangeCheck();对应
        {
            EditorUtility.SetDirty(target); //生成配置表
        }

        serializedObject.ApplyModifiedProperties();//同意配置
    }
Ejemplo n.º 29
0
        static void PreferencesGUI()
        {
            LoadPrefs();

            EditorGUIUtility.labelWidth = 200f;

            s_SettingsScroll = EditorGUILayout.BeginScrollView(s_SettingsScroll);

            EditorGUI.BeginChangeCheck();

            if (GUILayout.Button("Reset All Preferences"))
            {
                ResetToDefaults();
            }

            /**
             * GENERAL SETTINGS
             */
            GUILayout.Label("General Settings", EditorStyles.boldLabel);

            pbStripProBuilderOnBuild =
                EditorGUILayout.Toggle(
                    new GUIContent("Strip PB Scripts on Build",
                                   "If true, when building an executable all ProBuilder scripts will be stripped from your built product."),
                    pbStripProBuilderOnBuild);
            pbDisableAutoUV2Generation = EditorGUILayout.Toggle(
                new GUIContent("Disable Auto UV2 Generation",
                               "Disables automatic generation of UV2 channel.  If Unity is sluggish when working with large ProBuilder objects, disabling UV2 generation will improve performance.  Use `Actions/Generate UV2` or `Actions/Generate Scene UV2` to build lightmap UVs prior to baking."),
                pbDisableAutoUV2Generation);
            pbShowSceneInfo =
                EditorGUILayout.Toggle(
                    new GUIContent("Show Scene Info", "Displays the selected object vertex and triangle counts in the scene view."),
                    pbShowSceneInfo);
            pbShowEditorNotifications = EditorGUILayout.Toggle("Show Editor Notifications", pbShowEditorNotifications);

            /**
             * TOOLBAR SETTINGS
             */
            GUILayout.Label("Toolbar Settings", EditorStyles.boldLabel);

            pbIconGUI = EditorGUILayout.Toggle(
                new GUIContent("Use Icon GUI", "Toggles the ProBuilder window interface between text and icon versions."),
                pbIconGUI);
            pbShiftOnlyTooltips =
                EditorGUILayout.Toggle(new GUIContent("Shift Key Tooltips", "Tooltips will only show when the Shift key is held"),
                                       pbShiftOnlyTooltips);
            pbToolbarLocation = (SceneToolbarLocation)EditorGUILayout.EnumPopup("Toolbar Location", pbToolbarLocation);

            pbUniqueModeShortcuts = EditorGUILayout.Toggle(
                new GUIContent("Unique Mode Shortcuts",
                               "When off, the G key toggles between Object and Element modes and H enumerates the element modes.  If on, G, H, J, and K are shortcuts to Object, Vertex, Edge, and Face modes respectively."),
                pbUniqueModeShortcuts);
            defaultOpenInDockableWindow = EditorGUILayout.Toggle("Open in Dockable Window", defaultOpenInDockableWindow);

            /**
             * DEFAULT SETTINGS
             */
            GUILayout.Label("Defaults", EditorStyles.boldLabel);

            pbDefaultMaterial =
                (Material)EditorGUILayout.ObjectField("Default Material", pbDefaultMaterial, typeof(Material), false);

            pbDefaultStaticFlags = (StaticEditorFlags)EditorGUILayout.EnumFlagsField("Static Flags", pbDefaultStaticFlags);

            GUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Default Collider");
            defaultColliderType = ((ColliderType)EditorGUILayout.EnumPopup((ColliderType)defaultColliderType));
            GUILayout.EndHorizontal();

            if ((ColliderType)defaultColliderType == ColliderType.MeshCollider)
            {
                pbForceConvex = EditorGUILayout.Toggle("Force Convex Mesh Collider", pbForceConvex);
            }

            GUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Shadow Casting Mode");
            pbShadowCastingMode = (ShadowCastingMode)EditorGUILayout.EnumPopup(pbShadowCastingMode);
            GUILayout.EndHorizontal();

            /**
             * HANDLE COLORS
             */
            GUILayout.Label("Handles & Colors", EditorStyles.boldLabel);

            pbUseUnityColors = EditorGUILayout.Toggle("Use Unity Colors", pbUseUnityColors);

            if (!pbUseUnityColors)
            {
                pbWireframeColor      = EditorGUILayout.ColorField("Wireframe", pbWireframeColor);
                pbPreselectionColor   = EditorGUILayout.ColorField("Preselection", pbPreselectionColor);
                faceSelectedColor     = EditorGUILayout.ColorField("Selected Face Color", faceSelectedColor);
                pbSelectedFaceDither  = EditorGUILayout.Toggle("Dither Face Overlay", pbSelectedFaceDither);
                pbUnselectedEdgeColor = EditorGUILayout.ColorField("Unselected Edge Color", pbUnselectedEdgeColor);
                pbSelectedEdgeColor   = EditorGUILayout.ColorField("Selected Edge Color", pbSelectedEdgeColor);
                vertexUnselectedColor = EditorGUILayout.ColorField("Unselected Vertex Color", vertexUnselectedColor);
                vertexSelectedColor   = EditorGUILayout.ColorField("Selected Vertex Color", vertexSelectedColor);
            }

            pbVertexHandleSize = EditorGUILayout.Slider("Vertex Size", pbVertexHandleSize, 1f, 10f);

            bool geoLine = BuiltinMaterials.geometryShadersSupported;

            GUI.enabled      = geoLine;
            pbLineHandleSize = EditorGUILayout.Slider("Line Size", geoLine ? pbLineHandleSize : 0f, 0f, 3f);
            pbWireframeSize  = EditorGUILayout.Slider("Wireframe Size", geoLine ? pbWireframeSize : 0f, 0f, 3f);
            GUI.enabled      = true;

            /**
             * MISC. SETTINGS
             */
            GUILayout.Label("Misc. Settings", EditorStyles.boldLabel);

            pbManageLightmappingStaticFlag = EditorGUILayout.Toggle(
                new GUIContent("Manage Lightmap Static Flag",
                               "Allow ProBuilder to toggle off the Lightmap Static flag when no UV2 channel is present. This prevents lighting artifacts caused by a missing UV2 channel."),
                pbManageLightmappingStaticFlag);

            showMissingLightmapUvWarning = EditorGUILayout.Toggle("Show Missing Lightmap UVs Warning", showMissingLightmapUvWarning);

            pbPBOSelectionOnly =
                EditorGUILayout.Toggle(
                    new GUIContent("Only PBO are Selectable",
                                   "If true, you will not be able to select non probuilder objects in Geometry and Texture mode"),
                    pbPBOSelectionOnly);
            pbCloseShapeWindow =
                EditorGUILayout.Toggle(
                    new GUIContent("Close shape window after building",
                                   "If true the shape window will close after hitting the build button"), pbCloseShapeWindow);

            GUILayout.Space(4);

            /**
             * GEOMETRY EDITING SETTINGS
             */
            GUILayout.Label("Geometry Editing Settings", EditorStyles.boldLabel);

            pbForceVertexPivot =
                EditorGUILayout.Toggle(
                    new GUIContent("Force Pivot to Vertex Point",
                                   "If true, new objects will automatically have their pivot point set to a vertex instead of the center."),
                    pbForceVertexPivot);
            pbForceGridPivot = EditorGUILayout.Toggle(
                new GUIContent("Force Pivot to Grid",
                               "If true, newly instantiated pb_Objects will be snapped to the nearest point on grid.  If ProGrids is present, the snap value will be used, otherwise decimals are simply rounded to whole numbers."),
                pbForceGridPivot);
            pbPerimeterEdgeBridgeOnly = EditorGUILayout.Toggle(
                new GUIContent("Bridge Perimeter Edges Only",
                               "If true, only edges on the perimeters of an object may be bridged.  If false, you may bridge any between any two edges you like."),
                pbPerimeterEdgeBridgeOnly);

            GUILayout.Space(4);

            GUILayout.Label("Experimental", EditorStyles.boldLabel);

            pbEnableExperimental = EditorGUILayout.Toggle(
                new GUIContent("Experimental Features",
                               "Enables some experimental new features that we're trying out.  These may be incomplete or buggy, so please exercise caution when making use of this functionality!"),
                pbEnableExperimental);

            pbMeshesAreAssets =
                EditorGUILayout.Toggle(
                    new GUIContent("Meshes Are Assets",
                                   "Experimental!  Instead of storing mesh data in the scene, this toggle creates a Mesh cache in the Project that ProBuilder will use."),
                    pbMeshesAreAssets);

            pbShowPreselectionHighlight = EditorGUILayout.Toggle("Show Preselection Highlight", pbShowPreselectionHighlight);

            GUILayout.Space(4);

            /**
             * UV EDITOR SETTINGS
             */
            GUILayout.Label("UV Editing Settings", EditorStyles.boldLabel);
            pbUVGridSnapValue  = EditorGUILayout.FloatField("UV Snap Increment", pbUVGridSnapValue);
            pbUVGridSnapValue  = Mathf.Clamp(pbUVGridSnapValue, .015625f, 2f);
            pbUVEditorFloating =
                EditorGUILayout.Toggle(
                    new GUIContent("Editor window floating", "If true UV   Editor window will open as a floating window"),
                    pbUVEditorFloating);

            GUILayout.Space(4);

            GUILayout.Label("Shortcut Settings", EditorStyles.boldLabel);

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical(GUILayout.MinWidth(EditorGUIUtility.labelWidth), GUILayout.MaxWidth(EditorGUIUtility.labelWidth));
            ShortcutSelectPanel();
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            ShortcutEditPanel();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            EditorGUILayout.EndScrollView();

            // Save the preferences
            if (EditorGUI.EndChangeCheck())
            {
                SetPrefs();
            }

            EditorGUIUtility.labelWidth = 0f;
        }
Ejemplo n.º 30
0
        public void OnGUI()
        {
            string editorPath = CodeEditor.CurrentEditorInstallation;

            if (!Registry.Instance.TryGetDiscoveryFromEditorPath(editorPath, out Discovery discovery))
            {
                EditorGUILayout.HelpBox(Properties.discoveryFail.text, MessageType.Error);
                return;
            }

            EditorGUI.BeginDisabledGroup(!Preferences.IsActive || EditorApplication.isCompiling || EditorApplication.isUpdating);

            if (!string.IsNullOrEmpty(discovery.notes))
            {
                EditorGUILayout.HelpBox(discovery.notes, MessageType.Info);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            string arguments = EditorGUILayout.TextField(Properties.arguments, discovery.Arguments);

            if (EditorGUI.EndChangeCheck())
            {
                discovery.Arguments = arguments;
            }

            if (GUILayout.Button(Properties.reset, EditorStyles.miniButton, GUILayout.Width(64f)))
            {
                discovery.Arguments        = discovery.defaultArguments;
                GUIUtility.keyboardControl = 0;
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            EditorGUI.BeginChangeCheck();
            bool autoGenerate = EditorGUILayout.Toggle(Properties.autoGenerate, discovery.AutoGenerate);

            if (EditorGUI.EndChangeCheck())
            {
                discovery.AutoGenerate = autoGenerate;
                if (autoGenerate)
                {
                    generator.Sync();
                }
            }

            var flags = generator.AssemblyNameProvider.ProjectGenerationFlag;

            EditorGUI.BeginChangeCheck();
            var nflags = (ProjectGenerationFlag)EditorGUILayout.EnumFlagsField(flags);

            if (EditorGUI.EndChangeCheck())
            {
                generator.AssemblyNameProvider.ToggleProjectGeneration(nflags ^ flags);
            }

            if (GUILayout.Button(Properties.generate, EditorStyles.miniButtonLeft, GUILayout.Width(64f)))
            {
                generator.Sync();
            }

            if (GUILayout.Button(Properties.clear, EditorStyles.miniButtonRight, GUILayout.Width(40f)))
            {
                var di = new DirectoryInfo(Preferences.projectPath);
                foreach (var fi in di.EnumerateFiles("*.csproj", SearchOption.TopDirectoryOnly))
                {
                    fi.Delete();
                }

                foreach (var fi in di.EnumerateFiles("*.sln", SearchOption.TopDirectoryOnly))
                {
                    fi.Delete();
                }
            }

            EditorGUILayout.EndHorizontal();

#if !UNITY_2020_2_OR_NEWER
            EditorGUI.BeginChangeCheck();
            bool matchCompilerVersion = EditorGUILayout.Toggle(Properties.matchCompilerVersion, discovery.MatchCompilerVersion);
            if (EditorGUI.EndChangeCheck())
            {
                discovery.MatchCompilerVersion = matchCompilerVersion;
                if (matchCompilerVersion)
                {
                    generator.Sync();
                }
            }
#endif

            EditorGUI.BeginDisabledGroup(!MonoInstallationFinder.IsValid || !discovery.inheritsEnvironmentVariables);

            if (discovery.inheritsEnvironmentVariables)
            {
                EditorGUI.BeginChangeCheck();
                bool v = EditorGUILayout.Toggle(Properties.exportFrameworkPathOverride, discovery.ExportFrameworkPathOverride);
                if (EditorGUI.EndChangeCheck())
                {
                    discovery.ExportFrameworkPathOverride = v;
                }
            }

            EditorGUI.EndDisabledGroup();

            if (!MonoInstallationFinder.IsValid)
            {
                EditorGUILayout.HelpBox(Properties.monoInstallationFinderFail.text, MessageType.Warning);
            }

            EditorGUI.EndDisabledGroup();
        }