Пример #1
0
        void LayoutButton(Action <Transform[]> layoutFucntion)
        {
            if (EditorGUI.EndChangeCheck() && _applyContinuously)
            {
                layoutFucntion(GetOrderedSelection());
            }

            EditorGUILayout.BeginVertical();
            GUILayout.FlexibleSpace();


            EditorGUILayout.BeginHorizontal();

            EditorGUI.BeginDisabledGroup(Selection.transforms.Length <= 1 || _applyContinuously);
            if (GUILayout.Button("Layout"))
            {
                layoutFucntion(GetOrderedSelection());
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginChangeCheck();
            _applyContinuously = EditorGUILayout.ToggleLeft("AUTO", _applyContinuously, GUILayout.Width(50));
            if (EditorGUI.EndChangeCheck() && _applyContinuously)
            {
                layoutFucntion(GetOrderedSelection());
            }

            EditorGUILayout.EndHorizontal();



            EditorGUILayout.EndVertical();
        }
Пример #2
0
        void OnGUI()
        {
            EditorGUI.BeginChangeCheck();
            _tab = (Tab)GUILayout.Toolbar((int)_tab, Enum.GetNames(typeof(Tab)));
            if (EditorGUI.EndChangeCheck())
            {
                _applyContinuously = false;
            }

            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();

            switch (_tab)
            {
            case Tab.Line: LineTab(); break;

            case Tab.Grid: GridTab(); break;

            case Tab.Radial: RadialTab(); break;
            }
        }
        public override void OnInspectorGUI()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                EditorGUILayout.HelpBox("Changes made in play mode will not be saved.", MessageType.Warning, true);
            }

            m_QualitySettings.Update();

            var settings      = GetQualitySettings();
            var defaults      = GetDefaultQualityForPlatforms();
            var selectedLevel = QualitySettings.GetQualityLevel();

            EditorGUI.BeginChangeCheck();
            selectedLevel = DoQualityLevelSelection(selectedLevel, settings, defaults);
            if (EditorGUI.EndChangeCheck())
            {
                QualitySettings.SetQualityLevel(selectedLevel);
            }

            SetQualitySettings(settings);
            HandleAddRemoveQualitySetting(ref selectedLevel, defaults);
            SetDefaultQualityForPlatforms(defaults);
            GUILayout.Space(10.0f);
            DrawHorizontalDivider();
            GUILayout.Space(10.0f);

            var currentSettings                         = m_QualitySettingsProperty.GetArrayElementAtIndex(selectedLevel);
            var nameProperty                            = currentSettings.FindPropertyRelative("name");
            var pixelLightCountProperty                 = currentSettings.FindPropertyRelative("pixelLightCount");
            var shadowsProperty                         = currentSettings.FindPropertyRelative("shadows");
            var shadowResolutionProperty                = currentSettings.FindPropertyRelative("shadowResolution");
            var shadowProjectionProperty                = currentSettings.FindPropertyRelative("shadowProjection");
            var shadowCascadesProperty                  = currentSettings.FindPropertyRelative("shadowCascades");
            var shadowDistanceProperty                  = currentSettings.FindPropertyRelative("shadowDistance");
            var shadowNearPlaneOffsetProperty           = currentSettings.FindPropertyRelative("shadowNearPlaneOffset");
            var shadowCascade2SplitProperty             = currentSettings.FindPropertyRelative("shadowCascade2Split");
            var shadowCascade4SplitProperty             = currentSettings.FindPropertyRelative("shadowCascade4Split");
            var shadowMaskUsageProperty                 = currentSettings.FindPropertyRelative("shadowmaskMode");
            var blendWeightsProperty                    = currentSettings.FindPropertyRelative("blendWeights");
            var textureQualityProperty                  = currentSettings.FindPropertyRelative("textureQuality");
            var anisotropicTexturesProperty             = currentSettings.FindPropertyRelative("anisotropicTextures");
            var antiAliasingProperty                    = currentSettings.FindPropertyRelative("antiAliasing");
            var softParticlesProperty                   = currentSettings.FindPropertyRelative("softParticles");
            var realtimeReflectionProbes                = currentSettings.FindPropertyRelative("realtimeReflectionProbes");
            var billboardsFaceCameraPosition            = currentSettings.FindPropertyRelative("billboardsFaceCameraPosition");
            var vSyncCountProperty                      = currentSettings.FindPropertyRelative("vSyncCount");
            var lodBiasProperty                         = currentSettings.FindPropertyRelative("lodBias");
            var maximumLODLevelProperty                 = currentSettings.FindPropertyRelative("maximumLODLevel");
            var particleRaycastBudgetProperty           = currentSettings.FindPropertyRelative("particleRaycastBudget");
            var asyncUploadTimeSliceProperty            = currentSettings.FindPropertyRelative("asyncUploadTimeSlice");
            var asyncUploadBufferSizeProperty           = currentSettings.FindPropertyRelative("asyncUploadBufferSize");
            var resolutionScalingFixedDPIFactorProperty = currentSettings.FindPropertyRelative("resolutionScalingFixedDPIFactor");

            bool usingSRP = GraphicsSettings.renderPipelineAsset != null;

            if (string.IsNullOrEmpty(nameProperty.stringValue))
            {
                nameProperty.stringValue = "Level " + selectedLevel;
            }

            EditorGUILayout.PropertyField(nameProperty);

            if (usingSRP)
            {
                EditorGUILayout.HelpBox("A Scriptable Render Pipeline is in use, some settings will not be used and are hidden", MessageType.Info);
            }

            GUILayout.Space(10);

            GUILayout.Label(EditorGUIUtility.TempContent("Rendering"), EditorStyles.boldLabel);
            if (!usingSRP)
            {
                EditorGUILayout.PropertyField(pixelLightCountProperty);
            }

            // still valid with SRP
            EditorGUILayout.PropertyField(textureQualityProperty);
            EditorGUILayout.PropertyField(anisotropicTexturesProperty);

            if (!usingSRP)
            {
                EditorGUILayout.PropertyField(antiAliasingProperty);
                EditorGUILayout.PropertyField(softParticlesProperty);
                if (softParticlesProperty.boolValue)
                {
                    SoftParticlesHintGUI();
                }
            }

            EditorGUILayout.PropertyField(realtimeReflectionProbes);
            EditorGUILayout.PropertyField(billboardsFaceCameraPosition, Styles.kBillboardsFaceCameraPos);
            EditorGUILayout.PropertyField(resolutionScalingFixedDPIFactorProperty);

            var streamingMipmapsActiveProperty = currentSettings.FindPropertyRelative("streamingMipmapsActive");

            EditorGUILayout.PropertyField(streamingMipmapsActiveProperty, Styles.kStreamingMipmapsActive);
            if (streamingMipmapsActiveProperty.boolValue)
            {
                EditorGUI.indentLevel++;
                var streamingMipmapsAddAllCameras = currentSettings.FindPropertyRelative("streamingMipmapsAddAllCameras");
                EditorGUILayout.PropertyField(streamingMipmapsAddAllCameras, Styles.kStreamingMipmapsAddAllCameras);
                var streamingMipmapsBudgetProperty = currentSettings.FindPropertyRelative("streamingMipmapsMemoryBudget");
                EditorGUILayout.PropertyField(streamingMipmapsBudgetProperty, Styles.kStreamingMipmapsMemoryBudget);
                var streamingMipmapsRenderersPerFrameProperty = currentSettings.FindPropertyRelative("streamingMipmapsRenderersPerFrame");
                EditorGUILayout.PropertyField(streamingMipmapsRenderersPerFrameProperty, Styles.kStreamingMipmapsRenderersPerFrame);
                var streamingMipmapsMaxLevelReductionProperty = currentSettings.FindPropertyRelative("streamingMipmapsMaxLevelReduction");
                EditorGUILayout.PropertyField(streamingMipmapsMaxLevelReductionProperty, Styles.kStreamingMipmapsMaxLevelReduction);
                var streamingMipmapsMaxFileIORequestsProperty = currentSettings.FindPropertyRelative("streamingMipmapsMaxFileIORequests");
                EditorGUILayout.PropertyField(streamingMipmapsMaxFileIORequestsProperty, Styles.kStreamingMipmapsMaxFileIORequests);
                EditorGUI.indentLevel--;
            }


            GUILayout.Space(10);

            GUILayout.Label(EditorGUIUtility.TempContent("Shadows"), EditorStyles.boldLabel);
            if (SupportedRenderingFeatures.IsMixedLightingModeSupported(MixedLightingMode.Shadowmask))
            {
                EditorGUILayout.PropertyField(shadowMaskUsageProperty);
            }

            if (!usingSRP)
            {
                EditorGUILayout.PropertyField(shadowsProperty);
                EditorGUILayout.PropertyField(shadowResolutionProperty);
                EditorGUILayout.PropertyField(shadowProjectionProperty);
                EditorGUILayout.PropertyField(shadowDistanceProperty);
                EditorGUILayout.PropertyField(shadowNearPlaneOffsetProperty);
                EditorGUILayout.PropertyField(shadowCascadesProperty);

                if (shadowCascadesProperty.intValue == 2)
                {
                    DrawCascadeSplitGUI <float>(ref shadowCascade2SplitProperty);
                }
                else if (shadowCascadesProperty.intValue == 4)
                {
                    DrawCascadeSplitGUI <Vector3>(ref shadowCascade4SplitProperty);
                }
            }

            GUILayout.Space(10);
            GUILayout.Label(EditorGUIUtility.TempContent("Other"), EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(blendWeightsProperty);
            EditorGUILayout.PropertyField(vSyncCountProperty);
            EditorGUILayout.PropertyField(lodBiasProperty);
            EditorGUILayout.PropertyField(maximumLODLevelProperty);
            EditorGUILayout.PropertyField(particleRaycastBudgetProperty);
            EditorGUILayout.PropertyField(asyncUploadTimeSliceProperty);
            EditorGUILayout.PropertyField(asyncUploadBufferSizeProperty);

            asyncUploadTimeSliceProperty.intValue  = Mathf.Clamp(asyncUploadTimeSliceProperty.intValue, kMinAsyncUploadTimeSlice, kMaxAsyncUploadTimeSlice);
            asyncUploadBufferSizeProperty.intValue = Mathf.Clamp(asyncUploadBufferSizeProperty.intValue, kMinAsyncRingBufferSize, kMaxAsyncRingBufferSize);

            if (m_Dragging != null && m_Dragging.m_Position != m_Dragging.m_StartPosition)
            {
                m_QualitySettingsProperty.MoveArrayElement(m_Dragging.m_StartPosition, m_Dragging.m_Position);
                m_Dragging.m_StartPosition = m_Dragging.m_Position;
                selectedLevel = m_Dragging.m_Position;

                m_QualitySettings.ApplyModifiedProperties();
                QualitySettings.SetQualityLevel(Mathf.Clamp(selectedLevel, 0, m_QualitySettingsProperty.arraySize - 1));
            }

            m_QualitySettings.ApplyModifiedProperties();
        }
 private void DrawControls()
 {
     if ((Object)this.m_Manager == (Object)null)
     {
         return;
     }
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.PropertyField(this.m_HostMigrationProperty, this.m_HostMigrationLabel, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_ShowGUIProperty);
     if (this.m_Manager.showGUI)
     {
         EditorGUILayout.PropertyField(this.m_OffsetXProperty);
         EditorGUILayout.PropertyField(this.m_OffsetYProperty);
     }
     if (EditorGUI.EndChangeCheck())
     {
         this.serializedObject.ApplyModifiedProperties();
     }
     if (!Application.isPlaying)
     {
         return;
     }
     EditorGUILayout.Separator();
     EditorGUILayout.LabelField("Disconnected From Host", this.m_Manager.disconnectedFromHost.ToString(), new GUILayoutOption[0]);
     EditorGUILayout.LabelField("Waiting to become New Host", this.m_Manager.waitingToBecomeNewHost.ToString(), new GUILayoutOption[0]);
     EditorGUILayout.LabelField("Waitingto Reconnect to New Host", this.m_Manager.waitingReconnectToNewHost.ToString(), new GUILayoutOption[0]);
     EditorGUILayout.LabelField("Your ConnectionId", this.m_Manager.oldServerConnectionId.ToString(), new GUILayoutOption[0]);
     EditorGUILayout.LabelField("New Host Address", this.m_Manager.newHostAddress, new GUILayoutOption[0]);
     if (this.m_Manager.peers != null)
     {
         this.m_ShowPeers = EditorGUILayout.Foldout(this.m_ShowPeers, "Peers");
         if (this.m_ShowPeers)
         {
             ++EditorGUI.indentLevel;
             foreach (PeerInfoMessage peer in this.m_Manager.peers)
             {
                 EditorGUILayout.LabelField("Peer: ", peer.ToString(), new GUILayoutOption[0]);
             }
             --EditorGUI.indentLevel;
         }
     }
     if (this.m_Manager.pendingPlayers == null)
     {
         return;
     }
     this.m_ShowPlayers = EditorGUILayout.Foldout(this.m_ShowPlayers, "Pending Players");
     if (!this.m_ShowPlayers)
     {
         return;
     }
     ++EditorGUI.indentLevel;
     using (Dictionary <int, NetworkMigrationManager.ConnectionPendingPlayers> .KeyCollection.Enumerator enumerator1 = this.m_Manager.pendingPlayers.Keys.GetEnumerator())
     {
         while (enumerator1.MoveNext())
         {
             int current1 = enumerator1.Current;
             EditorGUILayout.LabelField("Connection: ", current1.ToString(), new GUILayoutOption[0]);
             ++EditorGUI.indentLevel;
             using (List <NetworkMigrationManager.PendingPlayerInfo> .Enumerator enumerator2 = this.m_Manager.pendingPlayers[current1].players.GetEnumerator())
             {
                 while (enumerator2.MoveNext())
                 {
                     NetworkMigrationManager.PendingPlayerInfo current2 = enumerator2.Current;
                     EditorGUILayout.ObjectField("Player netId:" + (object)current2.netId + " contId:" + (object)current2.playerControllerId, (Object)current2.obj, typeof(GameObject), false, new GUILayoutOption[0]);
                 }
             }
             --EditorGUI.indentLevel;
         }
     }
     --EditorGUI.indentLevel;
 }
        override public void OnInspectorGUI(InitialModuleUI initial)
        {
            EditorGUI.BeginChangeCheck();
            CollisionTypes type = (CollisionTypes)GUIPopup(s_Texts.collisionType, m_Type, s_Texts.collisionTypes);

            if (EditorGUI.EndChangeCheck())
            {
                SyncVisualization();
            }

            if (type == CollisionTypes.Plane)
            {
                DoListOfPlanesGUI();

                EditorGUI.BeginChangeCheck();
                m_PlaneVisualizationType = (PlaneVizType)GUIPopup(s_Texts.visualization, (int)m_PlaneVisualizationType, s_Texts.planeVizTypes);
                if (EditorGUI.EndChangeCheck())
                {
                    EditorPrefs.SetInt("PlaneColisionVizType", (int)m_PlaneVisualizationType);
                }

                EditorGUI.BeginChangeCheck();
                m_ScaleGrid = GUIFloat(s_Texts.scalePlane, m_ScaleGrid, "f2");
                if (EditorGUI.EndChangeCheck())
                {
                    m_ScaleGrid = Mathf.Max(0f, m_ScaleGrid);
                    EditorPrefs.SetFloat("ScalePlaneColision", m_ScaleGrid);
                }

                GUIButtonGroup(s_Texts.sceneViewEditModes, s_Texts.toolContents, GetBounds, m_ParticleSystemUI.m_ParticleEffectUI.m_Owner.customEditor);
            }
            else
            {
                GUIPopup(s_Texts.collisionMode, m_CollisionMode, s_Texts.collisionModes);
            }

            GUIMinMaxCurve(s_Texts.dampen, m_Dampen);
            GUIMinMaxCurve(s_Texts.bounce, m_Bounce);
            GUIMinMaxCurve(s_Texts.lifetimeLoss, m_LifetimeLossOnCollision);
            GUIFloat(s_Texts.minKillSpeed, m_MinKillSpeed);
            GUIFloat(s_Texts.maxKillSpeed, m_MaxKillSpeed);
            GUIFloat(s_Texts.radiusScale, m_RadiusScale);

            if (type == CollisionTypes.World)
            {
                GUIPopup(s_Texts.quality, m_Quality, s_Texts.qualitySettings);
                EditorGUI.indentLevel++;
                GUILayerMask(s_Texts.collidesWith, m_CollidesWith);
                GUIInt(s_Texts.maxCollisionShapes, m_MaxCollisionShapes);

                if (m_Quality.intValue == 0)
                {
                    GUIToggle(s_Texts.collidesWithDynamic, m_CollidesWithDynamic);
                }
                else
                {
                    GUIFloat(s_Texts.voxelSize, m_VoxelSize);
                }

                EditorGUI.indentLevel--;

                GUIFloat(s_Texts.colliderForce, m_ColliderForce);
                EditorGUI.indentLevel++;
                GUIToggle(s_Texts.multiplyColliderForceByCollisionAngle, m_MultiplyColliderForceByCollisionAngle);
                GUIToggle(s_Texts.multiplyColliderForceByParticleSpeed, m_MultiplyColliderForceByParticleSpeed);
                GUIToggle(s_Texts.multiplyColliderForceByParticleSize, m_MultiplyColliderForceByParticleSize);
                EditorGUI.indentLevel--;
            }

            GUIToggle(s_Texts.collisionMessages, m_CollisionMessages);

            EditorGUI.BeginChangeCheck();
            s_VisualizeBounds = GUIToggle(s_Texts.visualizeBounds, s_VisualizeBounds);
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetBool("VisualizeBounds", s_VisualizeBounds);
            }
        }
        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;
                    }
                }
            }
        }
