FloatField() public static method

Make a text field for entering float values.

public static FloatField ( GUIContent label, float value ) : float
label UnityEngine.GUIContent Optional label to display in front of the float field.
value float The value to edit.
return float
    bool ShowTreePrototype(TreePrototype treePrototype, int id)
    {
        bool removeThis = false;

        EGL.BeginVertical(GuiUtils.Skin.box);
        {
            GUILayout.Label(id.ToString() + ". " + (treePrototype.prefab != null ? treePrototype.prefab.name : ""));

            EGL.BeginHorizontal();
            {
                treePrototype.prefab = EGL.ObjectField(treePrototype.prefab, typeof(GameObject), false) as GameObject;

                EGL.BeginVertical();
                {
                    treePrototype.bendFactor = EGL.FloatField("Bend Factor", treePrototype.bendFactor);
                }
                EGL.EndVertical();

                if (GUILayout.Button("Remove", GUILayout.Width(64f), GUILayout.Height(64f)))
                {
                    removeThis = true;
                }
            }
            EGL.EndHorizontal();
        }
        EGL.EndVertical();

        return(removeThis);
    }
示例#2
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        neb = target as Nebula;

        EGL.Space();
        EGL.FloatField("Radius", neb.dimensions.magnitude);
    }
示例#3
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            var tree   = (BehaviourTree)target;
            var script = tree.source;

            if (script)
            {
                if (script.notCompiled)
                {
                    EGL.HelpBox("Script is not compiled.", MessageType.Error);
                }
                if (script.notUpToDate)
                {
                    EGL.HelpBox("Script is not up to date.", MessageType.Warning);
                }
                if (script.compileOkay)
                {
                    EGL.HelpBox("Script is compiled and up to date.", MessageType.Info);
                }
                if (GL.Button("Compile"))
                {
                    script.Compile();
                }
            }

            if (Application.isPlaying)
            {
                EGL.Space();
                EGL.LabelField("Conditions");
                GUI.enabled = false;
                foreach (var cond in tree.blackboard)
                {
                    var k = cond.Key;
                    var v = cond.Value;
                    if (v is float)
                    {
                        EGL.FloatField(k, (float)v);
                    }
                    else if (v is int)
                    {
                        EGL.IntField(k, (int)v);
                    }
                    else if (v is bool)
                    {
                        EGL.Toggle(k, (bool)v);
                    }
                    else if (v is string)
                    {
                        EGL.TextField(k, (string)v);
                    }
                }
                GUI.enabled = true;
                Repaint();
            }
        }
    bool ShowLodLevel(LodLevel lod, int index)
    {
        bool removeThis = false;

        EGL.BeginVertical(GuiUtils.Skin.box);
        {
            GUILayout.Label("[" + index + "]");

            lod.Level = EGL.IntField("Lod Level", lod.Level);
            GUILayout.BeginHorizontal();
            {
                lod.FolderPath = EGL.TextField("Folder Path", lod.FolderPath);
                if (GUILayout.Button("Browse", GUILayout.Width(50f)))
                {
                    lod.FolderPath = UPath.GetProjectPath(EditorUtility.OpenFolderPanel("Browse", lod.FolderPath, Application.dataPath));
                }
            }
            GUILayout.EndHorizontal();

            lod.GridSize = EGL.IntField("Grid Size", lod.GridSize);

            lod.HeightmapResolution = EGL.IntField("Heightmap Resolution (px)", lod.HeightmapResolution);
            lod.SplatmapResolution  = EGL.IntField("Splatmap Resolution (px)", lod.SplatmapResolution);

            lod.HasDetailMap = EGL.Toggle("Use Detail Map?", lod.HasDetailMap);
            lod.HasTreeMap   = EGL.Toggle("Use Tree Map?", lod.HasTreeMap);

            if (lod.HasDetailMap)
            {
                lod.DetailmapResolution      = EGL.IntField("Detailmap Resolution (px)", lod.DetailmapResolution);
                lod.DetailResolutionPerPatch = EGL.IntField("Detailmap Patch Size (px)", lod.DetailResolutionPerPatch);
            }

            EGL.Space();

            GUILayout.Label("In-game terrain dimensions.");
            lod.TerrainWidth  = EGL.FloatField("Width & Length (m)", lod.TerrainWidth);
            lod.TerrainHeight = EGL.FloatField("Height (m)", lod.TerrainHeight);

            EGL.Space();

            GUILayout.Label("Relief Terrain Configuration");
            lod.ColormapResolution  = EGL.IntField("Colormap Resolution", lod.ColormapResolution);
            lod.NormalmapResolution = EGL.IntField("Normalmap Resolution", lod.NormalmapResolution);


            EGL.Space();

            if (GUILayout.Button("Remove", GUILayout.Width(64f), GUILayout.Height(64f)))
            {
                removeThis = true;
            }
        }
        EGL.EndVertical();

        return(removeThis);
    }
    void ShowTerrainSettings()
    {
        LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance;
        ImporterConfiguration   importCfg       = editorUtilities.ImportCfg;
        TerrainConfiguration    terrainStreamingConfiguration = importCfg.TerrainConfiguration;

        EGL.BeginVertical();
        {
            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                if (GUILayout.Button("Apply to selected TerrainData assets"))
                {
                    QueueCall(editorUtilities.ApplyDimensionsToSelection);
                }
            }
            EGL.EndVertical();

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("In-game terrain LOD settings.");
                terrainStreamingConfiguration.HeightmapPixelError = EGL.Slider("Pixel Error", terrainStreamingConfiguration.HeightmapPixelError, 1f, 200f);
                terrainStreamingConfiguration.BasemapDistance     = EGL.FloatField("Basemap Dist.", terrainStreamingConfiguration.BasemapDistance);
                terrainStreamingConfiguration.CastShadows         = EGL.Toggle("Cast Shadows", terrainStreamingConfiguration.CastShadows);
                EGL.Separator();
                terrainStreamingConfiguration.DetailObjectDistance    = EGL.Slider("Detail Distance", terrainStreamingConfiguration.DetailObjectDistance, 0f, 250f);
                terrainStreamingConfiguration.DetailObjectDensity     = EGL.Slider("Detail Density", terrainStreamingConfiguration.DetailObjectDensity, 0f, 1f);
                terrainStreamingConfiguration.TreeDistance            = EGL.Slider("Tree Distance", terrainStreamingConfiguration.TreeDistance, 0f, 2000f);
                terrainStreamingConfiguration.TreeBillboardDistance   = EGL.Slider("Billboard Start", terrainStreamingConfiguration.TreeBillboardDistance, 50f, 2000f);
                terrainStreamingConfiguration.TreeCrossFadeLength     = EGL.Slider("Fade Length", terrainStreamingConfiguration.TreeCrossFadeLength, 0f, 200f);
                terrainStreamingConfiguration.TreeMaximumFullLODCount = EGL.IntSlider("Max Mesh Trees", terrainStreamingConfiguration.TreeMaximumFullLODCount, 0, 500);
                EGL.Separator();

                if (GUILayout.Button("Apply to selected Scene assets"))
                {
                    QueueCall(editorUtilities.ApplyTerrainLODSettingsToSelection);
                }
            }
            EGL.EndVertical();
        }
        EGL.EndVertical();
    }
    bool ShowDetailPrototype(DetailPrototype prototype, int id)
    {
        bool removeThis = false;

        EGL.BeginVertical(GuiUtils.Skin.box);
        {
            EGL.BeginHorizontal();
            {
                EGL.BeginVertical();
                {
                    prototype.usePrototypeMesh = EGL.Toggle("Use Mesh", prototype.usePrototypeMesh);
                    prototype.prototype        = EGL.ObjectField(prototype.prototype, typeof(GameObject), false) as GameObject;
                    prototype.prototypeTexture = EGL.ObjectField(prototype.prototypeTexture, typeof(Texture2D), false, GUILayout.Width(64f),
                                                                 GUILayout.Height(64f)) as Texture2D;
                }
                EGL.EndVertical();

                EGL.BeginVertical();
                {
                    prototype.bendFactor   = EGL.FloatField("Bend Factor", prototype.bendFactor);
                    prototype.dryColor     = EGL.ColorField("Dry Color", prototype.dryColor);
                    prototype.healthyColor = EGL.ColorField("Healthy Color", prototype.healthyColor);
                    prototype.maxHeight    = EGL.FloatField("Max Height", prototype.maxHeight);
                    prototype.minHeight    = EGL.FloatField("Min Height", prototype.minHeight);
                    prototype.maxWidth     = EGL.FloatField("Max Width", prototype.maxWidth);
                    prototype.minWidth     = EGL.FloatField("Min Width", prototype.minWidth);
                    prototype.noiseSpread  = EGL.FloatField("Noise Spread", prototype.noiseSpread);
                    prototype.renderMode   = (DetailRenderMode)EGL.EnumPopup("Noise Spread", prototype.renderMode);
                }
                EGL.EndVertical();

                if (GUILayout.Button("Remove", GUILayout.Width(64f), GUILayout.Height(64f)))
                {
                    removeThis = true;
                }
            }
            EGL.EndHorizontal();
        }
        EGL.EndVertical();

        return(removeThis);
    }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        EGL.Space();

        AsteroidField field = (AsteroidField)target;

        field.AsteroidGameObject = (GameObject)EGL.ObjectField(new GUIContent("Asteroid Game Object", "The game object that represents the spawned asteroids"), field.AsteroidGameObject, typeof(GameObject), false);

        field.InnerRadius = EGL.FloatField(new GUIContent("Inner Radius", "The inner radius of the field"), field.InnerRadius);
        field.OuterRadius = EGL.Slider("Outer Radius", field.OuterRadius, field.InnerRadius, 10000 + field.InnerRadius);

        EGL.Space();

        scaleUsesRange = EGL.Toggle(new GUIContent("Scale uses range?", "Whether the asteroids spawned should pick a scale from a specified range."), scaleUsesRange);

        if (scaleUsesRange)
        {
            field.AsteroidLowerScale = EGL.Slider("Lower range", field.AsteroidLowerScale, 0, 20);
            field.AsteroidUpperScale = EGL.Slider("Upper range", field.AsteroidUpperScale, field.AsteroidLowerScale, field.AsteroidLowerScale + 20);
        }

        else
        {
            field.AsteroidScale = EGL.Slider("Scale", field.AsteroidScale, 0, 20);
        }

        using (new EditorGUI.DisabledScope(field.AsteroidGameObject == null))
        {
            if (GUILayout.Button("Generate Field"))
            {
                field.GenerateField(scaleUsesRange);
            }
        }

        if (GUILayout.Button("Clear Field"))
        {
            field.ClearField();
        }
    }