Пример #7
0
        private void DoTimeline()
        {
            if (!m_ValidTransition)
            {
                return;
            }
            // get local durations
            float srcStateDuration   = (m_LeftStateTimeB - m_LeftStateTimeA) / (m_LeftStateWeightB - m_LeftStateWeightA);
            float dstStateDuration   = (m_RightStateTimeB - m_RightStateTimeA) / (m_RightStateWeightB - m_RightStateWeightA);
            float transitionDuration = m_Transition.duration * (m_RefTransition.hasFixedDuration ? 1.0f : srcStateDuration);

            // Set the timeline values
            m_Timeline.SrcStartTime = 0f;
            m_Timeline.SrcStopTime  = srcStateDuration;
            m_Timeline.SrcName      = m_RefSrcState.name;
            m_Timeline.HasExitTime  = m_RefTransition.hasExitTime;

            m_Timeline.srcLoop = m_SrcMotion ? m_SrcMotion.isLooping : false;
            m_Timeline.dstLoop = m_DstMotion ? m_DstMotion.isLooping : false;

            m_Timeline.TransitionStartTime = m_RefTransition.exitTime * srcStateDuration;
            m_Timeline.TransitionStopTime  = m_Timeline.TransitionStartTime + transitionDuration;

            m_Timeline.Time = m_AvatarPreview.timeControl.currentTime;

            m_Timeline.DstStartTime = m_Timeline.TransitionStartTime - m_RefTransition.offset * dstStateDuration;
            m_Timeline.DstStopTime  = m_Timeline.DstStartTime + dstStateDuration;

            m_Timeline.SampleStopTime = m_AvatarPreview.timeControl.stopTime;

            if (m_Timeline.TransitionStopTime == Mathf.Infinity)
            {
                m_Timeline.TransitionStopTime = Mathf.Min(m_Timeline.DstStopTime, m_Timeline.SrcStopTime);
            }


            m_Timeline.DstName = m_RefDstState.name;

            m_Timeline.SrcPivotList = m_SrcPivotList;
            m_Timeline.DstPivotList = m_DstPivotList;

            // Do the timeline
            Rect previewRect = EditorGUILayout.GetControlRect(false, 150, EditorStyles.label);

            EditorGUI.BeginChangeCheck();

            bool changedData = m_Timeline.DoTimeline(previewRect);

            if (EditorGUI.EndChangeCheck())
            {
                if (changedData)
                {
                    Undo.RegisterCompleteObjectUndo(m_RefTransition, "Edit Transition");
                    m_RefTransition.exitTime = m_Timeline.TransitionStartTime / m_Timeline.SrcDuration;
                    m_RefTransition.duration = m_Timeline.TransitionDuration / (m_RefTransition.hasFixedDuration ? 1.0f : m_Timeline.SrcDuration);
                    m_RefTransition.offset   = (m_Timeline.TransitionStartTime - m_Timeline.DstStartTime) / m_Timeline.DstDuration;
                }

                m_AvatarPreview.timeControl.nextCurrentTime = Mathf.Clamp(m_Timeline.Time, 0, m_AvatarPreview.timeControl.stopTime);
            }
        }
Пример #8
0
        public static SerializedPropertyTreeView.Column[] CreateLightColumns(out string[] propNames)
        {
            SerializedPropertyTreeView.Column[] expr_07 = new SerializedPropertyTreeView.Column[8];
            expr_07[0] = new SerializedPropertyTreeView.Column
            {
                headerContent         = LightTableColumns.Styles.Name,
                headerTextAlignment   = TextAlignment.Left,
                sortedAscending       = true,
                sortingArrowAlignment = TextAlignment.Center,
                width                 = 200f,
                minWidth              = 100f,
                autoResize            = false,
                allowToggleVisibility = true,
                propertyName          = null,
                dependencyIndices     = null,
                compareDelegate       = SerializedPropertyTreeView.DefaultDelegates.s_CompareName,
                drawDelegate          = SerializedPropertyTreeView.DefaultDelegates.s_DrawName,
                filter                = new SerializedPropertyFilters.Name()
            };
            expr_07[1] = new SerializedPropertyTreeView.Column
            {
                headerContent         = LightTableColumns.Styles.On,
                headerTextAlignment   = TextAlignment.Center,
                sortedAscending       = true,
                sortingArrowAlignment = TextAlignment.Center,
                width                 = 25f,
                minWidth              = 25f,
                maxWidth              = 25f,
                autoResize            = false,
                allowToggleVisibility = true,
                propertyName          = "m_Enabled",
                dependencyIndices     = null,
                compareDelegate       = SerializedPropertyTreeView.DefaultDelegates.s_CompareCheckbox,
                drawDelegate          = SerializedPropertyTreeView.DefaultDelegates.s_DrawCheckbox
            };
            expr_07[2] = new SerializedPropertyTreeView.Column
            {
                headerContent         = LightTableColumns.Styles.Type,
                headerTextAlignment   = TextAlignment.Left,
                sortedAscending       = true,
                sortingArrowAlignment = TextAlignment.Center,
                width                 = 120f,
                minWidth              = 60f,
                autoResize            = false,
                allowToggleVisibility = true,
                propertyName          = "m_Type",
                dependencyIndices     = null,
                compareDelegate       = SerializedPropertyTreeView.DefaultDelegates.s_CompareEnum,
                drawDelegate          = SerializedPropertyTreeView.DefaultDelegates.s_DrawDefault
            };
            int arg_21C_1 = 3;

            SerializedPropertyTreeView.Column column = new SerializedPropertyTreeView.Column();
            column.headerContent         = LightTableColumns.Styles.Mode;
            column.headerTextAlignment   = TextAlignment.Left;
            column.sortedAscending       = true;
            column.sortingArrowAlignment = TextAlignment.Center;
            column.width                 = 70f;
            column.minWidth              = 40f;
            column.maxWidth              = 70f;
            column.autoResize            = false;
            column.allowToggleVisibility = true;
            column.propertyName          = "m_Lightmapping";
            column.dependencyIndices     = new int[]
            {
                2
            };
            column.compareDelegate = SerializedPropertyTreeView.DefaultDelegates.s_CompareEnum;
            column.drawDelegate    = delegate(Rect r, SerializedProperty prop, SerializedProperty[] dep)
            {
                bool disabled = dep.Length > 1 && dep[0].enumValueIndex == 3;
                using (new EditorGUI.DisabledScope(disabled))
                {
                    EditorGUI.BeginChangeCheck();
                    int intValue = EditorGUI.IntPopup(r, prop.intValue, LightTableColumns.Styles.LightmapBakeTypeTitles, LightTableColumns.Styles.LightmapBakeTypeValues);
                    if (EditorGUI.EndChangeCheck())
                    {
                        prop.intValue = intValue;
                    }
                }
            };
            expr_07[arg_21C_1] = column;
            expr_07[4]         = new SerializedPropertyTreeView.Column
            {
                headerContent         = LightTableColumns.Styles.Color,
                headerTextAlignment   = TextAlignment.Left,
                sortedAscending       = true,
                sortingArrowAlignment = TextAlignment.Center,
                width                 = 70f,
                minWidth              = 40f,
                autoResize            = false,
                allowToggleVisibility = true,
                propertyName          = "m_Color",
                dependencyIndices     = null,
                compareDelegate       = SerializedPropertyTreeView.DefaultDelegates.s_CompareColor,
                drawDelegate          = SerializedPropertyTreeView.DefaultDelegates.s_DrawDefault
            };
            expr_07[5] = new SerializedPropertyTreeView.Column
            {
                headerContent         = LightTableColumns.Styles.Intensity,
                headerTextAlignment   = TextAlignment.Left,
                sortedAscending       = true,
                sortingArrowAlignment = TextAlignment.Center,
                width                 = 60f,
                minWidth              = 30f,
                autoResize            = false,
                allowToggleVisibility = true,
                propertyName          = "m_Intensity",
                dependencyIndices     = null,
                compareDelegate       = SerializedPropertyTreeView.DefaultDelegates.s_CompareFloat,
                drawDelegate          = SerializedPropertyTreeView.DefaultDelegates.s_DrawDefault
            };
            expr_07[6] = new SerializedPropertyTreeView.Column
            {
                headerContent         = LightTableColumns.Styles.IndirectMultiplier,
                headerTextAlignment   = TextAlignment.Left,
                sortedAscending       = true,
                sortingArrowAlignment = TextAlignment.Center,
                width                 = 110f,
                minWidth              = 60f,
                autoResize            = false,
                allowToggleVisibility = true,
                propertyName          = "m_BounceIntensity",
                dependencyIndices     = null,
                compareDelegate       = SerializedPropertyTreeView.DefaultDelegates.s_CompareFloat,
                drawDelegate          = SerializedPropertyTreeView.DefaultDelegates.s_DrawDefault
            };
            expr_07[7] = new SerializedPropertyTreeView.Column
            {
                headerContent         = LightTableColumns.Styles.ShadowType,
                headerTextAlignment   = TextAlignment.Left,
                sortedAscending       = true,
                sortingArrowAlignment = TextAlignment.Center,
                width                 = 100f,
                minWidth              = 60f,
                autoResize            = false,
                allowToggleVisibility = true,
                propertyName          = "m_Shadows.m_Type",
                dependencyIndices     = null,
                compareDelegate       = SerializedPropertyTreeView.DefaultDelegates.s_CompareEnum,
                drawDelegate          = SerializedPropertyTreeView.DefaultDelegates.s_DrawDefault
            };
            SerializedPropertyTreeView.Column[] columns = expr_07;
            return(LightTableColumns.FinalizeColumns(columns, out propNames));
        }
Пример #9
0
        protected override void OldOnGUI()
        {
            const float space               = 10;
            const float largeSpace          = 20;
            const float standardButtonWidth = 32;
            const float dropdownWidth       = 80;
            const float playPauseStopWidth  = 140;

            InitializeToolIcons();

            bool isOrWillEnterPlaymode = EditorApplication.isPlayingOrWillChangePlaymode;

            GUI.color = isOrWillEnterPlaymode ? HostView.kPlayModeDarken : Color.white;

            if (Event.current.type == EventType.Repaint)
            {
                Styles.appToolbar.Draw(new Rect(0, 0, position.width, position.height), false, false, false, false);
            }

            // Position left aligned controls controls - start from left to right.
            Rect pos = new Rect(0, 0, 0, 0);

            ReserveWidthRight(space, ref pos);

            ReserveWidthRight(standardButtonWidth * s_ShownToolIcons.Length, ref pos);
            DoToolButtons(EditorToolGUI.GetThickArea(pos));

            ReserveWidthRight(largeSpace, ref pos);

            int playModeControlsStart = Mathf.RoundToInt((position.width - playPauseStopWidth) / 2);

            pos.x    += pos.width;
            pos.width = (playModeControlsStart - pos.x) - largeSpace;
            DoToolSettings(EditorToolGUI.GetThickArea(pos));

            // Position centered controls.
            pos = new Rect(playModeControlsStart, 0, 240, 0);

            if (ModeService.HasCapability(ModeCapability.Playbar, true))
            {
                GUILayout.BeginArea(EditorToolGUI.GetThickArea(pos));
                GUILayout.BeginHorizontal();
                {
                    if (!ModeService.Execute("gui_playbar", isOrWillEnterPlaymode))
                    {
                        DoPlayButtons(isOrWillEnterPlaymode);
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.EndArea();
            }

            // Position right aligned controls controls - start from right to left.
            pos = new Rect(position.width, 0, 0, 0);

            // Right spacing side
            ReserveWidthLeft(space, ref pos);
            ReserveWidthLeft(dropdownWidth, ref pos);

            if (ModeService.HasCapability(ModeCapability.LayoutWindowMenu, true))
            {
                DoLayoutDropDown(EditorToolGUI.GetThinArea(pos));
            }

            if (ModeService.HasCapability(ModeCapability.Layers, true))
            {
                ReserveWidthLeft(space, ref pos);
                ReserveWidthLeft(dropdownWidth, ref pos);
                DoLayersDropDown(EditorToolGUI.GetThinArea(pos));
            }

            if (Unity.MPE.ProcessService.level == Unity.MPE.ProcessLevel.UMP_MASTER)
            {
                ReserveWidthLeft(space, ref pos);

                ReserveWidthLeft(dropdownWidth, ref pos);
                if (EditorGUI.DropdownButton(EditorToolGUI.GetThinArea(pos), s_AccountContent, FocusType.Passive, Styles.dropdown))
                {
                    ShowUserMenu(EditorToolGUI.GetThinArea(pos));
                }

                ReserveWidthLeft(space, ref pos);

                ReserveWidthLeft(standardButtonWidth, ref pos);
                if (GUI.Button(EditorToolGUI.GetThinArea(pos), s_CloudIcon, Styles.command))
                {
                    UnityConnectServiceCollection.instance.ShowService(HubAccess.kServiceName, true, "cloud_icon"); // Should show hub when it's done
                }
            }

            foreach (SubToolbar subToolbar in s_SubToolbars)
            {
                ReserveWidthLeft(space, ref pos);
                ReserveWidthLeft(subToolbar.Width, ref pos);
                subToolbar.OnGUI(EditorToolGUI.GetThinArea(pos));
            }

            if (ModeService.modeCount > 1 && Unsupported.IsDeveloperBuild())
            {
                EditorGUI.BeginChangeCheck();
                ReserveWidthLeft(space, ref pos);
                ReserveWidthLeft(dropdownWidth, ref pos);
                var selectedModeIndex = EditorGUI.Popup(EditorToolGUI.GetThinArea(pos), ModeService.currentIndex, ModeService.modeNames, Styles.dropdown);
                if (EditorGUI.EndChangeCheck())
                {
                    EditorApplication.delayCall += () => ModeService.ChangeModeByIndex(selectedModeIndex);
                    GUIUtility.ExitGUI();
                }
            }

            EditorGUI.ShowRepaints();
            Highlighter.ControlHighlightGUI(this);
        }
Пример #10
0
        private static void OnGUI(string searchContext)
        {
            EditorGUIUtility.labelWidth = 200f;
            // Get event type before the event is used.
            var eventType = Event.current.type;

            if (!InternalEditorUtility.HasTeamLicense())
            {
                GUILayout.Label(EditorGUIUtility.TempContent("You need to have a Pro or Team license to use the cache server.", EditorGUIUtility.GetHelpIcon(MessageType.Warning)), EditorStyles.helpBox);
            }


            using (new EditorGUI.DisabledScope(!InternalEditorUtility.HasTeamLicense()))
            {
                if (!s_PrefsLoaded)
                {
                    EnsurePreferencesRead();
                    OnPreferencesReadGUI();
                }

                EditorGUI.BeginChangeCheck();

                s_AssetPipelineVersionForNewProjects = (AssetPipelineVersion)EditorGUILayout.EnumPopup(Properties.newProjectsAssetPipeline, s_AssetPipelineVersionForNewProjects);

                EditorGUILayout.LabelField(Properties.activeAssetPipelineVersionLabel, Properties.activeAssetPipelineVersion);
                var  overrideAddress         = GetCommandLineRemoteAddressOverride();
                bool allowCacheServerChanges = overrideAddress == null;

                if (GetEnvironmentAssetPipelineOverride())
                {
                    EditorGUILayout.HelpBox("Asset pipeline currently forced environment variable UNITY_ASSETS_V2_KATANA_TESTS", MessageType.Info, true);
                }
                else if (GetCommandLineAssetPipelineOverride() != 0)
                {
                    EditorGUILayout.HelpBox("Asset pipeline currently forced by command line argument", MessageType.Info, true);
                }
                else if (GetMagicFileAssetPipelineOverride())
                {
                    EditorGUILayout.HelpBox("Asset pipeline currently forced by magic adb2.txt file", MessageType.Info, true);
                }

                GUILayout.Space(5);

                CacheServerVersion1GUI(allowCacheServerChanges, overrideAddress);

                GUILayout.Space(5);

                CacheServerVersion2GUI(allowCacheServerChanges, overrideAddress);
                GUILayout.Space(10);

                if (!allowCacheServerChanges)
                {
                    EditorGUILayout.HelpBox("Cache Server preferences currently forced via command line argument to " + overrideAddress + " and any changes here will not take effect until starting Unity without that command line argument.", MessageType.Info, true);
                }

                if (EditorGUI.EndChangeCheck())
                {
                    s_HasPendingChanges = true;
                }

                // Only commit changes when we don't have an active hot control, to avoid restarting the cache server all the time while the slider is dragged, slowing down the UI.
                if (s_HasPendingChanges && GUIUtility.hotControl == 0)
                {
                    s_HasPendingChanges = false;
                    WritePreferences();
                    ReadPreferences();
                }
            }
        }
Пример #11
0
        public void ShaderPropertiesGUI(Material material)
        {
            // Use default labelWidth
            EditorGUIUtility.labelWidth = 0f;

            // Detect any changes to the material
            EditorGUI.BeginChangeCheck();
            {
                BlendModePopup();

                // Primary properties
                GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel);
                DoAlbedoArea(material);
                DoSpecularMetallicArea();
                m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null);
                m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null);
                m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null);
                m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask);
                DoEmissionArea(material);
                EditorGUI.BeginChangeCheck();
                m_MaterialEditor.TextureScaleOffsetProperty(albedoMap);
                if (EditorGUI.EndChangeCheck())
                {
                    emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset;                     // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake
                }
                EditorGUILayout.Space();

                // Secondary properties
                GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel);
                m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap);
                m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale);
                m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap);
                m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text);

                // Third properties
                GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel);
                if (highlights != null)
                {
                    m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText);
                }
                if (reflections != null)
                {
                    m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText);
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                foreach (var obj in blendMode.targets)
                {
                    MaterialChanged((Material)obj, m_WorkflowMode);
                }
            }

            EditorGUILayout.Space();

            // NB renderqueue editor is not shown on purpose: we want to override it based on blend mode
            GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel);
            m_MaterialEditor.EnableInstancingField();
            m_MaterialEditor.DoubleSidedGIField();

            EditorGUI.BeginChangeCheck();
            {
                // Dissolve properties
                EditorGUILayout.Space();
                GUILayout.Label(Styles.dissolveSettings, EditorStyles.boldLabel);
                DoDissolveArea(material);
            }

            if (EditorGUI.EndChangeCheck())
            {
                foreach (var obj in blendMode.targets)
                {
                    MaterialChanged((Material)obj, m_WorkflowMode);
                }
            }
        }
Пример #12
0
        void NormalsTangentsGUI()
        {
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = m_LegacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes.hasMultipleDifferentValues;
            var legacyComputeFromSmoothingGroups = EditorGUILayout.Toggle(Styles.LegacyComputeNormalsFromSmoothingGroupsWhenMeshHasBlendShapes, m_LegacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes.boolValue);

            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                m_LegacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes.boolValue = legacyComputeFromSmoothingGroups;
            }

            using (var horizontal = new EditorGUILayout.HorizontalScope())
            {
                using (var property = new EditorGUI.PropertyScope(horizontal.rect, Styles.NormalsLabel, m_NormalImportMode))
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUI.showMixedValue = m_NormalImportMode.hasMultipleDifferentValues;
                    var newValue = (int)(ModelImporterNormals)EditorGUILayout.EnumPopup(property.content, (ModelImporterNormals)m_NormalImportMode.intValue);
                    EditorGUI.showMixedValue = false;
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_NormalImportMode.intValue = newValue;
                        // This check is made in CheckConsistency, but because AssetImporterEditor does not serialize the object each update,
                        // We need to double check here for UI consistency.
                        if (m_NormalImportMode.intValue == (int)ModelImporterNormals.None)
                        {
                            m_TangentImportMode.intValue = (int)ModelImporterTangents.None;
                        }
                        else if (m_NormalImportMode.intValue == (int)ModelImporterNormals.Calculate && m_TangentImportMode.intValue == (int)ModelImporterTangents.Import)
                        {
                            m_TangentImportMode.intValue = (int)ModelImporterTangents.CalculateMikk;
                        }


                        // Also make the blendshape normal mode follow normal mode, with the exception that we never
                        // select Import automatically (since we can't trust imported normals to be correct, and we
                        // also can't detect when they're not).
                        if (m_NormalImportMode.intValue == (int)ModelImporterNormals.None)
                        {
                            m_BlendShapeNormalCalculationMode.intValue = (int)ModelImporterNormals.None;
                        }
                        else
                        {
                            m_BlendShapeNormalCalculationMode.intValue = (int)ModelImporterNormals.Calculate;
                        }
                    }
                }
            }

            if (!m_LegacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes.boolValue && m_ImportBlendShapes.boolValue && !m_LegacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes.hasMultipleDifferentValues)
            {
                using (new EditorGUI.DisabledScope(m_NormalImportMode.intValue == (int)ModelImporterNormals.None))
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUI.showMixedValue = m_BlendShapeNormalCalculationMode.hasMultipleDifferentValues;
                    var blendShapeNormalCalculationMode = (int)(ModelImporterNormals)EditorGUILayout.EnumPopup(Styles.BlendShapeNormalsLabel, (ModelImporterNormals)m_BlendShapeNormalCalculationMode.intValue);
                    EditorGUI.showMixedValue = false;
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_BlendShapeNormalCalculationMode.intValue = blendShapeNormalCalculationMode;
                    }
                }
            }

            if (m_NormalImportMode.intValue != (int)ModelImporterNormals.None || m_BlendShapeNormalCalculationMode.intValue != (int)ModelImporterNormals.None)
            {
                // Normal calculation mode
                using (var horizontal = new EditorGUILayout.HorizontalScope())
                {
                    using (var property = new EditorGUI.PropertyScope(horizontal.rect, Styles.RecalculateNormalsLabel, m_NormalCalculationMode))
                    {
                        EditorGUI.BeginChangeCheck();
                        EditorGUI.showMixedValue = m_NormalCalculationMode.hasMultipleDifferentValues;
                        var normalCalculationMode = (int)(ModelImporterNormalCalculationMode)EditorGUILayout.EnumPopup(property.content, (ModelImporterNormalCalculationMode)m_NormalCalculationMode.intValue);
                        EditorGUI.showMixedValue = false;
                        if (EditorGUI.EndChangeCheck())
                        {
                            m_NormalCalculationMode.intValue = normalCalculationMode;
                        }
                    }
                }

                // Normal smoothness
                if (!m_LegacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes.boolValue)
                {
                    using (var horizontal = new EditorGUILayout.HorizontalScope())
                        using (var property = new EditorGUI.PropertyScope(horizontal.rect, Styles.NormalSmoothingSourceLabel, m_NormalSmoothingSource))
                        {
                            EditorGUI.BeginChangeCheck();
                            EditorGUI.showMixedValue = m_NormalSmoothingSource.hasMultipleDifferentValues;
                            var normalSmoothingSource = (int)(ModelImporterNormalSmoothingSource)EditorGUILayout.EnumPopup(property.content, (ModelImporterNormalSmoothingSource)m_NormalSmoothingSource.intValue);
                            EditorGUI.showMixedValue = false;
                            if (EditorGUI.EndChangeCheck())
                            {
                                m_NormalSmoothingSource.intValue = normalSmoothingSource;
                            }
                        }
                }

                // Normal split angle
                if (m_LegacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes.boolValue || m_NormalSmoothingSource.intValue == (int)ModelImporterNormalSmoothingSource.PreferSmoothingGroups || m_NormalSmoothingSource.intValue == (int)ModelImporterNormalSmoothingSource.FromAngle)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.Slider(m_NormalSmoothAngle, 0, 180, Styles.SmoothingAngle);

                    // Property is serialized as float but we want to show it as an int so we round the value when changed
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_NormalSmoothAngle.floatValue = Mathf.Round(m_NormalSmoothAngle.floatValue);
                    }
                }
            }

            // Choose the option values and labels based on what the NormalImportMode is
            if (m_NormalImportMode.intValue != (int)ModelImporterNormals.None)
            {
                using (var horizontal = new EditorGUILayout.HorizontalScope())
                {
                    using (var property = new EditorGUI.PropertyScope(horizontal.rect, Styles.TangentsLabel, m_TangentImportMode))
                    {
                        EditorGUI.BeginChangeCheck();
                        var newValue = (int)(ModelImporterTangents)EditorGUILayout.EnumPopup(property.content, (ModelImporterTangents)m_TangentImportMode.intValue, TangentModeAvailabilityCheck, false);
                        if (EditorGUI.EndChangeCheck())
                        {
                            m_TangentImportMode.intValue = newValue;
                        }
                    }
                }
            }
        }
Пример #13
0
        protected void MuscleGUI()
        {
            bool flag = false;

            this.HeaderGUI("Preview", "Per-Muscle Settings");
            GUILayout.BeginVertical(styles.box, new GUILayoutOption[0]);
            for (int i = 0; i < this.m_MuscleBodyGroupToggle.Length; i++)
            {
                Rect settingsRect = GetSettingsRect(GUILayoutUtility.GetRect((float)10f, (float)16f));
                this.m_MuscleBodyGroupToggle[i] = GUI.Toggle(settingsRect, this.m_MuscleBodyGroupToggle[i], styles.muscleBodyGroup[i], EditorStyles.foldout);
                if (this.m_MuscleBodyGroupToggle[i])
                {
                    for (int j = 0; j < this.m_Muscles[i].Length; j++)
                    {
                        int index = this.m_Muscles[i][j];
                        if (((index != -1) && (this.m_MuscleMin[index] != null)) && (this.m_MuscleMax[index] != null))
                        {
                            bool flag2          = this.m_MuscleToggle[index];
                            Rect wholeWidthRect = GUILayoutUtility.GetRect(10f, !flag2 ? 16f : 32f);
                            settingsRect               = GetSettingsRect(wholeWidthRect);
                            settingsRect.xMin         += 15f;
                            settingsRect.height        = 16f;
                            this.m_MuscleToggle[index] = GUI.Toggle(settingsRect, this.m_MuscleToggle[index], this.m_MuscleName[index], EditorStyles.foldout);
                            float num5 = PreviewSlider(wholeWidthRect, this.m_MuscleValue[index]);
                            if (this.m_MuscleValue[index] != num5)
                            {
                                Undo.RegisterCompleteObjectUndo(this, "Muscle preview");
                                this.m_FocusedMuscle      = index;
                                this.m_MuscleValue[index] = num5;
                                flag |= base.gameObject != null;
                            }
                            if (flag2)
                            {
                                bool flag3 = false;
                                settingsRect.xMin += 15f;
                                settingsRect.y    += 16f;
                                Rect position = settingsRect;
                                if (settingsRect.width > 160f)
                                {
                                    Rect rect4 = settingsRect;
                                    rect4.width = 38f;
                                    EditorGUI.BeginChangeCheck();
                                    this.m_MuscleMinEdit[index] = EditorGUI.FloatField(rect4, this.m_MuscleMinEdit[index]);
                                    flag3  |= EditorGUI.EndChangeCheck();
                                    rect4.x = settingsRect.xMax - 38f;
                                    EditorGUI.BeginChangeCheck();
                                    this.m_MuscleMaxEdit[index] = EditorGUI.FloatField(rect4, this.m_MuscleMaxEdit[index]);
                                    flag3         |= EditorGUI.EndChangeCheck();
                                    position.xMin += 43f;
                                    position.xMax -= 43f;
                                }
                                EditorGUI.BeginChangeCheck();
                                EditorGUI.MinMaxSlider(position, ref this.m_MuscleMinEdit[index], ref this.m_MuscleMaxEdit[index], -180f, 180f);
                                if (flag3 | EditorGUI.EndChangeCheck())
                                {
                                    this.m_MuscleMinEdit[index] = Mathf.Clamp(this.m_MuscleMinEdit[index], -180f, 0f);
                                    this.m_MuscleMaxEdit[index] = Mathf.Clamp(this.m_MuscleMaxEdit[index], 0f, 180f);
                                    flag |= this.UpdateMuscle(index, this.m_MuscleMinEdit[index], this.m_MuscleMaxEdit[index]);
                                }
                            }
                        }
                    }
                }
            }
            GUILayout.EndVertical();
            if (flag)
            {
                this.WritePose();
            }
        }