示例#8
0
    void OnGUI()
    {
        EGL.LabelField("3D Texture properties", EditorStyles.boldLabel);

        int new_size = EGL.IntField("Resolution", data.size);

        new_size  = new_size <= 512 ? new_size : 512;
        new_size  = new_size >= 8 ? new_size : 8;
        data.size = new_size;

        EGL.LabelField("Worley noise");
        data.freqs[0]   = EGL.FloatField("Frequency", data.freqs[0]);
        data.octaves[0] = EGL.IntField("Octaves", data.octaves[0]);
        bool inv = EGL.Toggle("Invert", data.inverts[0] > 0);

        data.inverts[0] = inv ? 1 : 0;

        if (GUILayout.Button("Generate"))
        {
            CreateTexture();
        }

        EGL.HelpBox(status, MessageType.None, true);

        if (GUILayout.Button("Preview"))
        {
            CloudPreviewer.ShowTexture(texture);
        }

        EGL.BeginHorizontal();
        assetName = EGL.TextField("Asset name:", assetName);
        if (GUILayout.Button("Save"))
        {
            AssetDatabase.CreateAsset(texture, "Assets/" + assetName + ".asset");
        }
        EGL.EndHorizontal();
    }
示例#9
0
        private void FloatGUI()
        {
            int?toRemove = null;

            for (int i = 0; i < data.floatNames.Count; i++)
            {
                UGL.BeginHorizontal();
                data.floatNames[i] = UGL.DelayedTextField(data.floatNames[i], GUILayout.MaxWidth(Screen.width));
                GUILayout.FlexibleSpace();
                float oldVal = i < data.floats.Count?data.floats[i]:0;
                float newVal = UGL.FloatField(oldVal);
                GUILayout.FlexibleSpace();
                GUI.color = Color.red;
                if (GUILayout.Button("-", GUILayout.Width(100)))
                {
                    toRemove = i;
                }
                GUI.color = Color.white;
                if (oldVal != newVal)
                {
                    if (!data.floats.Contains(oldVal))
                    {
                        data.floats.Add(newVal);
                    }
                    else
                    {
                        data.floats[data.floats.IndexOf(oldVal)] = newVal;
                    }
                }
                UGL.EndHorizontal();
            }
            if (toRemove != null)
            {
                data.floatNames.RemoveAt((int)toRemove);
            }
        }