Пример #14
0
        private void Buttons()
        {
            bool enabled = GUI.enabled;

            GUI.enabled &= !EditorApplication.isPlayingOrWillChangePlaymode;
            if (Lightmapping.lightingDataAsset && !Lightmapping.lightingDataAsset.isValid)
            {
                EditorGUILayout.HelpBox(Lightmapping.lightingDataAsset.validityErrorMessage, MessageType.Warning);
            }
            EditorGUILayout.Space();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            Rect rect = GUILayoutUtility.GetRect(LightingWindow.Styles.ContinuousBakeLabel, GUIStyle.none);

            EditorGUI.BeginProperty(rect, LightingWindow.Styles.ContinuousBakeLabel, this.m_WorkflowMode);
            bool flag = this.m_WorkflowMode.intValue == 0;

            EditorGUI.BeginChangeCheck();
            flag = GUILayout.Toggle(flag, LightingWindow.Styles.ContinuousBakeLabel, new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                this.m_WorkflowMode.intValue = ((!flag) ? 1 : 0);
            }
            EditorGUI.EndProperty();
            using (new EditorGUI.DisabledScope(flag))
            {
                bool flag2 = flag || !Lightmapping.isRunning;
                if (flag2)
                {
                    if (EditorGUI.ButtonWithDropdownList(LightingWindow.Styles.BuildLabel, LightingWindow.s_BakeModeOptions, new GenericMenu.MenuFunction2(this.BakeDropDownCallback), new GUILayoutOption[]
                    {
                        GUILayout.Width(170f)
                    }))
                    {
                        this.DoBake();
                        GUIUtility.ExitGUI();
                    }
                }
                else
                {
                    if (LightmapEditorSettings.lightmapper == LightmapEditorSettings.Lightmapper.PathTracer && this.m_EnabledBakedGI.boolValue && GUILayout.Button("Force Stop", new GUILayoutOption[]
                    {
                        GUILayout.Width(150f)
                    }))
                    {
                        Lightmapping.ForceStop();
                    }
                    if (GUILayout.Button("Cancel", new GUILayoutOption[]
                    {
                        GUILayout.Width(150f)
                    }))
                    {
                        Lightmapping.Cancel();
                        UsabilityAnalytics.Track("/LightMapper/Cancel");
                    }
                }
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();
            GUI.enabled = enabled;
        }
        private void OnSampleSettingGUI(BuildTargetGroup platform, AudioImporterInspector.MultiValueStatus status, bool selectionContainsTrackerFile, ref AudioImporterInspector.SampleSettingProperties properties, bool disablePreloadAudioDataOption)
        {
            EditorGUI.showMixedValue = status.multiLoadType && !properties.loadTypeChanged;
            EditorGUI.BeginChangeCheck();
            AudioClipLoadType audioClipLoadType = (AudioClipLoadType)EditorGUILayout.EnumPopup("Load Type", (Enum)properties.settings.loadType, new GUILayoutOption[0]);

            if (EditorGUI.EndChangeCheck())
            {
                properties.settings.loadType = audioClipLoadType;
                properties.loadTypeChanged   = true;
            }
            EditorGUI.BeginDisabledGroup(disablePreloadAudioDataOption);
            if (disablePreloadAudioDataOption)
            {
                EditorGUILayout.Toggle("Preload Audio Data", false, new GUILayoutOption[0]);
            }
            else
            {
                EditorGUILayout.PropertyField(this.m_PreloadAudioData);
            }
            EditorGUI.EndDisabledGroup();
            if (selectionContainsTrackerFile)
            {
                return;
            }
            AudioCompressionFormat[] formatsForPlatform = this.GetFormatsForPlatform(platform);
            EditorGUI.showMixedValue = status.multiCompressionFormat && !properties.compressionFormatChanged;
            EditorGUI.BeginChangeCheck();
            AudioCompressionFormat compressionFormat = (AudioCompressionFormat)EditorGUILayout.IntPopup("Compression Format", (int)properties.settings.compressionFormat, Array.ConvertAll <AudioCompressionFormat, string>(formatsForPlatform, (Converter <AudioCompressionFormat, string>)(value => value.ToString())), Array.ConvertAll <AudioCompressionFormat, int>(formatsForPlatform, (Converter <AudioCompressionFormat, int>)(value => (int)value)), new GUILayoutOption[0]);

            if (EditorGUI.EndChangeCheck())
            {
                properties.settings.compressionFormat = compressionFormat;
                properties.compressionFormatChanged   = true;
            }
            if (this.CompressionFormatHasQuality(properties.settings.compressionFormat))
            {
                EditorGUI.showMixedValue = status.multiQuality && !properties.qualityChanged;
                EditorGUI.BeginChangeCheck();
                int num = EditorGUILayout.IntSlider("Quality", (int)Mathf.Clamp(properties.settings.quality * 100f, 1f, 100f), 1, 100, new GUILayoutOption[0]);
                if (EditorGUI.EndChangeCheck())
                {
                    properties.settings.quality = 0.01f * (float)num;
                    properties.qualityChanged   = true;
                }
            }
            EditorGUI.showMixedValue = status.multiSampleRateSetting && !properties.sampleRateSettingChanged;
            EditorGUI.BeginChangeCheck();
            AudioSampleRateSetting sampleRateSetting = (AudioSampleRateSetting)EditorGUILayout.EnumPopup("Sample Rate Setting", (Enum)properties.settings.sampleRateSetting, new GUILayoutOption[0]);

            if (EditorGUI.EndChangeCheck())
            {
                properties.settings.sampleRateSetting = sampleRateSetting;
                properties.sampleRateSettingChanged   = true;
            }
            if (properties.settings.sampleRateSetting == AudioSampleRateSetting.OverrideSampleRate)
            {
                EditorGUI.showMixedValue = status.multiSampleRateOverride && !properties.sampleRateOverrideChanged;
                EditorGUI.BeginChangeCheck();
                int num = EditorGUILayout.IntPopup("Sample Rate", (int)properties.settings.sampleRateOverride, AudioImporterInspector.Styles.kSampleRateStrings, AudioImporterInspector.Styles.kSampleRateValues, new GUILayoutOption[0]);
                if (EditorGUI.EndChangeCheck())
                {
                    properties.settings.sampleRateOverride = (uint)num;
                    properties.sampleRateOverrideChanged   = true;
                }
            }
            EditorGUI.showMixedValue = false;
        }
        void DisplayUpdateGUI()
        {
            EditorGUILayout.IntPopup(m_UpdateMode, styles.updateModeStrings, styles.updateModeValues, styles.updateMode);

            EditorGUI.indentLevel++;

            if (m_UpdateMode.intValue == (int)CustomRenderTextureUpdateMode.Realtime)
            {
                EditorGUILayout.PropertyField(m_UpdatePeriod, styles.updatePeriod);
            }

            EditorGUILayout.PropertyField(m_DoubleBuffered, styles.doubleBuffered);
            EditorGUILayout.PropertyField(m_WrapUpdateZones, styles.wrapUpdateZones);

            bool isCubemap = true;

            foreach (Object o in targets)
            {
                CustomRenderTexture customRenderTexture = o as CustomRenderTexture;
                if (customRenderTexture != null && customRenderTexture.dimension != UnityEngine.Rendering.TextureDimension.Cube)
                {
                    isCubemap = false;
                }
            }

            if (isCubemap)
            {
                int newFaceMask     = 0;
                int currentFaceMask = m_CubeFaceMask.intValue;

                var AllRects = GUILayoutUtility.GetRect(0, EditorGUIUtility.singleLineHeight * 3 + EditorGUIUtility.standardVerticalSpacing * 2);
                EditorGUI.BeginProperty(AllRects, GUIContent.none, m_CubeFaceMask);

                Rect toggleRect = AllRects;
                toggleRect.width  = kToggleWidth;
                toggleRect.height = EditorGUIUtility.singleLineHeight;
                int faceIndex = 0;
                {
                    Rect labelRect = AllRects;
                    EditorGUI.LabelField(labelRect, styles.cubemapFacesLabel);

                    EditorGUI.BeginChangeCheck();
                    for (int i = 0; i < 3; ++i)
                    {
                        toggleRect.x = AllRects.x + EditorGUIUtility.labelWidth - kIndentSize;

                        {
                            for (int j = 0; j < 2; ++j)
                            {
                                bool value = EditorGUI.ToggleLeft(toggleRect, styles.cubemapFaces[faceIndex], (currentFaceMask & (1 << faceIndex)) != 0);
                                if (value)
                                {
                                    newFaceMask |= (int)(1 << faceIndex);
                                }
                                faceIndex++;

                                toggleRect.x += kToggleWidth;
                            }
                        }

                        toggleRect.y += EditorGUIUtility.singleLineHeight;
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_CubeFaceMask.intValue = newFaceMask;
                    }
                }
                EditorGUI.EndProperty();
            }


            EditorGUILayout.IntPopup(m_UpdateZoneSpace, styles.updateZoneSpaceStrings, styles.updateZoneSpaceValues, styles.updateZoneSpace);

            if (!multipleEditing)
            {
                Rect listRect = GUILayoutUtility.GetRect(0.0f, m_RectList.GetHeight() + kRListAddButtonOffset, GUILayout.ExpandWidth(true)); // kRListAddButtonOffset because reorderable list does not take the  +/- button at the bottom when computing its Rects making it half occulted by other GUI elements.
                // Reorderable list seems to not take indentLevel into account properly.
                float indentSize = kIndentSize;
                listRect.x     += indentSize;
                listRect.width -= indentSize;
                m_RectList.DoList(listRect);
            }
            else
            {
                EditorGUILayout.HelpBox("Update Zones cannot be changed while editing multiple Custom Textures.", MessageType.Info);
            }

            EditorGUI.indentLevel--;
        }
Пример #17
0
        public static SerializedPropertyTreeView.Column[] CreateEmissivesColumns(out string[] propNames)
        {
            SerializedPropertyTreeView.Column[] expr_07 = new SerializedPropertyTreeView.Column[4];
            int arg_9B_1 = 0;

            SerializedPropertyTreeView.Column column = new SerializedPropertyTreeView.Column();
            column.headerContent         = LightTableColumns.Styles.SelectObjects;
            column.headerTextAlignment   = TextAlignment.Left;
            column.sortedAscending       = true;
            column.sortingArrowAlignment = TextAlignment.Center;
            column.width                 = 20f;
            column.minWidth              = 20f;
            column.maxWidth              = 20f;
            column.autoResize            = false;
            column.allowToggleVisibility = true;
            column.propertyName          = "m_LightmapFlags";
            column.dependencyIndices     = null;
            column.compareDelegate       = null;
            column.drawDelegate          = delegate(Rect r, SerializedProperty prop, SerializedProperty[] dep)
            {
                if (GUI.Button(r, LightTableColumns.Styles.SelectObjectsButton, "label"))
                {
                    SearchableEditorWindow.SearchForReferencesToInstanceID(prop.serializedObject.targetObject.GetInstanceID());
                }
            };
            expr_07[arg_9B_1] = column;
            expr_07[1]        = new SerializedPropertyTreeView.Column
            {
                headerContent         = LightTableColumns.Styles.Name,
                headerTextAlignment   = TextAlignment.Left,
                sortedAscending       = true,
                sortingArrowAlignment = TextAlignment.Center,
                width                 = 200f,
                minWidth              = 100f,
                autoResize            = false,
                allowToggleVisibility = true,
                propertyName          = null,
                dependencyIndices     = null,
                compareDelegate       = SerializedPropertyTreeView.DefaultDelegates.s_CompareName,
                drawDelegate          = SerializedPropertyTreeView.DefaultDelegates.s_DrawName,
                filter                = new SerializedPropertyFilters.Name()
            };
            int arg_1A6_1 = 2;

            column = new SerializedPropertyTreeView.Column();
            column.headerContent         = LightTableColumns.Styles.GlobalIllumination;
            column.headerTextAlignment   = TextAlignment.Left;
            column.sortedAscending       = true;
            column.sortingArrowAlignment = TextAlignment.Center;
            column.width                 = 120f;
            column.minWidth              = 70f;
            column.autoResize            = false;
            column.allowToggleVisibility = true;
            column.propertyName          = "m_LightmapFlags";
            column.dependencyIndices     = null;
            column.compareDelegate       = SerializedPropertyTreeView.DefaultDelegates.s_CompareInt;
            column.drawDelegate          = delegate(Rect r, SerializedProperty prop, SerializedProperty[] dep)
            {
                if (prop.serializedObject.targetObject.GetType().Equals(typeof(Material)))
                {
                    using (new EditorGUI.DisabledScope(!LightTableColumns.IsEditable(prop.serializedObject.targetObject)))
                    {
                        MaterialGlobalIlluminationFlags materialGlobalIlluminationFlags = ((prop.intValue & 2) == 0) ? MaterialGlobalIlluminationFlags.RealtimeEmissive : MaterialGlobalIlluminationFlags.BakedEmissive;
                        int[] optionValues = new int[]
                        {
                            1,
                            2
                        };
                        EditorGUI.BeginChangeCheck();
                        materialGlobalIlluminationFlags = (MaterialGlobalIlluminationFlags)EditorGUI.IntPopup(r, (int)materialGlobalIlluminationFlags, LightTableColumns.Styles.LightmapEmissiveStrings, optionValues);
                        if (EditorGUI.EndChangeCheck())
                        {
                            Material material = (Material)prop.serializedObject.targetObject;
                            Undo.RecordObjects(new Material[]
                            {
                                material
                            }, "Modify GI Settings of " + material.name);
                            material.globalIlluminationFlags = materialGlobalIlluminationFlags;
                            prop.serializedObject.Update();
                        }
                    }
                }
            };
            expr_07[arg_1A6_1] = column;
            int arg_26F_1 = 3;

            column = new SerializedPropertyTreeView.Column();
            column.headerContent         = LightTableColumns.Styles.Color;
            column.headerTextAlignment   = TextAlignment.Left;
            column.sortedAscending       = true;
            column.sortingArrowAlignment = TextAlignment.Center;
            column.width                 = 70f;
            column.minWidth              = 40f;
            column.autoResize            = false;
            column.allowToggleVisibility = true;
            column.propertyName          = "m_Shader";
            column.dependencyIndices     = null;
            column.compareDelegate       = delegate(SerializedProperty lhs, SerializedProperty rhs)
            {
                float num;
                float num2;
                float num3;
                Color.RGBToHSV(((Material)lhs.serializedObject.targetObject).GetColor("_EmissionColor"), out num, out num2, out num3);
                float num4;
                float num5;
                float value;
                Color.RGBToHSV(((Material)rhs.serializedObject.targetObject).GetColor("_EmissionColor"), out num4, out num5, out value);
                return(num3.CompareTo(value));
            };
            column.drawDelegate = delegate(Rect r, SerializedProperty prop, SerializedProperty[] dep)
            {
                if (prop.serializedObject.targetObject.GetType().Equals(typeof(Material)))
                {
                    using (new EditorGUI.DisabledScope(!LightTableColumns.IsEditable(prop.serializedObject.targetObject)))
                    {
                        Material material = (Material)prop.serializedObject.targetObject;
                        Color    color    = material.GetColor("_EmissionColor");
                        EditorGUI.BeginChangeCheck();
                        Color value = EditorGUI.ColorField(r, GUIContent.Temp(""), color, true, false, true);
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObjects(new Material[]
                            {
                                material
                            }, "Modify Emission Color of " + material.name);
                            material.SetColor("_EmissionColor", value);
                        }
                    }
                }
            };
            column.copyDelegate = delegate(SerializedProperty target, SerializedProperty source)
            {
                Material material  = (Material)source.serializedObject.targetObject;
                Color    color     = material.GetColor("_EmissionColor");
                Material material2 = (Material)target.serializedObject.targetObject;
                material2.SetColor("_EmissionColor", color);
            };
            expr_07[arg_26F_1] = column;
            SerializedPropertyTreeView.Column[] columns = expr_07;
            return(LightTableColumns.FinalizeColumns(columns, out propNames));
        }
Пример #18
0
        public override void OnSelectionInspectorGUI()
        {
            BoundsInt selection = GridSelection.position;
            Tilemap   tilemap   = GridSelection.target.GetComponent <Tilemap>();

            int cellCount = selection.size.x * selection.size.y * selection.size.z;

            if (tilemap != null && cellCount > 0)
            {
                base.OnSelectionInspectorGUI();
                GUILayout.Space(10f);

                if (m_SelectionTiles == null || m_SelectionTiles.Length != cellCount)
                {
                    m_SelectionTiles         = new TileBase[cellCount];
                    m_SelectionColors        = new Color[cellCount];
                    m_SelectionMatrices      = new Matrix4x4[cellCount];
                    m_SelectionFlagsArray    = new TileFlags[cellCount];
                    m_SelectionSprites       = new Sprite[cellCount];
                    m_SelectionColliderTypes = new Tile.ColliderType[cellCount];
                }

                int index = 0;
                foreach (var p in selection.allPositionsWithin)
                {
                    m_SelectionTiles[index]         = tilemap.GetTile(p);
                    m_SelectionColors[index]        = tilemap.GetColor(p);
                    m_SelectionMatrices[index]      = tilemap.GetTransformMatrix(p);
                    m_SelectionFlagsArray[index]    = tilemap.GetTileFlags(p);
                    m_SelectionSprites[index]       = tilemap.GetSprite(p);
                    m_SelectionColliderTypes[index] = tilemap.GetColliderType(p);
                    index++;
                }

                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = m_SelectionTiles.Any(tile => tile != m_SelectionTiles.First());
                var      position = new Vector3Int(selection.xMin, selection.yMin, selection.zMin);
                TileBase newTile  = EditorGUILayout.ObjectField(Styles.tileLabel, tilemap.GetTile(position), typeof(TileBase), false) as TileBase;
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(tilemap, "Edit Tilemap");
                    foreach (var p in selection.allPositionsWithin)
                    {
                        tilemap.SetTile(p, newTile);
                    }
                }

                using (new EditorGUI.DisabledScope(true))
                {
                    EditorGUI.showMixedValue = m_SelectionSprites.Any(sprite => sprite != m_SelectionSprites.First());
                    EditorGUILayout.ObjectField(Styles.spriteLabel, m_SelectionSprites[0], typeof(Sprite), false, GUILayout.Height(EditorGUI.kSingleLineHeight));
                }

                bool colorFlagsAllEqual = m_SelectionFlagsArray.All(flags => (flags & TileFlags.LockColor) == (m_SelectionFlagsArray.First() & TileFlags.LockColor));
                using (new EditorGUI.DisabledScope(!colorFlagsAllEqual || (m_SelectionFlagsArray[0] & TileFlags.LockColor) != 0))
                {
                    EditorGUI.showMixedValue = m_SelectionColors.Any(color => color != m_SelectionColors.First());
                    EditorGUI.BeginChangeCheck();
                    Color newColor = EditorGUILayout.ColorField(Styles.colorLabel, m_SelectionColors[0]);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(tilemap, "Edit Tilemap");
                        foreach (var p in selection.allPositionsWithin)
                        {
                            tilemap.SetColor(p, newColor);
                        }
                    }
                }

                using (new EditorGUI.DisabledScope(true))
                {
                    EditorGUI.showMixedValue = m_SelectionColliderTypes.Any(colliderType => colliderType != m_SelectionColliderTypes.First());
                    EditorGUILayout.EnumPopup(Styles.colliderTypeLabel, m_SelectionColliderTypes[0]);
                }

                bool transformFlagsAllEqual = m_SelectionFlagsArray.All(flags => (flags & TileFlags.LockTransform) == (m_SelectionFlagsArray.First() & TileFlags.LockTransform));
                using (new EditorGUI.DisabledScope(!transformFlagsAllEqual || (m_SelectionFlagsArray[0] & TileFlags.LockTransform) != 0))
                {
                    EditorGUI.showMixedValue = m_SelectionMatrices.Any(matrix => matrix != m_SelectionMatrices.First());
                    EditorGUI.BeginChangeCheck();
                    Matrix4x4 newTransformMatrix = TileEditor.TransformMatrixOnGUI(m_SelectionMatrices[0]);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(tilemap, "Edit Tilemap");
                        foreach (var p in selection.allPositionsWithin)
                        {
                            tilemap.SetTransformMatrix(p, newTransformMatrix);
                        }
                    }
                }

                using (new EditorGUI.DisabledScope(true))
                {
                    EditorGUI.showMixedValue = !colorFlagsAllEqual;
                    EditorGUILayout.Toggle(Styles.lockColorLabel, (m_SelectionFlagsArray[0] & TileFlags.LockColor) != 0);
                    EditorGUI.showMixedValue = !transformFlagsAllEqual;
                    EditorGUILayout.Toggle(Styles.lockTransformLabel, (m_SelectionFlagsArray[0] & TileFlags.LockTransform) != 0);
                }

                EditorGUI.showMixedValue = false;
            }
        }
Пример #19
0
        private void SearchArea()
        {
            GUI.Label(new Rect(0f, 0f, base.position.width, this.m_ToolbarHeight), GUIContent.none, this.m_Styles.toolbarBack);
            bool flag = Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape;

            GUI.SetNextControlName("SearchFilter");
            string text = EditorGUI.SearchField(new Rect(5f, 5f, base.position.width - 10f, 15f), this.m_SearchFilter);

            if (flag && Event.current.type == EventType.Used)
            {
                if (this.m_SearchFilter == "")
                {
                    this.Cancel();
                }
                this.m_FocusSearchFilter = true;
            }
            if (text != this.m_SearchFilter || this.m_FocusSearchFilter)
            {
                this.m_SearchFilter = text;
                this.FilterSettingsChanged();
                base.Repaint();
            }
            if (this.m_FocusSearchFilter)
            {
                EditorGUI.FocusTextInControl("SearchFilter");
                this.m_FocusSearchFilter = false;
            }
            GUI.changed = false;
            GUILayout.BeginArea(new Rect(0f, 26f, base.position.width, this.m_ToolbarHeight - 26f));
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            bool flag2 = GUILayout.Toggle(this.m_IsShowingAssets, "Assets", this.m_Styles.tab, new GUILayoutOption[0]);

            if (!this.m_IsShowingAssets && flag2)
            {
                this.m_IsShowingAssets = true;
            }
            if (!this.m_AllowSceneObjects)
            {
                GUI.enabled = false;
                GUI.color   = new Color(1f, 1f, 1f, 0f);
            }
            bool flag3 = !this.m_IsShowingAssets;

            flag3 = GUILayout.Toggle(flag3, "Scene", this.m_Styles.tab, new GUILayoutOption[0]);
            if (this.m_IsShowingAssets && flag3)
            {
                this.m_IsShowingAssets = false;
            }
            if (!this.m_AllowSceneObjects)
            {
                GUI.color   = new Color(1f, 1f, 1f, 1f);
                GUI.enabled = true;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
            if (GUI.changed)
            {
                this.FilterSettingsChanged();
            }
            if (this.m_ListArea.CanShowThumbnails())
            {
                EditorGUI.BeginChangeCheck();
                int gridSize = (int)GUI.HorizontalSlider(new Rect(base.position.width - 60f, 26f, 55f, this.m_ToolbarHeight - 28f), (float)this.m_ListArea.gridSize, (float)this.m_ListArea.minGridSize, (float)this.m_ListArea.maxGridSize);
                if (EditorGUI.EndChangeCheck())
                {
                    this.m_ListArea.gridSize = gridSize;
                }
            }
        }
Пример #20
0
        public void RotationField(bool disabled)
        {
            Transform t          = targets[0] as Transform;
            Vector3   localEuler = t.GetLocalEulerAngles(t.rotationOrder);

            if (
                m_OldEulerAngles.x != localEuler.x ||
                m_OldEulerAngles.y != localEuler.y ||
                m_OldEulerAngles.z != localEuler.z ||
                m_OldRotationOrder != t.rotationOrder
                )
            {
                m_EulerAngles      = t.GetLocalEulerAngles(t.rotationOrder);
                m_OldRotationOrder = t.rotationOrder;
            }
            bool differentRotation      = false;
            bool differentRotationOrder = false;

            for (int i = 1; i < targets.Length; i++)
            {
                Transform otherTransform  = (targets[i] as Transform);
                Vector3   otherLocalEuler = otherTransform.GetLocalEulerAngles(otherTransform.rotationOrder);
                differentRotation |= (otherLocalEuler.x != localEuler.x ||
                                      otherLocalEuler.y != localEuler.y ||
                                      otherLocalEuler.z != localEuler.z);

                differentRotationOrder |= otherTransform.rotationOrder != t.rotationOrder;
            }

            Rect       r     = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight * (EditorGUIUtility.wideMode ? 1 : 2));
            GUIContent label = EditorGUI.BeginProperty(r, rotationContent, m_Rotation);

            m_EulerFloats[0] = m_EulerAngles.x;
            m_EulerFloats[1] = m_EulerAngles.y;
            m_EulerFloats[2] = m_EulerAngles.z;

            EditorGUI.showMixedValue = differentRotation;

            EditorGUI.BeginChangeCheck();

            int    id            = GUIUtility.GetControlID(s_FoldoutHash, FocusType.Keyboard, r);
            string rotationLabel = "";

            if (AnimationMode.InAnimationMode() && t.rotationOrder != RotationOrder.OrderZXY)
            {
                if (differentRotationOrder)
                {
                    rotationLabel = "Mixed";
                }
                else
                {
                    rotationLabel = (t.rotationOrder).ToString();
                    rotationLabel = rotationLabel.Substring(rotationLabel.Length - 3);
                }

                label.text = label.text + " (" + rotationLabel + ")";
            }

            // Using MultiFieldPrefixLabel/MultiFloatField here instead of Vector3Field
            // so that the label and the float fields can be disabled separately,
            // similar to other property-driven controls
            // Using MultiFloatField instead of Vector3Field to avoid superfluous label
            // (which creates a focus target even when there's no content (Case 953241))
            r        = EditorGUI.MultiFieldPrefixLabel(r, id, label, 3);
            r.height = EditorGUIUtility.singleLineHeight;
            using (new EditorGUI.DisabledScope(disabled))
                EditorGUI.MultiFloatField(r, s_XYZLabels, m_EulerFloats);

            if (EditorGUI.EndChangeCheck())
            {
                m_EulerAngles = new Vector3(m_EulerFloats[0], m_EulerFloats[1], m_EulerFloats[2]);
                Undo.RecordObjects(targets, "Inspector");  // Generic undo title to be consistent with Position and Scale changes.
                foreach (Transform tr in targets)
                {
                    tr.SetLocalEulerAngles(m_EulerAngles, tr.rotationOrder);
                    if (tr.parent != null)
                    {
                        tr.SendTransformChangedScale(); // force scale update, needed if tr has non-uniformly scaled parent.
                    }
                }
                m_Rotation.serializedObject.SetIsDifferentCacheDirty();
            }

            EditorGUI.showMixedValue = false;

            if (differentRotationOrder)
            {
                EditorGUILayout.HelpBox("Transforms have different rotation orders, keyframes saved will have the same value but not the same local rotation", MessageType.Warning);
            }

            EditorGUI.EndProperty();
        }
        private void OnClipboardGUI(Rect position)
        {
            if (Event.current.type != EventType.Layout && position.Contains(Event.current.mousePosition) && GridPaintingState.activeGrid != clipboardView)
            {
                GridPaintingState.activeGrid = clipboardView;
                SceneView.RepaintAll();
            }

            // Validate palette (case 1017965)
            GUIContent paletteError = null;

            if (palette == null)
            {
                if (GridPalettes.palettes.Count == 0)
                {
                    paletteError = Styles.emptyProjectInfo;
                }
                else
                {
                    paletteError = Styles.invalidPaletteInfo;
                }
            }
            else if (palette.GetComponent <Grid>() == null)
            {
                paletteError = Styles.invalidGridInfo;
            }

            if (paletteError != null)
            {
                Color old = GUI.color;
                GUI.color = Color.gray;
                GUI.Label(new Rect(position.center.x - GUI.skin.label.CalcSize(paletteError).x * .5f, position.center.y, 500, 100), paletteError);
                GUI.color = old;
                return;
            }

            bool oldEnabled = GUI.enabled;

            GUI.enabled = !clipboardView.showNewEmptyClipboardInfo || DragAndDrop.objectReferences.Length > 0;

            if (Event.current.type == EventType.Repaint)
            {
                clipboardView.guiRect = position;
            }

            EditorGUI.BeginChangeCheck();
            clipboardView.OnGUI();
            if (EditorGUI.EndChangeCheck())
            {
                Repaint();
            }

            GUI.enabled = oldEnabled;

            if (clipboardView.showNewEmptyClipboardInfo)
            {
                Color old = GUI.color;
                GUI.color = Color.gray;
                Rect rect = new Rect(position.center.x - GUI.skin.label.CalcSize(Styles.emptyPaletteInfo).x * .5f, position.center.y, 500, 100);
                GUI.Label(rect, Styles.emptyPaletteInfo);
                GUI.color = old;
            }
        }