示例#10
0
        void OnGUI()
        {
            var dirtyCount = PhysicsVisualizationSettings.dirtyCount;

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Reset", EditorStyles.toolbarButton))
            {
                PhysicsVisualizationSettings.Reset();
            }

            EditorGUILayout.EndHorizontal();

            m_MainScrollPos = GUILayout.BeginScrollView(m_MainScrollPos);

            {
                EditorGUILayout.Space();
                m_ShowInfoFoldout.value = EditorGUILayout.Foldout(m_ShowInfoFoldout.value, Style.selectedObjectInfo);
                if (m_ShowInfoFoldout.value)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.Space();
                    EditorGUI.BeginDisabledGroup(true);
                    var transforms = Selection.transforms;
                    if (transforms.Length > 0)
                    {
                        foreach (var tr in transforms)
                        {
                            EditorGUILayout.TextField(Style.gameObject, tr.name);
                            EditorGUILayout.TextField(Style.scene, tr.gameObject.scene.name);
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                    Repaint();
                    EditorGUI.indentLevel--;
                }
            }
            GUILayout.Space(4);

            int           sceneCount = SceneManager.sceneCount;
            List <string> options    = new List <string>();

            for (int i = 0; i < sceneCount; ++i)
            {
                var scene = SceneManager.GetSceneAt(i);
                options.Add(string.Format("{0} ", scene.name));
            }

            int newPhysicsSceneMask = EditorGUILayout.MaskField(Style.showPhysicsScenes, PhysicsVisualizationSettings.GetShowPhysicsSceneMask(), options.ToArray());

            PhysicsVisualizationSettings.SetShowPhysicsSceneMask(newPhysicsSceneMask);

            // Layers
            int oldConcatenatedMask = InternalEditorUtility.LayerMaskToConcatenatedLayersMask(
                PhysicsVisualizationSettings.GetShowCollisionLayerMask());

            int newConcatenatedMask = EditorGUILayout.MaskField(
                Style.showLayers, oldConcatenatedMask, InternalEditorUtility.layers);

            PhysicsVisualizationSettings.SetShowCollisionLayerMask(
                (int)InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(newConcatenatedMask));

            // Static Colliders
            PhysicsVisualizationSettings.SetShowStaticColliders(EditorGUILayout.Toggle(
                                                                    Style.showStaticCollider, PhysicsVisualizationSettings.GetShowStaticColliders()));

            // Triggers
            PhysicsVisualizationSettings.SetShowTriggers(EditorGUILayout.Toggle(
                                                             Style.showTriggers, PhysicsVisualizationSettings.GetShowTriggers()));

            // Rigidbodies
            PhysicsVisualizationSettings.SetShowRigidbodies(EditorGUILayout.Toggle(
                                                                Style.showRigibodies, PhysicsVisualizationSettings.GetShowRigidbodies()));

            // Kinematic Bodies
            PhysicsVisualizationSettings.SetShowKinematicBodies(EditorGUILayout.Toggle(
                                                                    Style.showKinematicBodies, PhysicsVisualizationSettings.GetShowKinematicBodies()));

            // Sleeping Bodies
            PhysicsVisualizationSettings.SetShowSleepingBodies(EditorGUILayout.Toggle(
                                                                   Style.showSleepingBodies, PhysicsVisualizationSettings.GetShowSleepingBodies()));

            m_ShowColliderTypeFoldout.value = EditorGUILayout.Foldout(m_ShowColliderTypeFoldout.value, Style.colliderTypes);
            if (m_ShowColliderTypeFoldout.value)
            {
                EditorGUI.indentLevel++;
                float oldWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 200;

                // BoxCollider
                PhysicsVisualizationSettings.SetShowBoxColliders(EditorGUILayout.Toggle(
                                                                     Style.showBoxCollider, PhysicsVisualizationSettings.GetShowBoxColliders()));

                // SphereCollider
                PhysicsVisualizationSettings.SetShowSphereColliders(EditorGUILayout.Toggle(
                                                                        Style.showSphereCollider, PhysicsVisualizationSettings.GetShowSphereColliders()));

                // CapsuleCollider
                PhysicsVisualizationSettings.SetShowCapsuleColliders(EditorGUILayout.Toggle(
                                                                         Style.showCapsuleCollider, PhysicsVisualizationSettings.GetShowCapsuleColliders()));

                // MeshCollider convex
                PhysicsVisualizationSettings.SetShowMeshColliders(PhysicsVisualizationSettings.MeshColliderType.Convex, EditorGUILayout.Toggle(
                                                                      Style.showConvexMeshCollider, PhysicsVisualizationSettings.GetShowMeshColliders(PhysicsVisualizationSettings.MeshColliderType.Convex)));

                // MeshCollider non-convex
                PhysicsVisualizationSettings.SetShowMeshColliders(PhysicsVisualizationSettings.MeshColliderType.NonConvex, EditorGUILayout.Toggle(
                                                                      Style.showConcaveMeshCollider, PhysicsVisualizationSettings.GetShowMeshColliders(PhysicsVisualizationSettings.MeshColliderType.NonConvex)));

                // TerrainCollider
                PhysicsVisualizationSettings.SetShowTerrainColliders(EditorGUILayout.Toggle(
                                                                         Style.showTerrainCollider, PhysicsVisualizationSettings.GetShowTerrainColliders()));

                EditorGUIUtility.labelWidth = oldWidth;
                EditorGUI.indentLevel--;
            }

            GUILayout.Space(4);

            // Selection buttons
            GUILayout.BeginHorizontal();

            bool selectNone = GUILayout.Button(Style.showNone);
            bool selectAll  = GUILayout.Button(Style.showAll);

            if (selectNone || selectAll)
            {
                PhysicsVisualizationSettings.SetShowForAllFilters(selectAll);
            }

            GUILayout.EndHorizontal();

            m_ColorFoldout.value = EditorGUILayout.Foldout(m_ColorFoldout.value, Style.colors);
            if (m_ColorFoldout.value)
            {
                EditorGUI.indentLevel++;

                PhysicsVisualizationSettings.staticColor =
                    EditorGUILayout.ColorField(Style.staticColor, PhysicsVisualizationSettings.staticColor);

                PhysicsVisualizationSettings.triggerColor =
                    EditorGUILayout.ColorField(Style.triggerColor, PhysicsVisualizationSettings.triggerColor);

                PhysicsVisualizationSettings.rigidbodyColor =
                    EditorGUILayout.ColorField(Style.rigidbodyColor, PhysicsVisualizationSettings.rigidbodyColor);

                PhysicsVisualizationSettings.kinematicColor =
                    EditorGUILayout.ColorField(Style.kinematicColor, PhysicsVisualizationSettings.kinematicColor);

                PhysicsVisualizationSettings.sleepingBodyColor =
                    EditorGUILayout.ColorField(Style.sleepingBodyColor, PhysicsVisualizationSettings.sleepingBodyColor);

                PhysicsVisualizationSettings.colorVariance =
                    EditorGUILayout.Slider(Style.colorVariaition, PhysicsVisualizationSettings.colorVariance, 0f, 1f);

                EditorGUI.indentLevel--;
            }

            m_RenderingFoldout.value = EditorGUILayout.Foldout(m_RenderingFoldout.value, Style.rendering);
            if (m_RenderingFoldout.value)
            {
                EditorGUI.indentLevel++;

                PhysicsVisualizationSettings.baseAlpha = 1f - EditorGUILayout.Slider(Style.transparency
                                                                                     , 1f - PhysicsVisualizationSettings.baseAlpha, 0f, 1f);

                PhysicsVisualizationSettings.forceOverdraw = EditorGUILayout.Toggle(Style.forceOverdraw
                                                                                    , PhysicsVisualizationSettings.forceOverdraw);

                PhysicsVisualizationSettings.viewDistance = EditorGUILayout.FloatField(Style.viewDistance
                                                                                       , PhysicsVisualizationSettings.viewDistance);

                PhysicsVisualizationSettings.terrainTilesMax = EditorGUILayout.IntField(Style.terrainTilesMax
                                                                                        , PhysicsVisualizationSettings.terrainTilesMax);

                EditorGUI.indentLevel--;
            }

            if (Unsupported.IsDeveloperMode() || PhysicsVisualizationSettings.devOptions)
            {
                PhysicsVisualizationSettings.devOptions = EditorGUILayout.Toggle(Style.devOptions
                                                                                 , PhysicsVisualizationSettings.devOptions);
            }

            if (PhysicsVisualizationSettings.devOptions)
            {
                PhysicsVisualizationSettings.dotAlpha = EditorGUILayout.Slider(Style.dotAlpha
                                                                               , PhysicsVisualizationSettings.dotAlpha, -1f, 1f);

                PhysicsVisualizationSettings.forceDot = EditorGUILayout.Toggle(Style.forceDot
                                                                               , PhysicsVisualizationSettings.forceDot);

                Tools.hidden = EditorGUILayout.Toggle(Style.toolsHidden
                                                      , Tools.hidden);
            }

            GUILayout.EndScrollView();

            if (dirtyCount != PhysicsVisualizationSettings.dirtyCount)
            {
                RepaintSceneAndGameViews();
            }
        }
示例#11
0
        private void BakeSettings()
        {
            EditorGUILayout.LabelField(s_Styles.m_AgentSizeHeader, EditorStyles.boldLabel, new GUILayoutOption[0]);
            Rect rect = EditorGUILayout.GetControlRect(false, 120f, new GUILayoutOption[0]);

            this.DrawAgentDiagram(rect, this.m_AgentRadius.floatValue, this.m_AgentHeight.floatValue, this.m_AgentClimb.floatValue, this.m_AgentSlope.floatValue);
            float num2 = EditorGUILayout.FloatField(s_Styles.m_AgentRadiusContent, this.m_AgentRadius.floatValue, new GUILayoutOption[0]);

            if ((num2 >= 0.001f) && !Mathf.Approximately(num2 - this.m_AgentRadius.floatValue, 0f))
            {
                this.m_AgentRadius.floatValue = num2;
                if (!this.m_ManualCellSize.boolValue)
                {
                    this.m_CellSize.floatValue = (2f * this.m_AgentRadius.floatValue) / 6f;
                }
            }
            if ((this.m_AgentRadius.floatValue < 0.05f) && !this.m_ManualCellSize.boolValue)
            {
                EditorGUILayout.HelpBox("The agent radius you've set is really small, this can slow down the build.\nIf you intended to allow the agent to move close to the borders and walls, please adjust voxel size in advaced settings to ensure correct bake.", MessageType.Warning);
            }
            float num3 = EditorGUILayout.FloatField(s_Styles.m_AgentHeightContent, this.m_AgentHeight.floatValue, new GUILayoutOption[0]);

            if ((num3 >= 0.001f) && !Mathf.Approximately(num3 - this.m_AgentHeight.floatValue, 0f))
            {
                this.m_AgentHeight.floatValue = num3;
            }
            EditorGUILayout.Slider(this.m_AgentSlope, 0f, 60f, s_Styles.m_AgentSlopeContent, new GUILayoutOption[0]);
            if (this.m_AgentSlope.floatValue > 60f)
            {
                EditorGUILayout.HelpBox("The maximum slope should be set to less than " + 60f + " degrees to prevent NavMesh build artifacts on slopes. ", MessageType.Warning);
            }
            float num5 = EditorGUILayout.FloatField(s_Styles.m_AgentClimbContent, this.m_AgentClimb.floatValue, new GUILayoutOption[0]);

            if ((num5 >= 0f) && !Mathf.Approximately(this.m_AgentClimb.floatValue - num5, 0f))
            {
                this.m_AgentClimb.floatValue = num5;
            }
            if (this.m_AgentClimb.floatValue > this.m_AgentHeight.floatValue)
            {
                EditorGUILayout.HelpBox("Step height should be less than agent height.\nClamping step height to " + this.m_AgentHeight.floatValue + " internally when baking.", MessageType.Warning);
            }
            float floatValue = this.m_CellSize.floatValue;
            float num7       = floatValue * 0.5f;
            int   num8       = (int)Mathf.Ceil(this.m_AgentClimb.floatValue / num7);
            float num9       = Mathf.Tan((this.m_AgentSlope.floatValue / 180f) * 3.141593f) * floatValue;
            int   num10      = (int)Mathf.Ceil((num9 * 2f) / num7);

            if (num10 > num8)
            {
                float f     = (num8 * num7) / (floatValue * 2f);
                float num12 = (Mathf.Atan(f) / 3.141593f) * 180f;
                float num13 = (num10 - 1) * num7;
                EditorGUILayout.HelpBox("Step Height conflicts with Max Slope. This makes some slopes unwalkable.\nConsider decreasing Max Slope to < " + num12.ToString("0.0") + " degrees.\nOr, increase Step Height to > " + num13.ToString("0.00") + ".", MessageType.Warning);
            }
            EditorGUILayout.Space();
            EditorGUILayout.LabelField(s_Styles.m_OffmeshHeader, EditorStyles.boldLabel, new GUILayoutOption[0]);
            float num14 = EditorGUILayout.FloatField(s_Styles.m_AgentDropContent, this.m_LedgeDropHeight.floatValue, new GUILayoutOption[0]);

            if ((num14 >= 0f) && !Mathf.Approximately(num14 - this.m_LedgeDropHeight.floatValue, 0f))
            {
                this.m_LedgeDropHeight.floatValue = num14;
            }
            float num15 = EditorGUILayout.FloatField(s_Styles.m_AgentJumpContent, this.m_MaxJumpAcrossDistance.floatValue, new GUILayoutOption[0]);

            if ((num15 >= 0f) && !Mathf.Approximately(num15 - this.m_MaxJumpAcrossDistance.floatValue, 0f))
            {
                this.m_MaxJumpAcrossDistance.floatValue = num15;
            }
            EditorGUILayout.Space();
            this.m_Advanced = GUILayout.Toggle(this.m_Advanced, s_Styles.m_AdvancedHeader, EditorStyles.foldout, new GUILayoutOption[0]);
            if (this.m_Advanced)
            {
                EditorGUI.indentLevel++;
                bool flag = EditorGUILayout.Toggle(s_Styles.m_ManualCellSizeContent, this.m_ManualCellSize.boolValue, new GUILayoutOption[0]);
                if (flag != this.m_ManualCellSize.boolValue)
                {
                    this.m_ManualCellSize.boolValue = flag;
                    if (!flag)
                    {
                        this.m_CellSize.floatValue = (2f * this.m_AgentRadius.floatValue) / 6f;
                    }
                }
                EditorGUI.BeginDisabledGroup(!this.m_ManualCellSize.boolValue);
                EditorGUI.indentLevel++;
                float num16 = EditorGUILayout.FloatField(s_Styles.m_CellSizeContent, this.m_CellSize.floatValue, new GUILayoutOption[0]);
                if ((num16 > 0f) && !Mathf.Approximately(num16 - this.m_CellSize.floatValue, 0f))
                {
                    this.m_CellSize.floatValue = Math.Max(0.01f, num16);
                }
                if (num16 < 0.01f)
                {
                    EditorGUILayout.HelpBox("The voxel size should be larger than 0.01.", MessageType.Warning);
                }
                float num17 = (this.m_CellSize.floatValue <= 0f) ? 0f : (this.m_AgentRadius.floatValue / this.m_CellSize.floatValue);
                EditorGUILayout.LabelField(" ", num17.ToString("0.00") + " voxels per agent radius", EditorStyles.miniLabel, new GUILayoutOption[0]);
                if (this.m_ManualCellSize.boolValue)
                {
                    float num19 = this.m_CellSize.floatValue * 0.5f;
                    if (((int)Mathf.Floor(this.m_AgentHeight.floatValue / num19)) > 250)
                    {
                        EditorGUILayout.HelpBox("The number of voxels per agent height is too high. This will reduce the accuracy of the navmesh. Consider using voxel size of at least " + (((this.m_AgentHeight.floatValue / 250f) / 0.5f)).ToString("0.000") + ".", MessageType.Warning);
                    }
                    if (num17 < 1f)
                    {
                        EditorGUILayout.HelpBox("The number of voxels per agent radius is too small. The agent may not avoid walls and ledges properly. Consider using voxel size of at least " + ((this.m_AgentRadius.floatValue / 2f)).ToString("0.000") + " (2 voxels per agent radius).", MessageType.Warning);
                    }
                    else if (num17 > 8f)
                    {
                        EditorGUILayout.HelpBox("The number of voxels per agent radius is too high. It can cause excessive build times. Consider using voxel size closer to " + ((this.m_AgentRadius.floatValue / 8f)).ToString("0.000") + " (8 voxels per radius).", MessageType.Warning);
                    }
                }
                if (this.m_ManualCellSize.boolValue)
                {
                    EditorGUILayout.HelpBox("Voxel size controls how accurately the navigation mesh is generated from the level geometry. A good voxel size is 2-4 voxels per agent radius. Making voxel size smaller will increase build time.", MessageType.None);
                }
                EditorGUI.indentLevel--;
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.Space();
                float num23 = EditorGUILayout.FloatField(s_Styles.m_MinRegionAreaContent, this.m_MinRegionArea.floatValue, new GUILayoutOption[0]);
                if ((num23 >= 0f) && (num23 != this.m_MinRegionArea.floatValue))
                {
                    this.m_MinRegionArea.floatValue = num23;
                }
                EditorGUILayout.Space();
                bool flag2 = EditorGUILayout.Toggle(s_Styles.m_AgentPlacementContent, this.m_AccuratePlacement.boolValue, new GUILayoutOption[0]);
                if (flag2 != this.m_AccuratePlacement.boolValue)
                {
                    this.m_AccuratePlacement.boolValue = flag2;
                }
                EditorGUI.indentLevel--;
            }
            if (Unsupported.IsDeveloperBuild())
            {
                EditorGUILayout.Space();
                GUILayout.Label("Internal Bake Debug Options", EditorStyles.boldLabel, new GUILayoutOption[0]);
                EditorGUILayout.HelpBox("Note: The debug visualization is build during bake, so you'll need to bake for these settings to take effect.", MessageType.None);
                bool showAutoOffMeshLinkSampling = NavMeshVisualizationSettings.showAutoOffMeshLinkSampling;
                if (showAutoOffMeshLinkSampling != EditorGUILayout.Toggle(new GUIContent("Show Auto-Off-MeshLink Sampling"), showAutoOffMeshLinkSampling, new GUILayoutOption[0]))
                {
                    NavMeshVisualizationSettings.showAutoOffMeshLinkSampling = !showAutoOffMeshLinkSampling;
                }
                bool showVoxels = NavMeshVisualizationSettings.showVoxels;
                if (showVoxels != EditorGUILayout.Toggle(new GUIContent("Show Voxels"), showVoxels, new GUILayoutOption[0]))
                {
                    NavMeshVisualizationSettings.showVoxels = !showVoxels;
                }
                bool showWalkable = NavMeshVisualizationSettings.showWalkable;
                if (showWalkable != EditorGUILayout.Toggle(new GUIContent("Show Walkable"), showWalkable, new GUILayoutOption[0]))
                {
                    NavMeshVisualizationSettings.showWalkable = !showWalkable;
                }
                bool showRawContours = NavMeshVisualizationSettings.showRawContours;
                if (showRawContours != EditorGUILayout.Toggle(new GUIContent("Show Raw Contours"), showRawContours, new GUILayoutOption[0]))
                {
                    NavMeshVisualizationSettings.showRawContours = !showRawContours;
                }
                bool showContours = NavMeshVisualizationSettings.showContours;
                if (showContours != EditorGUILayout.Toggle(new GUIContent("Show Contours"), showContours, new GUILayoutOption[0]))
                {
                    NavMeshVisualizationSettings.showContours = !showContours;
                }
                bool showInputs = NavMeshVisualizationSettings.showInputs;
                if (showInputs != EditorGUILayout.Toggle(new GUIContent("Show Inputs"), showInputs, new GUILayoutOption[0]))
                {
                    NavMeshVisualizationSettings.showInputs = !showInputs;
                }
                if (GUILayout.Button("Clear Visualiation Data", new GUILayoutOption[0]))
                {
                    NavMeshVisualizationSettings.ClearVisualizationData();
                    RepaintSceneAndGameViews();
                }
                EditorGUILayout.Space();
            }
        }
        void OnGUI()
        {
            var dirtyCount = PhysicsVisualizationSettings.dirtyCount;

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            // Workflow
            PhysicsVisualizationSettings.filterWorkflow = (PhysicsVisualizationSettings.FilterWorkflow)EditorGUILayout.EnumPopup(
                PhysicsVisualizationSettings.filterWorkflow, EditorStyles.toolbarPopup, GUILayout.Width(130));

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Reset", EditorStyles.toolbarButton))
            {
                PhysicsVisualizationSettings.Reset();
            }

            EditorGUILayout.EndHorizontal();

            m_MainScrollPos = GUILayout.BeginScrollView(m_MainScrollPos);

            PhysicsVisualizationSettings.FilterWorkflow filterMode = PhysicsVisualizationSettings.filterWorkflow;
            string action = (filterMode == PhysicsVisualizationSettings.FilterWorkflow.ShowSelectedItems) ? "Show " : "Hide ";

            // Layers
            int oldConcatenatedMask = InternalEditorUtility.LayerMaskToConcatenatedLayersMask(
                PhysicsVisualizationSettings.GetShowCollisionLayerMask(filterMode));

            int newConcatenatedMask = EditorGUILayout.MaskField(
                GUIContent.Temp(action + "Layers", action + "selected layers"), oldConcatenatedMask, InternalEditorUtility.layers);

            PhysicsVisualizationSettings.SetShowCollisionLayerMask(
                filterMode, (int)InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(newConcatenatedMask));

            // Static Colliders
            PhysicsVisualizationSettings.SetShowStaticColliders(filterMode, EditorGUILayout.Toggle(
                                                                    GUIContent.Temp(action + "Static Colliders", action + "collision geometry from Colliders that do not have a Rigidbody")
                                                                    , PhysicsVisualizationSettings.GetShowStaticColliders(filterMode)));

            // Triggers
            PhysicsVisualizationSettings.SetShowTriggers(filterMode, EditorGUILayout.Toggle(
                                                             GUIContent.Temp(action + "Triggers", action + "collision geometry from Colliders that have 'isTrigger' enabled")
                                                             , PhysicsVisualizationSettings.GetShowTriggers(filterMode)));

            // Rigidbodies
            PhysicsVisualizationSettings.SetShowRigidbodies(filterMode, EditorGUILayout.Toggle(
                                                                GUIContent.Temp(action + "Rigidbodies", action + "collision geometry from Rigidbodies")
                                                                , PhysicsVisualizationSettings.GetShowRigidbodies(filterMode)));

            // Kinematic Bodies
            PhysicsVisualizationSettings.SetShowKinematicBodies(filterMode, EditorGUILayout.Toggle(
                                                                    GUIContent.Temp(action + "Kinematic Bodies", action + "collision geometry from Kinematic Rigidbodies")
                                                                    , PhysicsVisualizationSettings.GetShowKinematicBodies(filterMode)));

            // Sleeping Bodies
            PhysicsVisualizationSettings.SetShowSleepingBodies(filterMode, EditorGUILayout.Toggle(
                                                                   GUIContent.Temp(action + "Sleeping Bodies", action + "collision geometry from Sleeping Rigidbodies")
                                                                   , PhysicsVisualizationSettings.GetShowSleepingBodies(filterMode)));

            m_FilterColliderTypesFoldout = EditorGUILayout.Foldout(m_FilterColliderTypesFoldout, "Collider Types");
            if (m_FilterColliderTypesFoldout)
            {
                EditorGUI.indentLevel++;
                float oldWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 200;

                // BoxCollider
                PhysicsVisualizationSettings.SetShowBoxColliders(filterMode, EditorGUILayout.Toggle(
                                                                     GUIContent.Temp(action + "BoxColliders", action + "collision geometry from BoxColliders")
                                                                     , PhysicsVisualizationSettings.GetShowBoxColliders(filterMode)));

                // SphereCollider
                PhysicsVisualizationSettings.SetShowSphereColliders(filterMode, EditorGUILayout.Toggle(
                                                                        GUIContent.Temp(action + "SphereColliders", action + "collision geometry from SphereColliders")
                                                                        , PhysicsVisualizationSettings.GetShowSphereColliders(filterMode)));

                // CapsuleCollider
                PhysicsVisualizationSettings.SetShowCapsuleColliders(filterMode, EditorGUILayout.Toggle(
                                                                         GUIContent.Temp(action + "CapsuleColliders", action + "collision geometry from CapsuleColliders")
                                                                         , PhysicsVisualizationSettings.GetShowCapsuleColliders(filterMode)));

                // MeshCollider convex
                PhysicsVisualizationSettings.SetShowMeshColliders(filterMode, PhysicsVisualizationSettings.MeshColliderType.Convex, EditorGUILayout.Toggle(
                                                                      GUIContent.Temp(action + "MeshColliders (convex)", action + "collision geometry from convex MeshColliders")
                                                                      , PhysicsVisualizationSettings.GetShowMeshColliders(filterMode, PhysicsVisualizationSettings.MeshColliderType.Convex)));

                // MeshCollider non-convex
                PhysicsVisualizationSettings.SetShowMeshColliders(filterMode, PhysicsVisualizationSettings.MeshColliderType.NonConvex, EditorGUILayout.Toggle(
                                                                      GUIContent.Temp(action + "MeshColliders (concave)", action + "collision geometry from non-convex MeshColliders")
                                                                      , PhysicsVisualizationSettings.GetShowMeshColliders(filterMode, PhysicsVisualizationSettings.MeshColliderType.NonConvex)));

                // TerrainCollider
                PhysicsVisualizationSettings.SetShowTerrainColliders(filterMode, EditorGUILayout.Toggle(
                                                                         GUIContent.Temp(action + "TerrainColliders", action + "collision geometry from TerrainColliders")
                                                                         , PhysicsVisualizationSettings.GetShowTerrainColliders(filterMode)));

                EditorGUIUtility.labelWidth = oldWidth;
                EditorGUI.indentLevel--;
            }

            GUILayout.Space(4);

            // Selection buttons
            GUILayout.BeginHorizontal();

            bool selectNone = GUILayout.Button(action + "None", "MiniButton");
            bool selectAll  = GUILayout.Button(action + "All", "MiniButton");

            if (selectNone || selectAll)
            {
                PhysicsVisualizationSettings.SetShowForAllFilters(filterMode, selectAll);
            }

            GUILayout.EndHorizontal();

            m_ColorFoldout = EditorGUILayout.Foldout(m_ColorFoldout, "Colors");
            if (m_ColorFoldout)
            {
                EditorGUI.indentLevel++;

                PhysicsVisualizationSettings.staticColor =
                    EditorGUILayout.ColorField(Contents.staticColor, PhysicsVisualizationSettings.staticColor);

                PhysicsVisualizationSettings.triggerColor =
                    EditorGUILayout.ColorField(Contents.triggerColor, PhysicsVisualizationSettings.triggerColor);

                PhysicsVisualizationSettings.rigidbodyColor =
                    EditorGUILayout.ColorField(Contents.rigidbodyColor, PhysicsVisualizationSettings.rigidbodyColor);

                PhysicsVisualizationSettings.kinematicColor =
                    EditorGUILayout.ColorField(Contents.kinematicColor, PhysicsVisualizationSettings.kinematicColor);

                PhysicsVisualizationSettings.sleepingBodyColor =
                    EditorGUILayout.ColorField(Contents.sleepingBodyColor, PhysicsVisualizationSettings.sleepingBodyColor);

                PhysicsVisualizationSettings.colorVariance =
                    EditorGUILayout.Slider("Variation", PhysicsVisualizationSettings.colorVariance, 0f, 1f);

                EditorGUI.indentLevel--;
            }

            m_RenderingFoldout = EditorGUILayout.Foldout(m_RenderingFoldout, "Rendering");
            if (m_RenderingFoldout)
            {
                EditorGUI.indentLevel++;

                PhysicsVisualizationSettings.baseAlpha = 1f - EditorGUILayout.Slider("Transparency"
                                                                                     , 1f - PhysicsVisualizationSettings.baseAlpha, 0f, 1f);

                PhysicsVisualizationSettings.forceOverdraw = EditorGUILayout.Toggle(Contents.forceOverdraw
                                                                                    , PhysicsVisualizationSettings.forceOverdraw);

                PhysicsVisualizationSettings.viewDistance = EditorGUILayout.FloatField(Contents.viewDistance
                                                                                       , PhysicsVisualizationSettings.viewDistance);

                PhysicsVisualizationSettings.terrainTilesMax = EditorGUILayout.IntField(Contents.terrainTilesMax
                                                                                        , PhysicsVisualizationSettings.terrainTilesMax);

                EditorGUI.indentLevel--;
            }

            if (Unsupported.IsDeveloperMode() || PhysicsVisualizationSettings.devOptions)
            {
                PhysicsVisualizationSettings.devOptions = EditorGUILayout.Toggle(Contents.devOptions
                                                                                 , PhysicsVisualizationSettings.devOptions);
            }

            if (PhysicsVisualizationSettings.devOptions)
            {
                PhysicsVisualizationSettings.dotAlpha = EditorGUILayout.Slider("dotAlpha"
                                                                               , PhysicsVisualizationSettings.dotAlpha, -1f, 1f);

                PhysicsVisualizationSettings.forceDot = EditorGUILayout.Toggle(Contents.forceDot
                                                                               , PhysicsVisualizationSettings.forceDot);

                Tools.hidden = EditorGUILayout.Toggle(Contents.toolsHidden
                                                      , Tools.hidden);
            }

            GUILayout.EndScrollView();

            if (dirtyCount != PhysicsVisualizationSettings.dirtyCount)
            {
                RepaintSceneAndGameViews();
            }
        }
示例#13
0
        /// <summary>
        /// Field drawing utility used when a field of an object needs to be drawn
        /// </summary>
        private static object DrawPropertyObject(object property, Type type, int indent = 0)
        {
            var _val = property;

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

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

                _elementAsObject.TryCast <object>(out _val);

                return(_val);
            }

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

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

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

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

                _elementAsBool.TryCast <object>(out _val);

                return(_val);
            }

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

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

                _elementAsInt.TryCast <object>(out _val);

                return(_val);
            }

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

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

                _elementAsFloat.TryCast <object>(out _val);

                return(_val);
            }

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

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

                _elementAsString.TryCast <object>(out _val);

                return(_val);
            }

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

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

                if (indent < PROPERTY_DEPTH_LIMIT)
                {
                    indent++;

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

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

                return(_val);
            }

            Gl.Label("[ERROR] Unknown Type");
            return(null);
        }