Пример #22
0
 public override void OnInspectorGUI()
 {
     base.serializedObject.Update();
     if (this.m_AllRoot)
     {
         EditorGUILayout.PropertyField(this.m_RenderMode, new GUILayoutOption[0]);
         this.m_OverlayMode.target = this.m_RenderMode.intValue == 0;
         this.m_CameraMode.target  = this.m_RenderMode.intValue == 1;
         this.m_WorldMode.target   = this.m_RenderMode.intValue == 2;
         EditorGUI.indentLevel++;
         if (EditorGUILayout.BeginFadeGroup(this.m_OverlayMode.faded))
         {
             EditorGUILayout.PropertyField(this.m_PixelPerfect, new GUILayoutOption[0]);
             EditorGUILayout.PropertyField(this.m_SortingOrder, this.sortingOrder, new GUILayoutOption[0]);
         }
         EditorGUILayout.EndFadeGroup();
         if (EditorGUILayout.BeginFadeGroup(this.m_CameraMode.faded))
         {
             EditorGUILayout.PropertyField(this.m_PixelPerfect, new GUILayoutOption[0]);
             EditorGUILayout.PropertyField(this.m_Camera, this.renderCamera, new GUILayoutOption[0]);
             EditorGUILayout.PropertyField(this.m_PlaneDistance, new GUILayoutOption[0]);
             EditorGUILayout.Space();
             EditorGUILayout.SortingLayerField(this.m_SortingLayerStyle, this.m_SortingLayerID, EditorStyles.popup, EditorStyles.label);
             EditorGUILayout.PropertyField(this.m_SortingOrder, this.m_SortingOrderStyle, new GUILayoutOption[0]);
         }
         EditorGUILayout.EndFadeGroup();
         if (EditorGUILayout.BeginFadeGroup(this.m_WorldMode.faded))
         {
             EditorGUILayout.PropertyField(this.m_Camera, this.eventCamera, new GUILayoutOption[0]);
             EditorGUILayout.Space();
             EditorGUILayout.SortingLayerField(this.m_SortingLayerStyle, this.m_SortingLayerID, EditorStyles.popup);
             EditorGUILayout.PropertyField(this.m_SortingOrder, this.m_SortingOrderStyle, new GUILayoutOption[0]);
         }
         EditorGUILayout.EndFadeGroup();
         EditorGUI.indentLevel--;
     }
     else if (this.m_AllNested)
     {
         EditorGUI.BeginChangeCheck();
         this.pixelPerfect = (PixelPerfect)EditorGUILayout.EnumPopup("Pixel Perfect", this.pixelPerfect, new GUILayoutOption[0]);
         if (EditorGUI.EndChangeCheck())
         {
             if (this.pixelPerfect == PixelPerfect.Inherit)
             {
                 this.m_PixelPerfectOverride.boolValue = false;
             }
             else if (this.pixelPerfect == PixelPerfect.Off)
             {
                 this.m_PixelPerfectOverride.boolValue = true;
                 this.m_PixelPerfect.boolValue         = false;
             }
             else
             {
                 this.m_PixelPerfectOverride.boolValue = true;
                 this.m_PixelPerfect.boolValue         = true;
             }
         }
         EditorGUILayout.PropertyField(this.m_OverrideSorting, new GUILayoutOption[0]);
         this.m_SortingOverride.target = this.m_OverrideSorting.boolValue;
         if (EditorGUILayout.BeginFadeGroup(this.m_SortingOverride.faded))
         {
             if (this.m_AllOverlay)
             {
                 EditorGUILayout.PropertyField(this.m_SortingOrder, this.sortingOrder, new GUILayoutOption[0]);
             }
             else if (this.m_NoneOverlay)
             {
                 EditorGUILayout.SortingLayerField(this.m_SortingLayerStyle, this.m_SortingLayerID, EditorStyles.popup);
                 EditorGUILayout.PropertyField(this.m_SortingOrder, this.m_SortingOrderStyle, new GUILayoutOption[0]);
             }
         }
         EditorGUILayout.EndFadeGroup();
     }
     else
     {
         GUILayout.Label(s_RootAndNestedMessage, EditorStyles.helpBox, new GUILayoutOption[0]);
     }
     base.serializedObject.ApplyModifiedProperties();
 }
Пример #23
0
        protected void OnRenderTextureGUI(GUIElements guiElements)
        {
            GUI.changed = false;

            bool isTexture3D = (m_Dimension.intValue == (int)UnityEngine.Rendering.TextureDimension.Tex3D);

            EditorGUILayout.IntPopup(m_Dimension, styles.dimensionStrings, styles.dimensionValues, styles.dimension);

            GUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(styles.size, EditorStyles.popup);
            EditorGUILayout.DelayedIntField(m_Width, GUIContent.none, GUILayout.MinWidth(40));
            GUILayout.Label(styles.cross);
            EditorGUILayout.DelayedIntField(m_Height, GUIContent.none, GUILayout.MinWidth(40));
            if (isTexture3D)
            {
                GUILayout.Label(styles.cross);
                EditorGUILayout.DelayedIntField(m_Depth, GUIContent.none, GUILayout.MinWidth(40));
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            if ((guiElements & GUIElements.RenderTargetAAGUI) != 0)
            {
                EditorGUILayout.IntPopup(m_AntiAliasing, styles.renderTextureAntiAliasing, styles.renderTextureAntiAliasingValues, styles.antiAliasing);
            }

            GraphicsFormat format           = (GraphicsFormat)m_ColorFormat.intValue;
            GraphicsFormat compatibleFormat = SystemInfo.GetCompatibleFormat(format, FormatUsage.Render);

            using (new EditorGUI.DisabledScope(compatibleFormat == GraphicsFormat.None))
                EditorGUILayout.PropertyField(m_EnableCompatibleFormat, styles.enableCompatibleFormat);

            EditorGUILayout.PropertyField(m_ColorFormat, styles.colorFormat);

            if (compatibleFormat != format)
            {
                string text = string.Format("Format {0} is not supported on this platform. ", format.ToString());
                if (compatibleFormat != GraphicsFormat.None)
                {
                    if (m_EnableCompatibleFormat.boolValue)
                    {
                        text += string.Format("Using {0} as a compatible format.", compatibleFormat.ToString());
                    }
                    else
                    {
                        text += string.Format("You may enable Compatible Color Format to fallback automatically to a platform specific compatible format, {0} on this device.", compatibleFormat.ToString());
                    }
                }
                EditorGUILayout.HelpBox(text, m_EnableCompatibleFormat.boolValue && compatibleFormat != GraphicsFormat.None ? MessageType.Warning : MessageType.Error);
            }

            if ((guiElements & GUIElements.RenderTargetDepthGUI) != 0)
            {
                EditorGUILayout.PropertyField(m_DepthFormat, styles.depthBuffer);
            }

            m_sRGB.boolValue = GraphicsFormatUtility.IsSRGBFormat(format);

            using (new EditorGUI.DisabledScope(isTexture3D))
            {
                EditorGUILayout.PropertyField(m_EnableMipmaps, styles.enableMipmaps);
                using (new EditorGUI.DisabledScope(!m_EnableMipmaps.boolValue))
                    EditorGUILayout.PropertyField(m_AutoGeneratesMipmaps, styles.autoGeneratesMipmaps);
            }

            if (isTexture3D)
            {
                // Mip map generation is not supported yet for 3D textures.
                EditorGUILayout.HelpBox("3D RenderTextures do not support Mip Maps.", MessageType.Info);
            }

            EditorGUILayout.PropertyField(m_UseDynamicScale, styles.useDynamicScale);

            var rt = target as RenderTexture;

            if (GUI.changed && rt != null)
            {
                rt.Release();
            }

            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            DoWrapModePopup();
            DoFilterModePopup();

            using (new EditorGUI.DisabledScope(RenderTextureHasDepth())) // Render Textures with depth are forced to 0 Aniso Level
            {
                DoAnisoLevelSlider();
            }
            if (RenderTextureHasDepth())
            {
                // RenderTextures don't enforce this nicely. RenderTexture only forces Aniso to 0 if the gfx card
                // supports depth, rather than forcing Aniso to zero depending on what the user asks of the RT. If the
                // user requests any kind of depth then we will force aniso to zero here.
                m_Aniso.intValue = 0;
                EditorGUILayout.HelpBox("RenderTextures with depth must have an Aniso Level of 0.", MessageType.Info);
            }

            if (EditorGUI.EndChangeCheck())
            {
                ApplySettingsToTextures();
            }
        }
Пример #24
0
        // showPerAxisWrapModes is state of whether "Per-Axis" mode should be active in the main dropdown.
        // It is set automatically if wrap modes in UVW are different, or if user explicitly picks "Per-Axis" option -- when that one is picked,
        // then it should stay true even if UVW wrap modes will initially be the same.
        //
        // Note: W wrapping mode is only shown when isVolumeTexture is true.
        internal static void WrapModePopup(SerializedProperty wrapU, SerializedProperty wrapV, SerializedProperty wrapW, bool isVolumeTexture, ref bool showPerAxisWrapModes)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            // In texture importer settings, serialized properties for things like wrap modes can contain -1;
            // that seems to indicate "use defaults, user has not changed them to anything" but not totally sure.
            // Show them as Repeat wrap modes in the popups.
            var wu = (TextureWrapMode)Mathf.Max(wrapU.intValue, 0);
            var wv = (TextureWrapMode)Mathf.Max(wrapV.intValue, 0);
            var ww = (TextureWrapMode)Mathf.Max(wrapW.intValue, 0);

            // automatically go into per-axis mode if values are already different
            if (wu != wv)
            {
                showPerAxisWrapModes = true;
            }
            if (isVolumeTexture)
            {
                if (wu != ww || wv != ww)
                {
                    showPerAxisWrapModes = true;
                }
            }

            // It's not possible to determine whether any single texture in the whole selection is using per-axis wrap modes
            // just from SerializedProperty values. They can only tell if "some values in whole selection are different" (e.g.
            // wrap value on U axis is not the same among all textures), and can return value of "some" object in the selection
            // (typically based on object loading order). So in order for more intuitive behavior with multi-selection,
            // we go over the actual objects when there's >1 object selected and some wrap modes are different.
            if (!showPerAxisWrapModes)
            {
                if (wrapU.hasMultipleDifferentValues || wrapV.hasMultipleDifferentValues || (isVolumeTexture && wrapW.hasMultipleDifferentValues))
                {
                    if (IsAnyTextureObjectUsingPerAxisWrapMode(wrapU.serializedObject.targetObjects, isVolumeTexture))
                    {
                        showPerAxisWrapModes = true;
                    }
                }
            }

            int value = showPerAxisWrapModes ? -1 : (int)wu;

            // main wrap mode popup
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = !showPerAxisWrapModes && (wrapU.hasMultipleDifferentValues || wrapV.hasMultipleDifferentValues || (isVolumeTexture && wrapW.hasMultipleDifferentValues));
            value = EditorGUILayout.IntPopup(s_Styles.wrapModeLabel, value, s_Styles.wrapModeContents, s_Styles.wrapModeValues);
            if (EditorGUI.EndChangeCheck() && value != -1)
            {
                // assign the same wrap mode to all axes, and hide per-axis popups
                wrapU.intValue       = value;
                wrapV.intValue       = value;
                wrapW.intValue       = value;
                showPerAxisWrapModes = false;
            }

            // show per-axis popups if needed
            if (value == -1)
            {
                showPerAxisWrapModes = true;
                EditorGUI.indentLevel++;
                WrapModeAxisPopup(s_Styles.wrapU, wrapU);
                WrapModeAxisPopup(s_Styles.wrapV, wrapV);
                if (isVolumeTexture)
                {
                    WrapModeAxisPopup(s_Styles.wrapW, wrapW);
                }
                EditorGUI.indentLevel--;
            }
            EditorGUI.showMixedValue = false;
        }
        private void CollisionPlanesSceneGUI()
        {
            if (m_ScenePlanes.Count == 0)
            {
                return;
            }

            Event evt = Event.current;

            Color origCol = Handles.color;
            Color col     = new Color(1, 1, 1, 0.5F);

            for (int i = 0; i < m_ScenePlanes.Count; ++i)
            {
                if (m_ScenePlanes[i] == null)
                {
                    continue;
                }

                Transform  transform          = m_ScenePlanes[i];
                Vector3    position           = transform.position;
                Quaternion rotation           = transform.rotation;
                Vector3    right              = rotation * Vector3.right;
                Vector3    up                 = rotation * Vector3.up;
                Vector3    forward            = rotation * Vector3.forward;
                bool       isPlayingAndStatic = EditorApplication.isPlaying && transform.gameObject.isStatic;
                if (editingPlanes)
                {
                    if (Object.ReferenceEquals(s_SelectedTransform, transform))
                    {
                        EditorGUI.BeginChangeCheck();
                        var newPosition = transform.position;
                        var newRotation = transform.rotation;

                        using (new EditorGUI.DisabledScope(isPlayingAndStatic))
                        {
                            if (isPlayingAndStatic)
                            {
                                Handles.ShowStaticLabel(position);
                            }
                            if (EditMode.editMode == EditMode.SceneViewEditMode.ParticleSystemCollisionModulePlanesMove)
                            {
                                newPosition = Handles.PositionHandle(position, rotation);
                            }
                            else if (EditMode.editMode == EditMode.SceneViewEditMode.ParticleSystemCollisionModulePlanesRotate)
                            {
                                newRotation = Handles.RotationHandle(rotation, position);
                            }
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(transform, "Modified Collision Plane Transform");
                            transform.position = newPosition;
                            transform.rotation = newRotation;
                            ParticleSystemEditorUtils.PerformCompleteResimulation();
                        }
                    }
                    else
                    {
                        float handleSize = HandleUtility.GetHandleSize(position) * 0.6f;

                        EventType oldEventType = evt.type;

                        // we want ignored mouse up events to check for dragging off of scene view
                        if (evt.type == EventType.Ignore && evt.rawType == EventType.MouseUp)
                        {
                            oldEventType = evt.rawType;
                        }

                        Handles.FreeMoveHandle(position, Quaternion.identity, handleSize, Vector3.zero, Handles.RectangleHandleCap);

                        // Detect selected plane (similar to TreeEditor)
                        if (oldEventType == EventType.MouseDown && evt.type == EventType.Used)
                        {
                            s_SelectedTransform   = transform;
                            oldEventType          = EventType.Used;
                            GUIUtility.hotControl = 0; // Reset hot control or the FreeMoveHandle will prevent input to the new Handles. (case 873514)
                        }
                    }
                }

                Handles.color = col;
                Color color = Handles.s_ColliderHandleColor * 0.9f;
                if (isPlayingAndStatic)
                {
                    color.a *= 0.2f;
                }

                if (m_PlaneVisualizationType == PlaneVizType.Grid)
                {
                    DrawGrid(position, right, forward, up, color);
                }
                else
                {
                    DrawSolidPlane(position, rotation, color, Color.yellow);
                }
            }

            Handles.color = origCol;
        }
        public override void OnInspectorGUI()
        {
            if (m_EditorUserSettings != null && !m_EditorUserSettings.targetObject)
            {
                LoadEditorUserSettings();
            }

            serializedObject.Update();

            // GUI.enabled hack because we don't want some controls to be disabled if the EditorSettings.asset is locked
            // since some of the controls are not dependent on the Editor Settings asset. Unfortunately, this assumes
            // that the editor will only be disabled because of version control locking which may change in the future.
            var editorEnabled = GUI.enabled;

            ShowUnityRemoteGUI(editorEnabled);

            GUILayout.Space(10);
            bool collabEnabled = Collab.instance.IsCollabEnabledForCurrentProject();
            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label(Content.versionControl, EditorStyles.boldLabel);

                ExternalVersionControl selvc = EditorSettings.externalVersionControl;
                CreatePopupMenuVersionControl(Content.mode.text, vcPopupList, selvc, SetVersionControlSystem);
                GUI.enabled = editorEnabled && !collabEnabled;
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Version Control not available when using Collaboration feature.", MessageType.Warning);
            }

            if (VersionControlSystemHasGUI())
            {
                GUI.enabled = true;
                bool hasRequiredFields = false;

                if (EditorSettings.externalVersionControl == ExternalVersionControl.Generic ||
                    EditorSettings.externalVersionControl == ExternalVersionControl.Disabled)
                {
                    // no specific UI for these VCS types
                }
                else
                {
                    ConfigField[] configFields = Provider.GetActiveConfigFields();

                    hasRequiredFields = true;

                    foreach (ConfigField field in configFields)
                    {
                        string newVal;
                        string oldVal = EditorUserSettings.GetConfigValue(field.name);
                        if (field.isPassword)
                        {
                            newVal = EditorGUILayout.PasswordField(field.label, oldVal);
                            if (newVal != oldVal)
                                EditorUserSettings.SetPrivateConfigValue(field.name, newVal);
                        }
                        else
                        {
                            newVal = EditorGUILayout.TextField(field.label, oldVal);
                            if (newVal != oldVal)
                                EditorUserSettings.SetConfigValue(field.name, newVal);
                        }

                        if (field.isRequired && string.IsNullOrEmpty(newVal))
                            hasRequiredFields = false;
                    }
                }

                // Log level popup
                string logLevel = EditorUserSettings.GetConfigValue("vcSharedLogLevel");
                int idx = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                if (idx == -1)
                {
                    logLevel = "notice";
                    idx = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                    if (idx == -1)
                    {
                        idx = 0;
                    }
                    logLevel = logLevelPopupList[idx];
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevel);
                }
                int newIdx = EditorGUILayout.Popup(Content.logLevel, idx, logLevelPopupList);
                if (newIdx != idx)
                {
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevelPopupList[newIdx].ToLower());
                }

                GUI.enabled = editorEnabled;

                string osState = "Connected";
                if (Provider.onlineState == OnlineState.Updating)
                    osState = "Connecting...";
                else if (Provider.onlineState == OnlineState.Offline)
                    osState = "Disconnected";
                else if (EditorUserSettings.WorkOffline)
                    osState = "Work Offline";

                EditorGUILayout.LabelField(Content.status.text, osState);

                if (Provider.onlineState != OnlineState.Online && !string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.enabled = false;
                    GUILayout.TextArea(Provider.offlineReason);
                    GUI.enabled = editorEnabled;
                }

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.enabled = hasRequiredFields && Provider.onlineState != OnlineState.Updating;
                if (GUILayout.Button("Connect", EditorStyles.miniButton))
                    Provider.UpdateSettings();
                GUILayout.EndHorizontal();

                EditorUserSettings.AutomaticAdd = EditorGUILayout.Toggle(Content.automaticAdd, EditorUserSettings.AutomaticAdd);

                if (Provider.requiresNetwork)
                {
                    bool workOfflineNew = EditorGUILayout.Toggle(Content.workOffline, EditorUserSettings.WorkOffline); // Enabled has a slightly different behaviour
                    if (workOfflineNew != EditorUserSettings.WorkOffline)
                    {
                        // On toggling on show a warning
                        if (workOfflineNew && !EditorUtility.DisplayDialog("Confirm working offline", "Working offline and making changes to your assets means that you will have to manually integrate changes back into version control using your standard version control client before you stop working offline in Unity. Make sure you know what you are doing.", "Work offline", "Cancel"))
                        {
                            workOfflineNew = false; // User cancelled working offline
                        }
                        EditorUserSettings.WorkOffline = workOfflineNew;
                        EditorApplication.RequestRepaintAllViews();
                    }

                    EditorUserSettings.allowAsyncStatusUpdate = EditorGUILayout.Toggle(Content.allowAsyncUpdate, EditorUserSettings.allowAsyncStatusUpdate);
                }

                if (Provider.hasCheckoutSupport)
                {
                    EditorUserSettings.showFailedCheckout = EditorGUILayout.Toggle(Content.showFailedCheckouts, EditorUserSettings.showFailedCheckout);
                    EditorUserSettings.overwriteFailedCheckoutAssets = EditorGUILayout.Toggle(Content.overwriteFailedCheckoutAssets, EditorUserSettings.overwriteFailedCheckoutAssets);
                }

                var newOverlayIcons = EditorGUILayout.Toggle(Content.overlayIcons, EditorUserSettings.overlayIcons);
                if (newOverlayIcons != EditorUserSettings.overlayIcons)
                {
                    EditorUserSettings.overlayIcons = newOverlayIcons;
                    EditorApplication.RequestRepaintAllViews();
                }

                GUI.enabled = editorEnabled;

                // Semantic merge popup
                EditorUserSettings.semanticMergeMode = (SemanticMergeMode)EditorGUILayout.Popup(Content.smartMerge, (int)EditorUserSettings.semanticMergeMode, semanticMergePopupList);

                DrawOverlayDescriptions();
            }

            GUILayout.Space(10);

            int index = (int)EditorSettings.serializationMode;
            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label(Content.assetSerialization, EditorStyles.boldLabel);
                GUI.enabled = editorEnabled && !collabEnabled;


                CreatePopupMenu("Mode", serializationPopupList, index, SetAssetSerializationMode);
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Asset Serialization is forced to Text when using Collaboration feature.", MessageType.Warning);
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.defaultBehaviorMode, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.defaultBehaviorMode, 0, behaviorPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, behaviorPopupList, index, SetDefaultBehaviorMode);

            {
                var wasEnabled = GUI.enabled;
                GUI.enabled = true;

                DoAssetPipelineSettings();

                if (m_AssetPipelineMode.intValue == (int)AssetPipelineMode.Version2)
                    DoCacheServerSettings();

                GUI.enabled = wasEnabled;
            }
            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label("Prefab Editing Environments", EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            {
                EditorGUI.BeginChangeCheck();
                SceneAsset scene = EditorSettings.prefabRegularEnvironment;
                scene = (SceneAsset)EditorGUILayout.ObjectField("Regular Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                    EditorSettings.prefabRegularEnvironment = scene;
            }
            {
                EditorGUI.BeginChangeCheck();
                SceneAsset scene = EditorSettings.prefabUIEnvironment;
                scene = (SceneAsset)EditorGUILayout.ObjectField("UI Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                    EditorSettings.prefabUIEnvironment = scene;
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.graphics, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            EditorGUI.BeginChangeCheck();
            bool showRes = LightmapVisualization.showResolution;
            showRes = EditorGUILayout.Toggle(Content.showLightmapResolutionOverlay, showRes);
            if (EditorGUI.EndChangeCheck())
                LightmapVisualization.showResolution = showRes;

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.spritePacker, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.spritePackerMode, 0, spritePackerPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, spritePackerPopupList, index, SetSpritePackerMode);

            if (EditorSettings.spritePackerMode == SpritePackerMode.AlwaysOn
                || EditorSettings.spritePackerMode == SpritePackerMode.BuildTimeOnly)
            {
                index = Mathf.Clamp((int)(EditorSettings.spritePackerPaddingPower - 1), 0, 2);
                CreatePopupMenu("Padding Power (Legacy Sprite Packer)", spritePackerPaddingPowerPopupList, index, SetSpritePackerPaddingPower);
            }

            DoProjectGenerationSettings();
            DoEtcTextureCompressionSettings();
            DoLineEndingsSettings();
            DoStreamingSettings();
            DoShaderCompilationSettings();
            DoEnterPlayModeSettings();

            serializedObject.ApplyModifiedProperties();
            m_EditorUserSettings.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            if (!target)
            {
                return;
            }

            if (m_CustomUI != null && m_CustomUITerrain != null &&
                m_CustomUI.OnTerrainLayerGUI(target as TerrainLayer, m_CustomUITerrain))
            {
                return;
            }

            serializedObject.Update();

            EditorGUI.BeginChangeCheck();

            var  curMaskMap  = m_MaskMapTexture.objectReferenceValue as Texture2D;
            bool maskMapUsed = m_MaskMapUsed || curMaskMap != null;

            var r            = EditorGUILayout.GetControlRect(true, EditorGUI.kObjectFieldThumbnailHeight);
            var diffuseLabel = m_ShowMaskMap ? (maskMapUsed ? m_DiffuseMapMaskMapEnabledText : m_DiffuseMapText) : s_Styles.diffuseTexture;

            EditorGUI.BeginProperty(r, diffuseLabel, m_DiffuseTexture);
            EditorGUI.BeginChangeCheck();
            var diffuseTexture = EditorGUI.ObjectField(r, diffuseLabel, m_DiffuseTexture.objectReferenceValue as Texture2D, typeof(Texture2D), false) as Texture2D;

            if (EditorGUI.EndChangeCheck())
            {
                m_DiffuseTexture.objectReferenceValue = diffuseTexture;
            }
            EditorGUI.EndProperty();

            TerrainLayerUtility.ValidateDiffuseTextureUI(diffuseTexture);

            r = EditorGUILayout.GetControlRect(true, EditorGUI.kObjectFieldThumbnailHeight);
            EditorGUI.BeginProperty(r, s_Styles.normalMapTexture, m_NormalMapTexture);
            EditorGUI.BeginChangeCheck();
            var normalMapTexture = EditorGUI.ObjectField(r, s_Styles.normalMapTexture, m_NormalMapTexture.objectReferenceValue as Texture2D, typeof(Texture2D), false) as Texture2D;

            if (EditorGUI.EndChangeCheck())
            {
                m_NormalMapTexture.objectReferenceValue = normalMapTexture;
                m_NormalMapHasCorrectTextureType        = TerrainLayerUtility.CheckNormalMapTextureType(normalMapTexture);
            }
            EditorGUI.EndProperty();

            TerrainLayerUtility.ValidateNormalMapTextureUI(normalMapTexture, m_NormalMapHasCorrectTextureType);

            if (normalMapTexture != null)
            {
                ++EditorGUI.indentLevel;
                EditorGUILayout.PropertyField(m_NormalScale);
                --EditorGUI.indentLevel;
                EditorGUILayout.Space();
            }

            if (m_ShowMaskMap)
            {
                r = EditorGUILayout.GetControlRect(true, EditorGUI.kObjectFieldThumbnailHeight);
                EditorGUI.BeginProperty(r, m_MaskMapText, m_MaskMapTexture);
                EditorGUI.BeginChangeCheck();
                var maskMapTexture = EditorGUI.ObjectField(r, m_MaskMapText, curMaskMap, typeof(Texture2D), false) as Texture2D;
                if (EditorGUI.EndChangeCheck())
                {
                    m_MaskMapTexture.objectReferenceValue = maskMapTexture;
                }
                EditorGUI.EndProperty();

                TerrainLayerUtility.ValidateMaskMapTextureUI(maskMapTexture);

                if (maskMapUsed)
                {
                    ++EditorGUI.indentLevel;
                    m_ShowMaskRemap = EditorGUILayout.Foldout(m_ShowMaskRemap, s_Styles.channelRemapping);
                    if (m_ShowMaskRemap)
                    {
                        DoMinMaxLabels(s_Styles.min, s_Styles.max, EditorStyles.miniLabel);
                        DoMinMaxFloatFields(m_MaskRemapRText, EditorStyles.miniLabel, m_MaskRemapMinR, m_MaskRemapMaxR, EditorStyles.miniTextField);
                        DoMinMaxFloatFields(m_MaskRemapGText, EditorStyles.miniLabel, m_MaskRemapMinG, m_MaskRemapMaxG, EditorStyles.miniTextField);
                        DoMinMaxFloatFields(m_MaskRemapBText, EditorStyles.miniLabel, m_MaskRemapMinB, m_MaskRemapMaxB, EditorStyles.miniTextField);
                        DoMinMaxFloatFields(m_MaskRemapAText, EditorStyles.miniLabel, m_MaskRemapMinA, m_MaskRemapMaxA, EditorStyles.miniTextField);
                    }
                    --EditorGUI.indentLevel;
                }
            }

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(m_Specular);
            EditorGUILayout.Slider(m_Metallic, 0.0f, 1.0f);
            EditorGUILayout.Slider(m_Smoothness, 0.0f, 1.0f);

            EditorGUILayout.Space();
            TerrainLayerUtility.TilingSettingsUI(m_TileSize, m_TileOffset);

            m_HasChanged |= EditorGUI.EndChangeCheck();
            serializedObject.ApplyModifiedProperties();
        }
        private void BuiltinCustomSplashScreenGUI()
        {
            EditorGUILayout.LabelField(PlayerSettingsSplashScreenEditor.k_Texts.splashTitle, EditorStyles.boldLabel, new GUILayoutOption[0]);
            using (new EditorGUI.DisabledScope(!PlayerSettingsSplashScreenEditor.licenseAllowsDisabling))
            {
                EditorGUILayout.PropertyField(this.m_ShowUnitySplashScreen, PlayerSettingsSplashScreenEditor.k_Texts.showSplash, new GUILayoutOption[0]);
                if (!this.m_ShowUnitySplashScreen.boolValue)
                {
                    return;
                }
            }
            Rect rect = GUILayoutUtility.GetRect(PlayerSettingsSplashScreenEditor.k_Texts.previewSplash, "button");

            rect = EditorGUI.PrefixLabel(rect, new GUIContent(" "));
            if (GUI.Button(rect, PlayerSettingsSplashScreenEditor.k_Texts.previewSplash))
            {
                SplashScreen.Begin();
                GameView mainGameView = GameView.GetMainGameView();
                if (mainGameView)
                {
                    mainGameView.Focus();
                }
                GameView.RepaintAll();
            }
            EditorGUILayout.PropertyField(this.m_SplashScreenLogoStyle, PlayerSettingsSplashScreenEditor.k_Texts.splashStyle, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_SplashScreenAnimation, PlayerSettingsSplashScreenEditor.k_Texts.animate, new GUILayoutOption[0]);
            this.m_ShowAnimationControlsAnimator.target = (this.m_SplashScreenAnimation.intValue == 2);
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowAnimationControlsAnimator.faded))
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.Slider(this.m_SplashScreenLogoAnimationZoom, 0f, 1f, PlayerSettingsSplashScreenEditor.k_Texts.logoZoom, new GUILayoutOption[0]);
                EditorGUILayout.Slider(this.m_SplashScreenBackgroundAnimationZoom, 0f, 1f, PlayerSettingsSplashScreenEditor.k_Texts.backgroundZoom, new GUILayoutOption[0]);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFadeGroup();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField(PlayerSettingsSplashScreenEditor.k_Texts.logosTitle, EditorStyles.boldLabel, new GUILayoutOption[0]);
            using (new EditorGUI.DisabledScope(!Application.HasProLicense()))
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(this.m_ShowUnitySplashLogo, PlayerSettingsSplashScreenEditor.k_Texts.showLogo, new GUILayoutOption[0]);
                if (EditorGUI.EndChangeCheck())
                {
                    if (!this.m_ShowUnitySplashLogo.boolValue)
                    {
                        this.RemoveUnityLogoFromLogosList();
                    }
                    else if (this.m_SplashScreenDrawMode.intValue == 1)
                    {
                        this.AddUnityLogoToLogosList();
                    }
                }
                this.m_ShowLogoControlsAnimator.target = this.m_ShowUnitySplashLogo.boolValue;
            }
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowLogoControlsAnimator.faded))
            {
                EditorGUI.indentLevel++;
                EditorGUI.BeginChangeCheck();
                int intValue = this.m_SplashScreenDrawMode.intValue;
                EditorGUILayout.PropertyField(this.m_SplashScreenDrawMode, PlayerSettingsSplashScreenEditor.k_Texts.drawMode, new GUILayoutOption[0]);
                if (intValue != this.m_SplashScreenDrawMode.intValue)
                {
                    if (this.m_SplashScreenDrawMode.intValue == 0)
                    {
                        this.RemoveUnityLogoFromLogosList();
                    }
                    else
                    {
                        this.AddUnityLogoToLogosList();
                    }
                }
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFadeGroup();
            this.m_LogoList.DoLayoutList();
            EditorGUILayout.Space();
            EditorGUILayout.LabelField(PlayerSettingsSplashScreenEditor.k_Texts.backgroundTitle, EditorStyles.boldLabel, new GUILayoutOption[0]);
            EditorGUILayout.Slider(this.m_SplashScreenOverlayOpacity, (!Application.HasProLicense()) ? PlayerSettingsSplashScreenEditor.k_MinPersonalEditionOverlayOpacity : PlayerSettingsSplashScreenEditor.k_MinProEditionOverlayOpacity, 1f, PlayerSettingsSplashScreenEditor.k_Texts.overlayOpacity, new GUILayoutOption[0]);
            this.m_ShowBackgroundColorAnimator.target = (this.m_SplashScreenBackgroundLandscape.objectReferenceValue == null);
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowBackgroundColorAnimator.faded))
            {
                EditorGUILayout.PropertyField(this.m_SplashScreenBackgroundColor, PlayerSettingsSplashScreenEditor.k_Texts.backgroundColor, new GUILayoutOption[0]);
            }
            EditorGUILayout.EndFadeGroup();
            PlayerSettingsSplashScreenEditor.ObjectReferencePropertyField <Sprite>(this.m_SplashScreenBackgroundLandscape, PlayerSettingsSplashScreenEditor.k_Texts.backgroundImage);
            if (GUI.changed && this.m_SplashScreenBackgroundLandscape.objectReferenceValue == null)
            {
                this.m_SplashScreenBackgroundPortrait.objectReferenceValue = null;
            }
            using (new EditorGUI.DisabledScope(this.m_SplashScreenBackgroundLandscape.objectReferenceValue == null))
            {
                PlayerSettingsSplashScreenEditor.ObjectReferencePropertyField <Sprite>(this.m_SplashScreenBackgroundPortrait, PlayerSettingsSplashScreenEditor.k_Texts.backgroundPortraitImage);
            }
        }