示例#14
0
        public override void OnInspectorGUI()
        {
            transition = (Transition)target;

            EditorGUI.BeginChangeCheck();

            var fromName    = transition.fromState.GetStatePreview();
            var toName      = transition.targetInfo;
            var displayName = fromName + "->" + toName;

            EGL.LabelField(displayName);
            EGL.Space();

            FromStateFilterInspector(transition.profile, transition.fromState, ref fromStateRect);
            EGL.Space();

            transition.triggerRangeType = (TriggerRangeType)EGL.EnumPopup("Trigger Range Type", transition.triggerRangeType);

            if (transition.triggerRangeType == TriggerRangeType.Range)
            {
                transition.triggerRange = EditorGUIUtil.FrameRangeInput("Trigger Frame", transition.triggerRange);
            }
            if (transition.triggerRangeType == TriggerRangeType.FrameSinceExec || transition.triggerRangeType == TriggerRangeType.FrameSinceExecBefore)
            {
                transition.triggerFrameSinceExec = EGL.IntField("Frame Since Exec", transition.triggerFrameSinceExec);
            }

            transition.timeBuffer = EGL.FloatField("Time Buffer", transition.timeBuffer);

            using (new EGL.VerticalScope(EditorStyles.helpBox))  {
                var conds      = transition.conditions;
                var paramNames = transition.profile.parameters.Select(it => it.name).ToArray();

                using (new EGL.HorizontalScope()) {
                    EGL.LabelField("Conditions", EditorStyles.boldLabel);
                    GL.FlexibleSpace();
                    if (GL.Button("+", GL.Width(30)))
                    {
                        conds.Add(new Condition());
                    }
                }
                for (int i = 0; i < conds.Count; ++i)
                {
                    var cond = conds[i];

                    EGL.BeginHorizontal();

                    int condSelectIndex = Mathf.Max(0, Array.IndexOf(paramNames, cond.name));

                    // cond.name = EGL.TextField(cond.name, GL.Width(70));
                    condSelectIndex = EGL.Popup(condSelectIndex, paramNames);
                    cond.name       = paramNames[condSelectIndex];

                    var param = transition.profile.FindParam(cond.name);
                    if (param == null)
                    {
                        EGL.LabelField("!Doesn't exist");
                    }
                    else
                    {
                        var type = param.type;
                        if (type == ParamType.Bool)
                        {
                            cond.boolValue = EGL.Toggle(cond.boolValue);
                        }
                        else if (type != ParamType.Trigger) // Trigger 不需要编辑
                        {
                            cond.cmp = (Cmp)EGL.EnumPopup(cond.cmp, GL.Width(50));

                            if (type == ParamType.Int)
                            {
                                cond.intValue = EGL.IntField(cond.intValue);
                            }
                            else
                            {
                                cond.floatValue = EGL.FloatField(cond.floatValue);
                            }
                        }
                    }

                    GL.FlexibleSpace();
                    if (GL.Button("-", GL.Width(30)))
                    {
                        conds.RemoveAt(i);
                        --i;
                    }

                    EGL.EndHorizontal();
                }
            }

            EGL.LabelField("", GUI.skin.horizontalSlider);

            transition.actionType = (ActionType)EGL.EnumPopup("Action", transition.actionType);

            if (transition.actionType == ActionType.ChangeState)
            {
                EGL.BeginHorizontal();
                EGL.PrefixLabel("Target State");
                EditorGUIUtil.AutoCompleteList(transition.targetStateName, allStateNames,
                                               str => transition.targetStateName = str, ref targetStateRect);

                transition.targetStateFrame = EGL.IntField(transition.targetStateFrame, GL.Width(30));
                EGL.LabelField("F", GUILayout.Width(20));

                var targetState = transition.profile.FindState(transition.targetStateName);
                if (targetState)
                {
                    if (GL.Button("Focus"))
                    {
                        Utils.FocusEditingAnimation(transition.profile, targetState.stateName);
                    }
                }
                EGL.EndHorizontal();

                if (!targetState)
                {
                    EGL.HelpBox("No target state " + targetState, MessageType.Error);
                }
            }
            else // SendMessage
            {
                transition.messageName = EGL.TextField("Message Name", transition.messageName);

                EGL.Space();
                transition.messageParType = (MessageParType)EGL.EnumPopup("Parameter Type", transition.messageParType);

                switch (transition.messageParType)
                {
                case MessageParType.Int:
                    transition.messageParInt = EGL.IntField("Value", transition.messageParInt);
                    break;

                case MessageParType.Float:
                    transition.messageParFloat = EGL.FloatField("Value", transition.messageParFloat);
                    break;

                case MessageParType.Bool:
                    transition.messageParBool = EGL.Toggle("Value", transition.messageParBool);
                    break;
                }
            }

            transition.priority    = EGL.IntField("Priority", transition.priority);
            transition.shouldDelay = EGL.Toggle("Should Delay", transition.shouldDelay);
            if (transition.shouldDelay)
            {
                transition.delay = EGL.FloatField("Delay", transition.delay);
            }

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(transition);
            }

            if (transition.fromState.type == FromStateType.State)
            {
                EGL.LabelField("", GUI.skin.horizontalSlider);
                using (new EGL.VerticalScope(EditorStyles.helpBox)) {
                    EGL.LabelField("From State", EditorStyles.boldLabel);
                    ++EditorGUI.indentLevel;
                    var fromState = transition.profile.FindState(transition.fromState.stateOrTagName);
                    if (fromState)
                    {
                        GUI.enabled = false;
                        if (!fromStateEditor || fromStateEditor.target != fromState)
                        {
                            if (fromStateEditor)
                            {
                                DestroyImmediate(fromStateEditor);
                            }
                            fromStateEditor = Editor.CreateEditor(fromState);
                        }

                        fromStateEditor.OnInspectorGUI();
                        GUI.enabled = true;
                    }
                    --EditorGUI.indentLevel;
                }
            }
        }