Пример #29
0
        void OnGUI()
        {
            Event e = Event.current;

            LoadIcons();
            LogEntries.wrapped.UpdateEntries();

            if (!m_HasUpdatedGuiStyles)
            {
                m_LineHeight   = Mathf.RoundToInt(Constants.ErrorStyle.lineHeight);
                m_BorderHeight = Constants.ErrorStyle.border.top + Constants.ErrorStyle.border.bottom;
                UpdateListView();
            }

            GUILayout.BeginHorizontal(Constants.Toolbar);

            if (GUILayout.Button(Constants.ClearLabel, Constants.MiniButton))
            {
                LogEntries.Clear();
                GUIUtility.keyboardControl = 0;
            }

            int currCount = LogEntries.wrapped.GetCount();

            if (m_ListView.totalRows != currCount && m_ListView.totalRows > 0)
            {
                // scroll bar was at the bottom?
                if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight)
                {
                    m_ListView.scrollPos.y = currCount * RowHeight - ms_LVHeight;
                }
            }

            if (LogEntries.wrapped.searchFrame)
            {
                LogEntries.wrapped.searchFrame = false;
                int selectedIndex = LogEntries.wrapped.GetSelectedEntryIndex();
                if (selectedIndex != -1)
                {
                    int showIndex = selectedIndex + 1;
                    if (currCount > showIndex)
                    {
                        int showCount = ms_LVHeight / RowHeight;
                        showIndex = showIndex + showCount / 2;
                    }
                    m_ListView.scrollPos.y = showIndex * RowHeight - ms_LVHeight;
                }
            }

            EditorGUILayout.Space();

            bool wasCollapsed = LogEntries.wrapped.collapse;

            LogEntries.wrapped.collapse = GUILayout.Toggle(wasCollapsed, Constants.CollapseLabel, Constants.MiniButton);

            bool collapsedChanged = (wasCollapsed != LogEntries.wrapped.collapse);

            if (collapsedChanged)
            {
                // unselect if collapsed flag changed
                m_ListView.row = -1;

                // scroll to bottom
                m_ListView.scrollPos.y = LogEntries.wrapped.GetCount() * RowHeight;
            }

            SetFlag(ConsoleFlags.ClearOnPlay, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnPlay), Constants.ClearOnPlayLabel, Constants.MiniButton));
#if UNITY_2019_1_OR_NEWER
            SetFlag(ConsoleFlags.ClearOnBuild, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnBuild), Constants.ClearOnBuildLabel, Constants.MiniButton));
#endif
            SetFlag(ConsoleFlags.ErrorPause, GUILayout.Toggle(HasFlag(ConsoleFlags.ErrorPause), Constants.ErrorPauseLabel, Constants.MiniButton));

#if UNITY_2018_3_OR_NEWER
            ConnectionGUILayout.AttachToPlayerDropdown(m_ConsoleAttachToPlayerState, EditorStyles.toolbarDropDown);
#endif

            EditorGUILayout.Space();

            if (m_DevBuild)
            {
                GUILayout.FlexibleSpace();
                SetFlag(ConsoleFlags.StopForAssert, GUILayout.Toggle(HasFlag(ConsoleFlags.StopForAssert), Constants.StopForAssertLabel, Constants.MiniButton));
                SetFlag(ConsoleFlags.StopForError, GUILayout.Toggle(HasFlag(ConsoleFlags.StopForError), Constants.StopForErrorLabel, Constants.MiniButton));
            }

            GUILayout.FlexibleSpace();

            // Search bar
            GUILayout.Space(4f);
            SearchField(e);

            int errorCount = 0, warningCount = 0, logCount = 0;
            LogEntries.wrapped.GetCountsByType(ref errorCount, ref warningCount, ref logCount);
            EditorGUI.BeginChangeCheck();
            bool setLogFlag     = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelLog), new GUIContent((logCount <= 999 ? logCount.ToString() : "999+"), logCount > 0 ? iconInfoSmall : iconInfoMono), Constants.MiniButton);
            bool setWarningFlag = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelWarning), new GUIContent((warningCount <= 999 ? warningCount.ToString() : "999+"), warningCount > 0 ? iconWarnSmall : iconWarnMono), Constants.MiniButton);
            bool setErrorFlag   = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelError), new GUIContent((errorCount <= 999 ? errorCount.ToString() : "999+"), errorCount > 0 ? iconErrorSmall : iconErrorMono), Constants.MiniButton);
            // Active entry index may no longer be valid
            if (EditorGUI.EndChangeCheck())
            {
            }

            LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelLog, setLogFlag);
            LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelWarning, setWarningFlag);
            LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelError, setErrorFlag);

            if (GUILayout.Button(new GUIContent(errorCount > 0 ? iconFirstErrorSmall : iconFirstErrorMono, Constants.FirstErrorLabel), Constants.MiniButton))
            {
                int firstErrorIndex = LogEntries.wrapped.GetFirstErrorEntryIndex();
                if (firstErrorIndex != -1)
                {
                    SetActiveEntry(firstErrorIndex);
                    LogEntries.wrapped.searchFrame = true;
                }
            }

            GUILayout.EndHorizontal();

            SplitterGUILayout.BeginVerticalSplit(spl);
            int rowHeight = RowHeight;
            EditorGUIUtility.SetIconSize(new Vector2(rowHeight, rowHeight));
            GUIContent tempContent      = new GUIContent();
            int        id               = GUIUtility.GetControlID(0);
            int        rowDoubleClicked = -1;

            /////@TODO: Make Frame selected work with ListViewState
            using (new GettingLogEntriesScope(m_ListView))
            {
                int  selectedRow      = -1;
                bool openSelectedItem = false;
                bool collapsed        = LogEntries.wrapped.collapse;
                foreach (ListViewElement el in ListViewGUI.ListView(m_ListView, Constants.Box))
                {
                    if (e.type == EventType.MouseDown && e.button == 0 && el.position.Contains(e.mousePosition))
                    {
                        m_ListView.row = el.row;
                        selectedRow    = el.row;
                        if (e.clickCount == 2)
                        {
                            openSelectedItem = true;
                        }
                    }
                    else if (e.type == EventType.Repaint)
                    {
                        int    mode           = 0;
                        int    entryCount     = 0;
                        int    searchIndex    = 0;
                        int    searchEndIndex = 0;
                        string text           = LogEntries.wrapped.GetEntryLinesAndFlagAndCount(el.row, ref mode, ref entryCount,
                                                                                                ref searchIndex, ref searchEndIndex);
                        ConsoleFlags flag       = (ConsoleFlags)mode;
                        bool         isSelected = LogEntries.wrapped.IsEntrySelected(el.row);

                        // Draw the background
                        GUIStyle s = el.row % 2 == 0 ? Constants.OddBackground : Constants.EvenBackground;
                        s.Draw(el.position, false, false, isSelected, false);

                        // Draw the icon
#if !UNITY_2017_3_OR_NEWER
                        if (Constants.LogStyleLineCount == 1)
                        {
                            Rect rt = el.position;
                            rt.x     += 6f;
                            rt.y     += 2f;
                            rt.width  = 16f;
                            rt.height = 16f;
                            GUI.DrawTexture(rt, GetIconForErrorMode(flag, false));
                        }
                        else
#endif
                        {
                            GUIStyle iconStyle = GetStyleForErrorMode(flag, true, Constants.LogStyleLineCount == 1);
                            iconStyle.Draw(el.position, false, false, isSelected, false);
                        }

                        // Draw the text
                        tempContent.text = text;
                        GUIStyle errorModeStyle = GetStyleForErrorMode(flag, false, Constants.LogStyleLineCount == 1);

                        if (string.IsNullOrEmpty(LogEntries.wrapped.searchString) || searchIndex == -1 || searchIndex >= text.Length)
                        {
                            errorModeStyle.Draw(el.position, tempContent, id, isSelected);
                        }
                        else
                        {
                            errorModeStyle.DrawWithTextSelection(el.position, tempContent, GUIUtility.keyboardControl, searchIndex, searchEndIndex);
                        }

                        if (collapsed)
                        {
                            Rect badgeRect = el.position;
                            tempContent.text = entryCount.ToString(CultureInfo.InvariantCulture);
                            Vector2 badgeSize = Constants.CountBadge.CalcSize(tempContent);
                            badgeRect.xMin  = badgeRect.xMax - badgeSize.x;
                            badgeRect.yMin += ((badgeRect.yMax - badgeRect.yMin) - badgeSize.y) * 0.5f;
                            badgeRect.x    -= 5f;
                            GUI.Label(badgeRect, tempContent, Constants.CountBadge);
                        }
                    }
                }

                if (selectedRow != -1)
                {
                    if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight)
                    {
                        m_ListView.scrollPos.y = m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight - 1;
                    }
                }

                // Make sure the selected entry is up to date
                if (m_ListView.totalRows == 0 || m_ListView.row >= m_ListView.totalRows || m_ListView.row < 0)
                {
                }
                else
                {
                    if (m_ListView.selectionChanged)
                    {
                        SetActiveEntry(m_ListView.row);
                    }
                }

                // Open entry using return key
                if ((GUIUtility.keyboardControl == m_ListView.ID) && (e.type == EventType.KeyDown) && (e.keyCode == KeyCode.Return) && (m_ListView.row != 0))
                {
                    selectedRow      = m_ListView.row;
                    openSelectedItem = true;
                }

                if (e.type != EventType.Layout && ListViewGUI.ilvState.rectHeight != 1)
                {
                    ms_LVHeight = ListViewGUI.ilvState.rectHeight;
                }

                if (openSelectedItem)
                {
                    rowDoubleClicked = selectedRow;
                    e.Use();
                }

                if (selectedRow != -1)
                {
                    SetActiveEntry(selectedRow);
                }
            }

            // Prevent dead locking in EditorMonoConsole by delaying callbacks (which can log to the console) until after LogEntries.EndGettingEntries() has been
            // called (this releases the mutex in EditorMonoConsole so logging again is allowed). Fix for case 1081060.
            if (rowDoubleClicked != -1)
            {
                LogEntries.wrapped.StacktraceListView_RowGotDoubleClicked();
            }

            EditorGUIUtility.SetIconSize(Vector2.zero);

            StacktraceListView(e, tempContent);

            SplitterGUILayout.EndVerticalSplit();

            // Copy & Paste selected item
            if ((e.type == EventType.ValidateCommand || e.type == EventType.ExecuteCommand) && e.commandName == "Copy")
            {
                if (e.type == EventType.ExecuteCommand)
                {
                    LogEntries.wrapped.StacktraceListView_CopyAll();
                }
                e.Use();
            }
        }
Пример #30
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();
        }