示例#15
0
        private void DrawOneView(Rect drawPos, LookDevEditionContext context)
        {
            int  index = (int)context;
            bool flag  = ((this.m_LookDevView.config.lookDevMode != LookDevMode.Single1) && (context == LookDevEditionContext.Left)) || ((this.m_LookDevView.config.lookDevMode != LookDevMode.Single2) && (context == LookDevEditionContext.Right));

            GUILayout.BeginArea(drawPos);
            GUILayout.Label(styles.sViewTitle[index], styles.sViewTitleStyles[index], new GUILayoutOption[0]);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(this.m_WindowWidth) };
            GUILayout.BeginVertical(options);
            GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Height(kLineHeight) };
            GUILayout.BeginHorizontal(optionArray2);
            GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.Width(kLabelWidth) };
            GUILayout.Label(styles.sExposure, styles.sMenuItem, optionArray3);
            float floatProperty = this.m_LookDevView.config.GetFloatProperty(LookDevProperty.ExposureValue, context);

            EditorGUI.BeginChangeCheck();
            float max = Mathf.Round(this.m_LookDevView.config.exposureRange);

            GUILayoutOption[] optionArray4 = new GUILayoutOption[] { GUILayout.Width(kSliderWidth) };
            floatProperty = Mathf.Clamp(GUILayout.HorizontalSlider(floatProperty, -max, max, optionArray4), -max, max);
            GUILayoutOption[] optionArray5 = new GUILayoutOption[] { GUILayout.Width(kSliderFieldWidth) };
            floatProperty = Mathf.Clamp(EditorGUILayout.FloatField((float)Math.Round((double)floatProperty, (floatProperty >= 0f) ? 2 : 1), optionArray5), -max, max);
            if (EditorGUI.EndChangeCheck())
            {
                this.m_LookDevView.config.UpdateFocus(context);
                this.m_LookDevView.config.UpdateFloatProperty(LookDevProperty.ExposureValue, floatProperty);
            }
            GUILayout.EndHorizontal();
            GUILayoutOption[] optionArray6 = new GUILayoutOption[] { GUILayout.Height(kLineHeight) };
            GUILayout.BeginHorizontal(optionArray6);
            int num4      = -1;
            int hdriCount = this.m_LookDevView.envLibrary.hdriCount;

            using (new EditorGUI.DisabledScope(hdriCount <= 1))
            {
                GUILayoutOption[] optionArray7 = new GUILayoutOption[] { GUILayout.Width(kLabelWidth) };
                GUILayout.Label(styles.sEnvironment, styles.sMenuItem, optionArray7);
                if (hdriCount > 1)
                {
                    int num6 = hdriCount - 1;
                    num4 = this.m_LookDevView.config.GetIntProperty(LookDevProperty.HDRI, context);
                    EditorGUI.BeginChangeCheck();
                    GUILayoutOption[] optionArray8 = new GUILayoutOption[] { GUILayout.Width(kSliderWidth) };
                    num4 = (int)GUILayout.HorizontalSlider((float)num4, 0f, (float)num6, optionArray8);
                    GUILayoutOption[] optionArray9 = new GUILayoutOption[] { GUILayout.Width(kSliderFieldWidth) };
                    num4 = Mathf.Clamp(EditorGUILayout.IntField(num4, optionArray9), 0, num6);
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.m_LookDevView.config.UpdateFocus(context);
                        this.m_LookDevView.config.UpdateIntProperty(LookDevProperty.HDRI, num4);
                    }
                }
                else
                {
                    GUILayoutOption[] optionArray10 = new GUILayoutOption[] { GUILayout.Width(kSliderWidth) };
                    GUILayout.HorizontalSlider(0f, 0f, 0f, optionArray10);
                    GUILayout.Label(styles.sZero, styles.sMenuItem, new GUILayoutOption[0]);
                }
            }
            GUILayout.EndHorizontal();
            GUILayoutOption[] optionArray11 = new GUILayoutOption[] { GUILayout.Height(kLineHeight) };
            GUILayout.BeginHorizontal(optionArray11);
            GUILayoutOption[] optionArray12 = new GUILayoutOption[] { GUILayout.Width(kLabelWidth) };
            GUILayout.Label(styles.sShadingMode, styles.sMenuItem, optionArray12);
            int intProperty = this.m_LookDevView.config.GetIntProperty(LookDevProperty.ShadingMode, context);

            EditorGUI.BeginChangeCheck();
            GUILayoutOption[] optionArray13 = new GUILayoutOption[] { GUILayout.Width((kSliderFieldWidth + kSliderWidth) + 4f) };
            intProperty = EditorGUILayout.IntPopup("", intProperty, styles.sShadingModeStrings, styles.sShadingModeValues, optionArray13);
            if (EditorGUI.EndChangeCheck())
            {
                this.m_LookDevView.config.UpdateFocus(context);
                this.m_LookDevView.config.UpdateIntProperty(LookDevProperty.ShadingMode, intProperty);
            }
            GUILayout.EndHorizontal();
            GUILayoutOption[] optionArray14 = new GUILayoutOption[] { GUILayout.Height(kLineHeight) };
            GUILayout.BeginHorizontal(optionArray14);
            GUILayoutOption[] optionArray15 = new GUILayoutOption[] { GUILayout.Width(kLabelWidth) };
            GUILayout.Label(styles.sRotation, styles.sMenuItem, optionArray15);
            float num8 = this.m_LookDevView.config.GetFloatProperty(LookDevProperty.EnvRotation, context);

            EditorGUI.BeginChangeCheck();
            GUILayoutOption[] optionArray16 = new GUILayoutOption[] { GUILayout.Width(kSliderWidth) };
            GUILayoutOption[] optionArray17 = new GUILayoutOption[] { GUILayout.Width(kSliderFieldWidth) };
            num8 = Mathf.Clamp(EditorGUILayout.FloatField((float)Math.Round((double)GUILayout.HorizontalSlider(num8, 0f, 720f, optionArray16), 0), optionArray17), 0f, 720f);
            if (EditorGUI.EndChangeCheck())
            {
                this.m_LookDevView.config.UpdateFocus(context);
                this.m_LookDevView.config.UpdateFloatProperty(LookDevProperty.EnvRotation, num8);
            }
            GUILayout.EndHorizontal();
            if (this.NeedLoD())
            {
                GUILayoutOption[] optionArray18 = new GUILayoutOption[] { GUILayout.Height(kLineHeight) };
                GUILayout.BeginHorizontal(optionArray18);
                if (this.m_LookDevView.config.GetObjectLoDCount(context) > 1)
                {
                    int num9 = this.m_LookDevView.config.GetIntProperty(LookDevProperty.LoDIndex, context);
                    GUILayoutOption[] optionArray19 = new GUILayoutOption[] { GUILayout.Width(kLabelWidth) };
                    GUILayout.Label((num9 != -1) ? styles.sLoD : styles.sLoDAuto, styles.sMenuItem, optionArray19);
                    EditorGUI.BeginChangeCheck();
                    int num10 = this.m_LookDevView.config.GetObjectLoDCount(context) - 1;
                    if (((this.m_LookDevView.config.lookDevMode != LookDevMode.Single1) && (this.m_LookDevView.config.lookDevMode != LookDevMode.Single2)) && this.m_LookDevView.config.IsPropertyLinked(LookDevProperty.LoDIndex))
                    {
                        num10 = Math.Min(this.m_LookDevView.config.GetObjectLoDCount(LookDevEditionContext.Left), this.m_LookDevView.config.GetObjectLoDCount(LookDevEditionContext.Right)) - 1;
                    }
                    GUILayoutOption[] optionArray20 = new GUILayoutOption[] { GUILayout.Width(kSliderWidth) };
                    num9 = (int)GUILayout.HorizontalSlider((float)Mathf.Clamp(num9, -1, num10), -1f, (float)num10, optionArray20);
                    GUILayoutOption[] optionArray21 = new GUILayoutOption[] { GUILayout.Width(kSliderFieldWidth) };
                    num9 = EditorGUILayout.IntField(num9, optionArray21);
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.m_LookDevView.config.UpdateFocus(context);
                        this.m_LookDevView.config.UpdateIntProperty(LookDevProperty.LoDIndex, num9);
                    }
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
            if (flag)
            {
                GUILayoutOption[] optionArray22 = new GUILayoutOption[] { GUILayout.Width(kIconSize) };
                GUILayout.BeginVertical(optionArray22);
                LookDevProperty[] propertyArray = new LookDevProperty[] { LookDevProperty.ExposureValue };
                int num11 = 4 + (!this.NeedLoD() ? 0 : 1);
                for (int i = 0; i < num11; i++)
                {
                    bool flag2 = false;
                    EditorGUI.BeginChangeCheck();
                    bool flag3 = this.m_LookDevView.config.IsPropertyLinked(propertyArray[i]);
                    GUILayoutOption[] optionArray23 = new GUILayoutOption[] { GUILayout.Height(kLineHeight) };
                    flag2 = GUILayout.Toggle(flag3, this.GetGUIContentLink(flag3), styles.sToolBarButton, optionArray23);
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.m_LookDevView.config.UpdatePropertyLink(propertyArray[i], flag2);
                    }
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }
 private void ShowRadiusInfromation()
 {
     field.innerRadius = EGL.FloatField(new GUIContent("Inner Radius", "The inner radius of the field"), field.innerRadius);
     field.outerRadius = EGL.Slider("Outer Radius", field.outerRadius, field.innerRadius, 10000 + field.innerRadius);
 }
示例#17
0
        internal void PlayBackInfoGUI(bool isPlayMode)
        {
            EventType oldEventType  = Event.current.type;
            int       oldHotControl = GUIUtility.hotControl;
            string    oldFormat     = EditorGUI.kFloatFieldFormatString;

            EditorGUIUtility.labelWidth = 110.0f;

            if (!isPlayMode)
            {
                EditorGUI.kFloatFieldFormatString = s_Texts.secondsFloatFieldFormatString;
                if (Time.timeScale == 0.0f)
                {
                    using (new EditorGUI.DisabledScope(true))
                    {
                        EditorGUILayout.FloatField(s_Texts.previewSpeedDisabled, 0.0f);
                    }
                }
                else
                {
                    ParticleSystemEditorUtils.simulationSpeed = Mathf.Clamp(EditorGUILayout.FloatField(s_Texts.previewSpeed, ParticleSystemEditorUtils.simulationSpeed), 0f, 10f);
                }
                EditorGUI.kFloatFieldFormatString = oldFormat;

                EditorGUI.BeginChangeCheck();
                EditorGUI.kFloatFieldFormatString = s_Texts.secondsFloatFieldFormatString;
                float playbackTime = EditorGUILayout.FloatField(s_Texts.previewTime, ParticleSystemEditorUtils.playbackTime);
                EditorGUI.kFloatFieldFormatString = oldFormat;
                if (EditorGUI.EndChangeCheck())
                {
                    if (oldEventType == EventType.MouseDrag)
                    {
                        ParticleSystemEditorUtils.playbackIsScrubbing = true;
                        float previewSpeed    = ParticleSystemEditorUtils.simulationSpeed;
                        float oldplaybackTime = ParticleSystemEditorUtils.playbackTime;
                        float timeDiff        = playbackTime - oldplaybackTime;
                        playbackTime = oldplaybackTime + timeDiff * (0.05F * previewSpeed);
                    }

                    playbackTime = Mathf.Max(playbackTime, 0.0F);
                    ParticleSystemEditorUtils.playbackTime = playbackTime;

                    foreach (ParticleSystem ps in m_SelectedParticleSystems)
                    {
                        ParticleSystem root = ParticleSystemEditorUtils.GetRoot(ps);
                        if (root.isStopped)
                        {
                            root.Play();
                            root.Pause();
                        }
                    }

                    ParticleSystemEditorUtils.PerformCompleteResimulation();
                }

                // Detect start dragging
                if (oldEventType == EventType.MouseDown && GUIUtility.hotControl != oldHotControl)
                {
                    m_IsDraggingTimeHotControlID = GUIUtility.hotControl;
                    ParticleSystemEditorUtils.playbackIsScrubbing = true;
                }

                // Detect stop dragging
                if (m_IsDraggingTimeHotControlID != -1 && GUIUtility.hotControl != m_IsDraggingTimeHotControlID)
                {
                    m_IsDraggingTimeHotControlID = -1;
                    ParticleSystemEditorUtils.playbackIsScrubbing = false;
                }
            }

            int   particleCount   = 0;
            float fastestParticle = 0.0f;
            float slowestParticle = Mathf.Infinity;

            foreach (ParticleSystem ps in m_SelectedParticleSystems)
            {
                ps.CalculateEffectUIData(ref particleCount, ref fastestParticle, ref slowestParticle);
            }
            EditorGUILayout.LabelField(s_Texts.particleCount, GUIContent.Temp(particleCount.ToString()));

            bool hasSubEmitters      = false;
            int  subEmitterParticles = 0;

            foreach (ParticleSystem ps in m_SelectedParticleSystems)
            {
                int subEmitterParticlesCurrent = 0;
                if (ps.CalculateEffectUISubEmitterData(ref subEmitterParticlesCurrent, ref fastestParticle, ref slowestParticle))
                {
                    hasSubEmitters       = true;
                    subEmitterParticles += subEmitterParticlesCurrent;
                }
            }
            if (hasSubEmitters)
            {
                EditorGUILayout.LabelField(s_Texts.subEmitterParticleCount, GUIContent.Temp(subEmitterParticles.ToString()));
            }

            if (fastestParticle >= slowestParticle)
            {
                EditorGUILayout.LabelField(s_Texts.particleSpeeds, GUIContent.Temp(slowestParticle.ToString(s_Texts.speedFloatFieldFormatString) + " - " + fastestParticle.ToString(s_Texts.speedFloatFieldFormatString)));
            }
            else
            {
                EditorGUILayout.LabelField(s_Texts.particleSpeeds, GUIContent.Temp("0.0 - 0.0"));
            }

            if (!EditorApplication.isPlaying)
            {
                EditorGUILayout.LayerMaskField(ParticleSystemEditorUtils.previewLayers, s_Texts.previewLayers, SetPreviewLayersDelegate);
                ParticleSystemEditorUtils.resimulation = GUILayout.Toggle(ParticleSystemEditorUtils.resimulation, s_Texts.resimulation, EditorStyles.toggle);
            }

            ParticleEffectUI.m_ShowBounds = GUILayout.Toggle(ParticleEffectUI.m_ShowBounds, ParticleEffectUI.texts.showBounds, EditorStyles.toggle);

            EditorGUIUtility.labelWidth = 0.0f;
        }
示例#18
0
            public void DrawProjection()
            {
                ProjectionType projectionType = orthographic.boolValue ? ProjectionType.Orthographic : ProjectionType.Perspective;

                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = orthographic.hasMultipleDifferentValues;
                projectionType           = (ProjectionType)EditorGUILayout.EnumPopup(Styles.projection, projectionType);
                EditorGUI.showMixedValue = false;
                if (EditorGUI.EndChangeCheck())
                {
                    orthographic.boolValue = (projectionType == ProjectionType.Orthographic);
                }

                if (!orthographic.hasMultipleDifferentValues)
                {
                    if (projectionType == ProjectionType.Orthographic)
                    {
                        EditorGUILayout.PropertyField(orthographicSize, Styles.size);
                    }
                    else
                    {
                        float fovCurrentValue;
                        bool  multipleDifferentFovValues = false;
                        bool  isPhysicalCamera           = projectionMatrixMode.intValue == (int)Camera.ProjectionMatrixMode.PhysicalPropertiesBased;

                        var rect       = EditorGUILayout.GetControlRect();
                        var guiContent = EditorGUI.BeginProperty(rect, Styles.FOVAxisMode, fovAxisMode);
                        EditorGUI.showMixedValue = fovAxisMode.hasMultipleDifferentValues;

                        EditorGUI.BeginChangeCheck();
                        var fovAxisNewVal = (int)(Camera.FieldOfViewAxis)EditorGUI.EnumPopup(rect, guiContent, (Camera.FieldOfViewAxis)fovAxisMode.intValue);
                        if (EditorGUI.EndChangeCheck())
                        {
                            fovAxisMode.intValue = fovAxisNewVal;
                        }
                        EditorGUI.EndProperty();

                        bool fovAxisVertical = fovAxisMode.intValue == 0;

                        if (!fovAxisVertical && !fovAxisMode.hasMultipleDifferentValues)
                        {
                            var   targets     = m_SerializedObject.targetObjects;
                            var   camera0     = targets[0] as Camera;
                            float aspectRatio = isPhysicalCamera ? sensorSize.vector2Value.x / sensorSize.vector2Value.y : camera0.aspect;
                            // camera.aspect is not serialized so we have to check all targets.
                            fovCurrentValue = Camera.VerticalToHorizontalFieldOfView(camera0.fieldOfView, aspectRatio);
                            if (m_SerializedObject.targetObjectsCount > 1)
                            {
                                foreach (Camera camera in targets)
                                {
                                    if (camera.fieldOfView != fovCurrentValue)
                                    {
                                        multipleDifferentFovValues = true;
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            fovCurrentValue            = verticalFOV.floatValue;
                            multipleDifferentFovValues = fovAxisMode.hasMultipleDifferentValues;
                        }

                        EditorGUI.showMixedValue = multipleDifferentFovValues;
                        var content = EditorGUI.BeginProperty(EditorGUILayout.BeginHorizontal(), Styles.fieldOfView, verticalFOV);
                        EditorGUI.BeginDisabled(projectionMatrixMode.hasMultipleDifferentValues || isPhysicalCamera && (sensorSize.hasMultipleDifferentValues || fovAxisMode.hasMultipleDifferentValues));
                        EditorGUI.BeginChangeCheck();
                        var fovNewValue = EditorGUILayout.Slider(content, fovCurrentValue, 0.00001f, 179f);
                        var fovChanged  = EditorGUI.EndChangeCheck();
                        EditorGUI.EndDisabled();
                        EditorGUILayout.EndHorizontal();
                        EditorGUI.EndProperty();
                        EditorGUI.showMixedValue = false;

                        content = EditorGUI.BeginProperty(EditorGUILayout.BeginHorizontal(), Styles.physicalCamera, projectionMatrixMode);
                        EditorGUI.showMixedValue = projectionMatrixMode.hasMultipleDifferentValues;

                        EditorGUI.BeginChangeCheck();
                        isPhysicalCamera = EditorGUILayout.Toggle(content, isPhysicalCamera);
                        if (EditorGUI.EndChangeCheck())
                        {
                            projectionMatrixMode.intValue = isPhysicalCamera ? (int)Camera.ProjectionMatrixMode.PhysicalPropertiesBased : (int)Camera.ProjectionMatrixMode.Implicit;
                        }
                        EditorGUILayout.EndHorizontal();
                        EditorGUI.EndProperty();

                        EditorGUI.showMixedValue = false;
                        if (isPhysicalCamera && !projectionMatrixMode.hasMultipleDifferentValues)
                        {
                            using (new EditorGUI.IndentLevelScope())
                            {
                                using (var horizontal = new EditorGUILayout.HorizontalScope())
                                    using (new EditorGUI.PropertyScope(horizontal.rect, Styles.focalLength, focalLength))
                                        using (var checkScope = new EditorGUI.ChangeCheckScope())
                                        {
                                            EditorGUI.showMixedValue = focalLength.hasMultipleDifferentValues;
                                            float sensorLength   = fovAxisVertical ? sensorSize.vector2Value.y : sensorSize.vector2Value.x;
                                            float focalLengthVal = fovChanged ? Camera.FieldOfViewToFocalLength(fovNewValue, sensorLength) : focalLength.floatValue;
                                            focalLengthVal = EditorGUILayout.FloatField(Styles.focalLength, focalLengthVal);
                                            if (checkScope.changed || fovChanged)
                                            {
                                                focalLength.floatValue = focalLengthVal;
                                            }
                                        }

                                EditorGUI.showMixedValue = sensorSize.hasMultipleDifferentValues;
                                EditorGUI.BeginChangeCheck();
                                int filmGateIndex = Array.IndexOf(k_ApertureFormatValues, new Vector2((float)Math.Round(sensorSize.vector2Value.x, 3), (float)Math.Round(sensorSize.vector2Value.y, 3)));
                                if (filmGateIndex == -1)
                                {
                                    filmGateIndex = EditorGUILayout.Popup(Styles.cameraType, k_ApertureFormatNames.Length - 1, k_ApertureFormatNames);
                                }
                                else
                                {
                                    filmGateIndex = EditorGUILayout.Popup(Styles.cameraType, filmGateIndex, k_ApertureFormatNames);
                                }
                                EditorGUI.showMixedValue = false;
                                if (EditorGUI.EndChangeCheck() && filmGateIndex < k_ApertureFormatValues.Length)
                                {
                                    sensorSize.vector2Value = k_ApertureFormatValues[filmGateIndex];
                                }

                                EditorGUILayout.PropertyField(sensorSize, Styles.sensorSize);

                                EditorGUILayout.PropertyField(lensShift, Styles.lensShift);

                                using (var horizontal = new EditorGUILayout.HorizontalScope())
                                    using (var propertyScope = new EditorGUI.PropertyScope(horizontal.rect, Styles.gateFit, gateFit))
                                        using (var checkScope = new EditorGUI.ChangeCheckScope())
                                        {
                                            int gateValue = (int)(Camera.GateFitMode)EditorGUILayout.EnumPopup(propertyScope.content, (Camera.GateFitMode)gateFit.intValue);
                                            if (checkScope.changed)
                                            {
                                                gateFit.intValue = gateValue;
                                            }
                                        }
                            }
                        }
                        else if (fovChanged)
                        {
                            verticalFOV.floatValue = fovAxisVertical ? fovNewValue : Camera.HorizontalToVerticalFieldOfView(fovNewValue, (m_SerializedObject.targetObjects[0] as Camera).aspect);
                        }
                        EditorGUILayout.Space();
                    }
                }
            }
示例#19
0
    public void OnGUI()
    {
        EditorGUIUtility.labelWidth = 75;
        if (atomMapHolder == null)
        {
            atomMapHolder = GameObject.Find("Atom Map List").transform;
            if (atomMapHolder == null)
            {
                GUI.Label(new Rect((position.width - 100) / 2, (position.height - 20) / 2, 100, 20), "NO ATOM MAP LIST");
                return;
            }
        }

        if (ionMapHolder == null)
        {
            ionMapHolder = GameObject.Find("Ion Map List").transform;
            if (ionMapHolder == null)
            {
                GUI.Label(new Rect((position.width - 100) / 2, (position.height - 20) / 2, 100, 20), "NO ION MAP LIST");
                return;
            }
        }

        if (atomMap == null || ionMap == null)
        {
            SetTargetMap(0);
        }

        GL.BeginHorizontal();
        type      = (IonType)EGL.EnumPopup("Ion Type:", type);
        behaviour = (IonBehaviour)EGL.EnumPopup("Behaviour:", behaviour);
        GL.EndHorizontal();

        radiusIndex = EGL.IntSlider("Radius:", radiusIndex, 0, 500);

        GL.Label("Subdivision:");
        subdivIndex  = GL.Toolbar(subdivIndex, subdivLabels);
        subdivOffset = EGL.IntField("Subdiv Offset:", subdivOffset);

        if (behaviour == IonBehaviour.Orbit)
        {
            orbitFreq    = EGL.FloatField("Orbit Speed:", orbitFreq);
            resetTrigger = (Atom)EGL.ObjectField("Reset Trig:", resetTrigger, typeof(Atom));
        }

        bool prevEditingState = isEditing;

        GL.BeginHorizontal();
        //GL.Label("");
        isEditing = GL.Toggle(isEditing, "Enable/Disable Editing");
        if (isEditing != prevEditingState)
        {
            ToggleEditing(isEditing);
        }

        int prevTarget = targetMapIndex;

        targetMapIndex = (int)Mathf.Clamp(EGL.IntField("Target Map", targetMapIndex), 0, atomMapHolder.childCount - 1);
        if (prevTarget != targetMapIndex)
        {
            SetTargetMap(targetMapIndex);
        }
        GL.EndHorizontal();

        radius = radiusIndex * baseRadiusUnit;
        subdiv = subdivOptions[subdivIndex];
    }
        private static void DoEditRegularParameters(AnimationEvent[] events, Type selectedParameter)
        {
            AnimationEvent firstEvent = events[0];

            if (selectedParameter == typeof(AnimationEvent) || selectedParameter == typeof(float))
            {
                bool singleParamValue = Array.TrueForAll(events, evt => evt.floatParameter == firstEvent.floatParameter);

                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = !singleParamValue;
                float newValue = EditorGUILayout.FloatField("Float", firstEvent.floatParameter);
                EditorGUI.showMixedValue = false;

                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var evt in events)
                        evt.floatParameter = newValue;
                }
            }

            if (selectedParameter == typeof(AnimationEvent) || selectedParameter == typeof(int) || selectedParameter.IsEnum)
            {
                bool singleParamValue = Array.TrueForAll(events, evt => evt.intParameter == firstEvent.intParameter);

                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = !singleParamValue;
                int newValue = 0;
                if (selectedParameter.IsEnum)
                    newValue = EnumPopup("Enum", selectedParameter, firstEvent.intParameter);
                else
                    newValue = EditorGUILayout.IntField("Int", firstEvent.intParameter);
                EditorGUI.showMixedValue = false;

                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var evt in events)
                        evt.intParameter = newValue;
                }
            }

            if (selectedParameter == typeof(AnimationEvent) || selectedParameter == typeof(string))
            {
                bool singleParamValue = Array.TrueForAll(events, evt => evt.stringParameter == firstEvent.stringParameter);

                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = !singleParamValue;
                string newValue = EditorGUILayout.TextField("String", firstEvent.stringParameter);
                EditorGUI.showMixedValue = false;

                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var evt in events)
                        evt.stringParameter = newValue;
                }
            }

            if (selectedParameter == typeof(AnimationEvent) || selectedParameter.IsSubclassOf(typeof(UnityEngine.Object)) || selectedParameter == typeof(UnityEngine.Object))
            {
                bool singleParamValue = Array.TrueForAll(events, evt => evt.objectReferenceParameter == firstEvent.objectReferenceParameter);

                EditorGUI.BeginChangeCheck();
                Type type = typeof(UnityEngine.Object);
                if (selectedParameter != typeof(AnimationEvent))
                    type = selectedParameter;

                EditorGUI.showMixedValue = !singleParamValue;
                bool allowSceneObjects = false;
                Object newValue = EditorGUILayout.ObjectField(ObjectNames.NicifyVariableName(type.Name), firstEvent.objectReferenceParameter, type, allowSceneObjects);
                EditorGUI.showMixedValue = false;

                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var evt in events)
                        evt.objectReferenceParameter = newValue;
                }
            }
        }
示例#21
0
        private void DrawOneView(Rect drawPos, LookDevEditionContext context)
        {
            bool flag = (this.m_LookDevView.config.lookDevMode != LookDevMode.Single1 && context == LookDevEditionContext.Left) || (this.m_LookDevView.config.lookDevMode != LookDevMode.Single2 && context == LookDevEditionContext.Right);

            GUILayout.BeginArea(drawPos);
            GUILayout.Label(LookDevViewsWindow.styles.sViewTitle[(int)context], LookDevViewsWindow.styles.sViewTitleStyles[(int)context], new GUILayoutOption[0]);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.BeginVertical(new GUILayoutOption[]
            {
                GUILayout.Width(this.m_WindowWidth)
            });
            GUILayout.BeginHorizontal(new GUILayoutOption[]
            {
                GUILayout.Height(LookDevViewsWindow.kLineHeight)
            });
            GUILayout.Label(LookDevViewsWindow.styles.sExposure, LookDevViewsWindow.styles.sMenuItem, new GUILayoutOption[]
            {
                GUILayout.Width(LookDevViewsWindow.kLabelWidth)
            });
            float num = this.m_LookDevView.config.GetFloatProperty(LookDevProperty.ExposureValue, context);

            EditorGUI.BeginChangeCheck();
            float num2 = Mathf.Round(this.m_LookDevView.config.exposureRange);

            num = Mathf.Clamp(GUILayout.HorizontalSlider(num, -num2, num2, new GUILayoutOption[]
            {
                GUILayout.Width(LookDevViewsWindow.kSliderWidth)
            }), -num2, num2);
            num = Mathf.Clamp(EditorGUILayout.FloatField((float)Math.Round((double)num, (num >= 0f) ? 2 : 1), new GUILayoutOption[]
            {
                GUILayout.Width(LookDevViewsWindow.kSliderFieldWidth)
            }), -num2, num2);
            if (EditorGUI.EndChangeCheck())
            {
                this.m_LookDevView.config.UpdateFocus(context);
                this.m_LookDevView.config.UpdateFloatProperty(LookDevProperty.ExposureValue, num);
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(new GUILayoutOption[]
            {
                GUILayout.Height(LookDevViewsWindow.kLineHeight)
            });
            int hdriCount = this.m_LookDevView.envLibrary.hdriCount;

            using (new EditorGUI.DisabledScope(hdriCount <= 1))
            {
                GUILayout.Label(LookDevViewsWindow.styles.sEnvironment, LookDevViewsWindow.styles.sMenuItem, new GUILayoutOption[]
                {
                    GUILayout.Width(LookDevViewsWindow.kLabelWidth)
                });
                if (hdriCount > 1)
                {
                    int num3 = hdriCount - 1;
                    int num4 = this.m_LookDevView.config.GetIntProperty(LookDevProperty.HDRI, context);
                    EditorGUI.BeginChangeCheck();
                    num4 = (int)GUILayout.HorizontalSlider((float)num4, 0f, (float)num3, new GUILayoutOption[]
                    {
                        GUILayout.Width(LookDevViewsWindow.kSliderWidth)
                    });
                    num4 = Mathf.Clamp(EditorGUILayout.IntField(num4, new GUILayoutOption[]
                    {
                        GUILayout.Width(LookDevViewsWindow.kSliderFieldWidth)
                    }), 0, num3);
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.m_LookDevView.config.UpdateFocus(context);
                        this.m_LookDevView.config.UpdateIntProperty(LookDevProperty.HDRI, num4);
                    }
                }
                else
                {
                    GUILayout.HorizontalSlider(0f, 0f, 0f, new GUILayoutOption[]
                    {
                        GUILayout.Width(LookDevViewsWindow.kSliderWidth)
                    });
                    GUILayout.Label(LookDevViewsWindow.styles.sZero, LookDevViewsWindow.styles.sMenuItem, new GUILayoutOption[0]);
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(new GUILayoutOption[]
            {
                GUILayout.Height(LookDevViewsWindow.kLineHeight)
            });
            GUILayout.Label(LookDevViewsWindow.styles.sShadingMode, LookDevViewsWindow.styles.sMenuItem, new GUILayoutOption[]
            {
                GUILayout.Width(LookDevViewsWindow.kLabelWidth)
            });
            int num5 = this.m_LookDevView.config.GetIntProperty(LookDevProperty.ShadingMode, context);

            EditorGUI.BeginChangeCheck();
            num5 = EditorGUILayout.IntPopup("", num5, LookDevViewsWindow.styles.sShadingModeStrings, LookDevViewsWindow.styles.sShadingModeValues, new GUILayoutOption[]
            {
                GUILayout.Width(LookDevViewsWindow.kSliderFieldWidth + LookDevViewsWindow.kSliderWidth + 4f)
            });
            if (EditorGUI.EndChangeCheck())
            {
                this.m_LookDevView.config.UpdateFocus(context);
                this.m_LookDevView.config.UpdateIntProperty(LookDevProperty.ShadingMode, num5);
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(new GUILayoutOption[]
            {
                GUILayout.Height(LookDevViewsWindow.kLineHeight)
            });
            GUILayout.Label(LookDevViewsWindow.styles.sRotation, LookDevViewsWindow.styles.sMenuItem, new GUILayoutOption[]
            {
                GUILayout.Width(LookDevViewsWindow.kLabelWidth)
            });
            float num6 = this.m_LookDevView.config.GetFloatProperty(LookDevProperty.EnvRotation, context);

            EditorGUI.BeginChangeCheck();
            num6 = GUILayout.HorizontalSlider(num6, 0f, 720f, new GUILayoutOption[]
            {
                GUILayout.Width(LookDevViewsWindow.kSliderWidth)
            });
            num6 = Mathf.Clamp(EditorGUILayout.FloatField((float)Math.Round((double)num6, 0), new GUILayoutOption[]
            {
                GUILayout.Width(LookDevViewsWindow.kSliderFieldWidth)
            }), 0f, 720f);
            if (EditorGUI.EndChangeCheck())
            {
                this.m_LookDevView.config.UpdateFocus(context);
                this.m_LookDevView.config.UpdateFloatProperty(LookDevProperty.EnvRotation, num6);
            }
            GUILayout.EndHorizontal();
            if (this.NeedLoD())
            {
                GUILayout.BeginHorizontal(new GUILayoutOption[]
                {
                    GUILayout.Height(LookDevViewsWindow.kLineHeight)
                });
                if (this.m_LookDevView.config.GetObjectLoDCount(context) > 1)
                {
                    int num7 = this.m_LookDevView.config.GetIntProperty(LookDevProperty.LoDIndex, context);
                    GUILayout.Label((num7 != -1) ? LookDevViewsWindow.styles.sLoD : LookDevViewsWindow.styles.sLoDAuto, LookDevViewsWindow.styles.sMenuItem, new GUILayoutOption[]
                    {
                        GUILayout.Width(LookDevViewsWindow.kLabelWidth)
                    });
                    EditorGUI.BeginChangeCheck();
                    int num8 = this.m_LookDevView.config.GetObjectLoDCount(context) - 1;
                    if (this.m_LookDevView.config.lookDevMode != LookDevMode.Single1 && this.m_LookDevView.config.lookDevMode != LookDevMode.Single2 && this.m_LookDevView.config.IsPropertyLinked(LookDevProperty.LoDIndex))
                    {
                        num8 = Math.Min(this.m_LookDevView.config.GetObjectLoDCount(LookDevEditionContext.Left), this.m_LookDevView.config.GetObjectLoDCount(LookDevEditionContext.Right)) - 1;
                    }
                    num7 = Mathf.Clamp(num7, -1, num8);
                    num7 = (int)GUILayout.HorizontalSlider((float)num7, -1f, (float)num8, new GUILayoutOption[]
                    {
                        GUILayout.Width(LookDevViewsWindow.kSliderWidth)
                    });
                    num7 = EditorGUILayout.IntField(num7, new GUILayoutOption[]
                    {
                        GUILayout.Width(LookDevViewsWindow.kSliderFieldWidth)
                    });
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.m_LookDevView.config.UpdateFocus(context);
                        this.m_LookDevView.config.UpdateIntProperty(LookDevProperty.LoDIndex, num7);
                    }
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
            if (flag)
            {
                GUILayout.BeginVertical(new GUILayoutOption[]
                {
                    GUILayout.Width(LookDevViewsWindow.kIconSize)
                });
                LookDevProperty[] array = new LookDevProperty[]
                {
                    LookDevProperty.ExposureValue,
                    LookDevProperty.HDRI,
                    LookDevProperty.ShadingMode,
                    LookDevProperty.EnvRotation,
                    LookDevProperty.LoDIndex
                };
                int num9 = 4 + ((!this.NeedLoD()) ? 0 : 1);
                for (int i = 0; i < num9; i++)
                {
                    EditorGUI.BeginChangeCheck();
                    bool flag2 = this.m_LookDevView.config.IsPropertyLinked(array[i]);
                    bool value = GUILayout.Toggle(flag2, this.GetGUIContentLink(flag2), LookDevViewsWindow.styles.sToolBarButton, new GUILayoutOption[]
                    {
                        GUILayout.Height(LookDevViewsWindow.kLineHeight)
                    });
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.m_LookDevView.config.UpdatePropertyLink(array[i], value);
                    }
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }