コード例 #1
0
        static bool AnyTargetMaterialHasChildren(string[] targetPaths)
        {
            GUID[] guids = targetPaths.Select(path => AssetDatabase.GUIDFromAssetPath(path)).ToArray();

            Func <string, bool> HasChildrenInPath = (string rootPath) => {
                var property = new HierarchyProperty(rootPath, false);
                property.SetSearchFilter(new SearchFilter {
                    classNames = new string[] { "Material" }, searchArea = SearchFilter.SearchArea.AllAssets
                });
                while (property.Next(null))
                {
                    GUID parent;
                    var  child = InternalEditorUtility.GetLoadedObjectFromInstanceID(property.GetInstanceIDIfImported()) as Material;
                    if (child)
                    {
                        if (AssetDatabase.IsForeignAsset(child))
                        {
                            continue;
                        }
                        parent = AssetDatabase.GUIDFromAssetPath(AssetDatabase.GetAssetPath(child.parent));
                    }
                    else
                    {
                        var path = AssetDatabase.GUIDToAssetPath(property.guid);
                        if (!path.EndsWith(".mat", StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }
                        parent = EditorMaterialUtility.GetMaterialParentFromFile(path);
                    }

                    for (int i = 0; i < guids.Length; i++)
                    {
                        if (guids[i] == parent)
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            };

            if (HasChildrenInPath("Assets"))
            {
                return(true);
            }
            foreach (var package in PackageManagerUtilityInternal.GetAllVisiblePackages(false))
            {
                if (package.source == PackageManager.PackageSource.Local && HasChildrenInPath(package.assetPath))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
            static void ResetMaterialProperties()
            {
                foreach (var property in capturedProperties)
                {
                    // fetch default value from shader
                    var shader = (property.targets[0] as Material).shader;
                    int nameId = shader.FindPropertyIndex(property.name);
                    switch (property.type)
                    {
                    case PropType.Float:
                    case PropType.Range:
                        property.floatValue = shader.GetPropertyDefaultFloatValue(nameId);
                        break;

                    case PropType.Vector:
                        property.vectorValue = shader.GetPropertyDefaultVectorValue(nameId);
                        break;

                    case PropType.Color:
                        property.colorValue = shader.GetPropertyDefaultVectorValue(nameId);
                        break;

                    case PropType.Int:
                        property.intValue = shader.GetPropertyDefaultIntValue(nameId);
                        break;

                    case PropType.Texture:
                        Texture texture  = null;
                        var     importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(shader)) as ShaderImporter;
                        if (importer != null)
                        {
                            texture = importer.GetDefaultTexture(property.name);
                        }
                        if (texture == null)
                        {
                            texture = EditorMaterialUtility.GetShaderDefaultTexture(shader, property.name);
                        }
                        property.textureValue          = texture;
                        property.textureScaleAndOffset = new Vector4(1, 1, 0, 0);
                        break;
                    }
                }
            }
コード例 #3
0
        void Search()
        {
            var newResults = new List <int>();

            var maxAddCount = k_MaxSearchIterationPerFrame;

            while (--maxAddCount >= 0)
            {
                if (!enumerator.MoveNext())
                {
                    enumerator = null;
                    break;
                }
                var child = InternalEditorUtility.GetLoadedObjectFromInstanceID(enumerator.Current.GetInstanceIDIfImported()) as Material;
                if (!child)
                {
                    // First check guid from file to avoid loading material in memory
                    string path = AssetDatabase.GUIDToAssetPath(enumerator.Current.guid);
                    if (EditorMaterialUtility.GetMaterialParentFromFile(path) != targetGUID)
                    {
                        continue;
                    }
                    child = AssetDatabase.LoadAssetAtPath <Material>(path);
                }
                if (child != null && child.parent == target)
                {
                    newResults.Add(child.GetInstanceID());
                }
            }

            int newElements = newResults.Count;
            int i           = results.Length;

            System.Array.Resize(ref results, results.Length + newElements);
            for (var j = 0; j < newElements && i < results.Length; ++j, ++i)
            {
                results[i] = newResults[j];
            }

            listArea.ShowObjectsInList(results);
        }
コード例 #4
0
        static void ReparentMaterialChildren(string assetPath)
        {
            var toDelete     = AssetDatabase.LoadAssetAtPath <Material>(assetPath);
            var toDeleteGUID = AssetDatabase.GUIDFromAssetPath(assetPath);
            var newParent    = toDelete.parent;

            Action <string> ReparentInPath = (string rootPath) => {
                var property = new HierarchyProperty(rootPath, false);
                property.SetSearchFilter(new SearchFilter {
                    classNames = new string[] { "Material" }, searchArea = SearchFilter.SearchArea.AllAssets
                });
                while (property.Next(null))
                {
                    var child = InternalEditorUtility.GetLoadedObjectFromInstanceID(property.GetInstanceIDIfImported()) as Material;
                    if (!child)
                    {
                        // First check guid from file to avoid loading all materials in memory
                        string path = AssetDatabase.GUIDToAssetPath(property.guid);
                        if (EditorMaterialUtility.GetMaterialParentFromFile(path) != toDeleteGUID)
                        {
                            continue;
                        }
                        child = AssetDatabase.LoadAssetAtPath <Material>(path);
                    }
                    if (child != null && child.parent == toDelete && !AssetDatabase.IsForeignAsset(child))
                    {
                        child.parent = newParent;
                    }
                }
            };

            ReparentInPath("Assets");
            foreach (var package in PackageManagerUtilityInternal.GetAllVisiblePackages(false))
            {
                if (package.source == PackageManager.PackageSource.Local)
                {
                    ReparentInPath(package.assetPath);
                }
            }
        }
コード例 #5
0
        public override void OnInspectorGUI()
        {
            this.serializedObject.Update();
            this.m_lightmapSettings.Update();
            EditorGUILayout.Space();
            this.m_ShowEditor = EditorGUILayout.FoldoutTitlebar(this.m_ShowEditor, LightingEditor.Styles.environmentHeader);
            if (!this.m_ShowEditor)
            {
                return;
            }
            ++EditorGUI.indentLevel;
            EditorGUILayout.PropertyField(this.m_SkyboxMaterial, LightingEditor.Styles.skyboxLabel, new GUILayoutOption[0]);
            Material objectReferenceValue = this.m_SkyboxMaterial.objectReferenceValue as Material;

            if ((bool)((UnityEngine.Object)objectReferenceValue) && !EditorMaterialUtility.IsBackgroundMaterial(objectReferenceValue))
            {
                EditorGUILayout.HelpBox(LightingEditor.Styles.skyboxWarning.text, MessageType.Warning);
            }
            EditorGUILayout.PropertyField(this.m_Sun, LightingEditor.Styles.sunLabel, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            EditorGUILayout.IntPopup(this.m_AmbientMode, LightingEditor.kFullAmbientModes, LightingEditor.kFullAmbientModeValues, LightingEditor.Styles.ambientModeLabel, new GUILayoutOption[0]);
            ++EditorGUI.indentLevel;
            switch (this.m_AmbientMode.intValue)
            {
            case 0:
                if ((UnityEngine.Object)objectReferenceValue == (UnityEngine.Object)null)
                {
                    EditorGUILayout.PropertyField(this.m_AmbientSkyColor, LightingEditor.Styles.ambient, new GUILayoutOption[0]);
                    break;
                }
                break;

            case 1:
                EditorGUILayout.PropertyField(this.m_AmbientSkyColor, LightingEditor.Styles.ambientUp, new GUILayoutOption[0]);
                EditorGUILayout.PropertyField(this.m_AmbientEquatorColor, LightingEditor.Styles.ambientMid, new GUILayoutOption[0]);
                EditorGUILayout.PropertyField(this.m_AmbientGroundColor, LightingEditor.Styles.ambientDown, new GUILayoutOption[0]);
                break;

            case 3:
                EditorGUILayout.PropertyField(this.m_AmbientSkyColor, LightingEditor.Styles.ambient, new GUILayoutOption[0]);
                break;
            }
            --EditorGUI.indentLevel;
            EditorGUILayout.Slider(this.m_AmbientIntensity, 0.0f, 8f, LightingEditor.Styles.ambientIntensity, new GUILayoutOption[0]);
            this.m_ShowAmbientBakeMode.target = LightingEditor.ShowAmbientField();
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowAmbientBakeMode.faded))
            {
                bool flag = Lightmapping.realtimeLightmapsEnabled && Lightmapping.bakedLightmapsEnabled;
                EditorGUI.BeginDisabledGroup(!flag);
                if (flag)
                {
                    EditorGUILayout.PropertyField(this.m_EnvironmentLightingMode, LightingEditor.Styles.SkyLightBaked, new GUILayoutOption[0]);
                }
                else
                {
                    int index = !Lightmapping.bakedLightmapsEnabled ? 0 : 1;
                    EditorGUILayout.LabelField(LightingEditor.Styles.SkyLightBaked, GUIContent.Temp(this.m_EnvironmentLightingMode.enumNames[index]), EditorStyles.popup, new GUILayoutOption[0]);
                }
                EditorGUI.EndDisabledGroup();
            }
            EditorGUILayout.EndFadeGroup();
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(this.m_DefaultReflectionMode, LightingEditor.Styles.reflectionModeLabel, new GUILayoutOption[0]);
            ++EditorGUI.indentLevel;
            switch ((DefaultReflectionMode)this.m_DefaultReflectionMode.intValue)
            {
            case DefaultReflectionMode.FromSkybox:
                EditorGUILayout.IntPopup(this.m_DefaultReflectionResolution, LightingEditor.Styles.defaultReflectionSizes, LightingEditor.Styles.defaultReflectionSizesValues, LightingEditor.Styles.defaultReflectionResolution, new GUILayoutOption[1]
                {
                    GUILayout.MinWidth(40f)
                });
                break;

            case DefaultReflectionMode.Custom:
                EditorGUILayout.PropertyField(this.m_CustomReflection, LightingEditor.Styles.customReflection, new GUILayoutOption[0]);
                break;
            }
            EditorGUILayout.PropertyField(this.m_ReflectionCompression, LightingEditor.Styles.ReflectionCompression, new GUILayoutOption[0]);
            --EditorGUI.indentLevel;
            EditorGUILayout.Slider(this.m_ReflectionIntensity, 0.0f, 1f, LightingEditor.Styles.reflectionIntensity, new GUILayoutOption[0]);
            EditorGUILayout.IntSlider(this.m_ReflectionBounces, 1, 5, LightingEditor.Styles.reflectionBounces, new GUILayoutOption[0]);
            --EditorGUI.indentLevel;
            this.serializedObject.ApplyModifiedProperties();
            this.m_lightmapSettings.ApplyModifiedProperties();
        }
コード例 #6
0
        private void DrawGUI()
        {
            Material material = this.m_SkyboxMaterial.objectReferenceValue as Material;

            this.m_bShowEnvironment = EditorGUILayout.FoldoutTitlebar(this.m_bShowEnvironment, LightingEditor.Styles.env_top, true);
            if (this.m_bShowEnvironment)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(this.m_SkyboxMaterial, LightingEditor.Styles.env_skybox_mat, new GUILayoutOption[0]);
                if (material && !EditorMaterialUtility.IsBackgroundMaterial(material))
                {
                    EditorGUILayout.HelpBox(LightingEditor.Styles.skyboxWarning.text, MessageType.Warning);
                }
                EditorGUILayout.PropertyField(this.m_Sun, LightingEditor.Styles.env_skybox_sun, new GUILayoutOption[0]);
                EditorGUILayout.Space();
                EditorGUILayout.LabelField(LightingEditor.Styles.env_amb_top, new GUILayoutOption[0]);
                EditorGUI.indentLevel++;
                EditorGUILayout.IntPopup(this.m_AmbientSource, LightingEditor.Styles.kFullAmbientSource, LightingEditor.Styles.kFullAmbientSourceValues, LightingEditor.Styles.env_amb_src, new GUILayoutOption[0]);
                AmbientMode intValue = (AmbientMode)this.m_AmbientSource.intValue;
                if (intValue != AmbientMode.Trilight)
                {
                    if (intValue != AmbientMode.Flat)
                    {
                        if (intValue == AmbientMode.Skybox)
                        {
                            if (material == null)
                            {
                                EditorGUI.BeginChangeCheck();
                                Color colorValue = EditorGUILayout.ColorField(LightingEditor.Styles.ambient, this.m_AmbientSkyColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]);
                                if (EditorGUI.EndChangeCheck())
                                {
                                    this.m_AmbientSkyColor.colorValue = colorValue;
                                }
                            }
                            else
                            {
                                EditorGUILayout.Slider(this.m_AmbientIntensity, 0f, 8f, LightingEditor.Styles.env_amb_int, new GUILayoutOption[0]);
                            }
                        }
                    }
                    else
                    {
                        EditorGUI.BeginChangeCheck();
                        Color colorValue2 = EditorGUILayout.ColorField(LightingEditor.Styles.ambient, this.m_AmbientSkyColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]);
                        if (EditorGUI.EndChangeCheck())
                        {
                            this.m_AmbientSkyColor.colorValue = colorValue2;
                        }
                    }
                }
                else
                {
                    EditorGUI.BeginChangeCheck();
                    Color colorValue3 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientUp, this.m_AmbientSkyColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]);
                    Color colorValue4 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientMid, this.m_AmbientEquatorColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]);
                    Color colorValue5 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientDown, this.m_AmbientGroundColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]);
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.m_AmbientSkyColor.colorValue     = colorValue3;
                        this.m_AmbientEquatorColor.colorValue = colorValue4;
                        this.m_AmbientGroundColor.colorValue  = colorValue5;
                    }
                }
                if (LightModeUtil.Get().IsAnyGIEnabled())
                {
                    int  selectedValue;
                    bool ambientLightingMode = LightModeUtil.Get().GetAmbientLightingMode(out selectedValue);
                    using (new EditorGUI.DisabledScope(!ambientLightingMode))
                    {
                        int[] optionValues = new int[]
                        {
                            0,
                            1
                        };
                        if (ambientLightingMode)
                        {
                            this.m_AmbientLightingMode.intValue = EditorGUILayout.IntPopup(LightingEditor.Styles.AmbientLightingMode, this.m_AmbientLightingMode.intValue, LightingEditor.Styles.AmbientLightingModes, optionValues, new GUILayoutOption[0]);
                        }
                        else
                        {
                            EditorGUILayout.IntPopup(LightingEditor.Styles.AmbientLightingMode, selectedValue, LightingEditor.Styles.AmbientLightingModes, optionValues, new GUILayoutOption[0]);
                        }
                    }
                }
                EditorGUI.indentLevel--;
                EditorGUILayout.Space();
                EditorGUILayout.LabelField(LightingEditor.Styles.env_refl_top, new GUILayoutOption[0]);
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(this.m_DefaultReflectionMode, LightingEditor.Styles.env_refl_src, new GUILayoutOption[0]);
                DefaultReflectionMode intValue2 = (DefaultReflectionMode)this.m_DefaultReflectionMode.intValue;
                if (intValue2 != DefaultReflectionMode.FromSkybox)
                {
                    if (intValue2 == DefaultReflectionMode.Custom)
                    {
                        EditorGUILayout.PropertyField(this.m_CustomReflection, LightingEditor.Styles.customReflection, new GUILayoutOption[0]);
                    }
                }
                else
                {
                    EditorGUILayout.IntPopup(this.m_DefaultReflectionResolution, LightingEditor.Styles.defaultReflectionSizes, LightingEditor.Styles.defaultReflectionSizesValues, LightingEditor.Styles.env_refl_res, new GUILayoutOption[]
                    {
                        GUILayout.MinWidth(40f)
                    });
                }
                EditorGUILayout.PropertyField(this.m_ReflectionCompression, LightingEditor.Styles.env_refl_cmp, new GUILayoutOption[0]);
                EditorGUILayout.Slider(this.m_ReflectionIntensity, 0f, 1f, LightingEditor.Styles.env_refl_int, new GUILayoutOption[0]);
                EditorGUILayout.IntSlider(this.m_ReflectionBounces, 1, 5, LightingEditor.Styles.env_refl_bnc, new GUILayoutOption[0]);
                EditorGUI.indentLevel--;
                EditorGUI.indentLevel--;
                EditorGUILayout.Space();
            }
        }
コード例 #7
0
        private void DrawGUI()
        {
            Material skyboxMaterial = m_SkyboxMaterial.objectReferenceValue as Material;

            m_bShowEnvironment = EditorGUILayout.FoldoutTitlebar(m_bShowEnvironment, Styles.env_top, true);

            if (m_bShowEnvironment)
            {
                EditorGUI.indentLevel++;

                EditorGUILayout.PropertyField(m_SkyboxMaterial, Styles.env_skybox_mat);
                if (skyboxMaterial && !EditorMaterialUtility.IsBackgroundMaterial(skyboxMaterial))
                {
                    EditorGUILayout.HelpBox(Styles.skyboxWarning.text, MessageType.Warning);
                }

                EditorGUILayout.PropertyField(m_Sun, Styles.env_skybox_sun);
                EditorGUILayout.Space();

                EditorGUILayout.LabelField(Styles.env_amb_top);
                EditorGUI.indentLevel++;

                EditorGUILayout.IntPopup(m_AmbientSource, Styles.kFullAmbientSource, Styles.kFullAmbientSourceValues, Styles.env_amb_src);
                switch ((AmbientMode)m_AmbientSource.intValue)
                {
                case AmbientMode.Trilight:
                {
                    EditorGUI.BeginChangeCheck();
                    Color newValueUp   = EditorGUILayout.ColorField(Styles.ambientUp, m_AmbientSkyColor.colorValue, true, false, true);
                    Color newValueMid  = EditorGUILayout.ColorField(Styles.ambientMid, m_AmbientEquatorColor.colorValue, true, false, true);
                    Color newValueDown = EditorGUILayout.ColorField(Styles.ambientDown, m_AmbientGroundColor.colorValue, true, false, true);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_AmbientSkyColor.colorValue     = newValueUp;
                        m_AmbientEquatorColor.colorValue = newValueMid;
                        m_AmbientGroundColor.colorValue  = newValueDown;
                    }
                }
                break;

                case AmbientMode.Flat:
                {
                    EditorGUI.BeginChangeCheck();
                    Color newValue = EditorGUILayout.ColorField(Styles.ambient, m_AmbientSkyColor.colorValue, true, false, true);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_AmbientSkyColor.colorValue = newValue;
                    }
                }
                break;

                case AmbientMode.Skybox:
                    if (skyboxMaterial == null)
                    {
                        EditorGUI.BeginChangeCheck();
                        Color newValue = EditorGUILayout.ColorField(Styles.ambient, m_AmbientSkyColor.colorValue, true, false, true);
                        if (EditorGUI.EndChangeCheck())
                        {
                            m_AmbientSkyColor.colorValue = newValue;
                        }
                    }
                    else
                    {
                        // Ambient intensity - maximum is kEmissiveRGBMMax
                        EditorGUILayout.Slider(m_AmbientIntensity, 0.0F, 8.0F, Styles.env_amb_int);
                    }
                    break;
                }

                // ambient GI - realtime / baked
                bool realtimeGISupported = SupportedRenderingFeatures.IsLightmapBakeTypeSupported(LightmapBakeType.Realtime);
                bool bakedGISupported    = SupportedRenderingFeatures.IsLightmapBakeTypeSupported(LightmapBakeType.Baked);

                if ((m_EnabledBakedGI.boolValue || m_EnabledRealtimeGI.boolValue) && (bakedGISupported || realtimeGISupported))
                {
                    int[] modeVals = { 0, 1 };

                    if (m_EnabledBakedGI.boolValue && m_EnabledRealtimeGI.boolValue)
                    {
                        // if the user has selected the only state that is supported, then gray it out
                        using (new EditorGUI.DisabledScope(((m_AmbientLightingMode.intValue == 0) && realtimeGISupported && !bakedGISupported) || ((m_AmbientLightingMode.intValue == 1) && bakedGISupported && !realtimeGISupported)))
                        {
                            EditorGUILayout.IntPopup(m_AmbientLightingMode, Styles.AmbientLightingModes, modeVals, Styles.AmbientLightingMode);
                        }

                        // if they have selected a state that isnt supported, show dialog, and still make the box editable
                        if (((m_AmbientLightingMode.intValue == 0) && !realtimeGISupported) ||
                            ((m_AmbientLightingMode.intValue == 1) && !bakedGISupported))
                        {
                            EditorGUILayout.HelpBox("The following mode is not supported and will fallback on " + (((m_AmbientLightingMode.intValue == 0) && !realtimeGISupported) ? "Baked" : "Realtime"), MessageType.Warning);
                        }
                    }
                    // Show "Baked" if precomputed GI is disabled and "Realtime" if baked GI is disabled (but we don't wanna show the box if the whole mode is not supported.)
                    else if ((m_EnabledBakedGI.boolValue && bakedGISupported) || (m_EnabledRealtimeGI.boolValue && realtimeGISupported))
                    {
                        using (new EditorGUI.DisabledScope(true))
                        {
                            EditorGUILayout.IntPopup(Styles.AmbientLightingMode, m_EnabledBakedGI.boolValue ? 1 : 0, Styles.AmbientLightingModes, modeVals);
                        }
                    }
                }

                EditorGUI.indentLevel--;
                EditorGUILayout.Space();

                EditorGUILayout.LabelField(Styles.env_refl_top);
                EditorGUI.indentLevel++;

                EditorGUILayout.PropertyField(m_DefaultReflectionMode, Styles.env_refl_src);

                DefaultReflectionMode defReflectionMode = (DefaultReflectionMode)m_DefaultReflectionMode.intValue;
                switch (defReflectionMode)
                {
                case DefaultReflectionMode.FromSkybox:
                {
                    int[]        reflectionResolutionValuesArray = null;
                    GUIContent[] reflectionResolutionTextArray   = null;
                    ReflectionProbeEditor.GetResolutionArray(ref reflectionResolutionValuesArray, ref reflectionResolutionTextArray);
                    EditorGUILayout.IntPopup(m_DefaultReflectionResolution, reflectionResolutionTextArray, reflectionResolutionValuesArray, Styles.env_refl_res, GUILayout.MinWidth(40));
                }
                break;

                case DefaultReflectionMode.Custom:
                    EditorGUILayout.PropertyField(m_CustomReflection, Styles.customReflection);
                    break;
                }

                EditorGUILayout.PropertyField(m_ReflectionCompression, Styles.env_refl_cmp);
                EditorGUILayout.Slider(m_ReflectionIntensity, 0.0F, 1.0F, Styles.env_refl_int);
                EditorGUILayout.IntSlider(m_ReflectionBounces, 1, 5, Styles.env_refl_bnc);

                EditorGUI.indentLevel--;

                EditorGUI.indentLevel--;
                EditorGUILayout.Space();
            }
        }
コード例 #8
0
 public override void OnInspectorGUI()
 {
     base.serializedObject.Update();
     this.m_lightmapSettings.Update();
     EditorGUILayout.Space();
     this.m_ShowEditor = EditorGUILayout.FoldoutTitlebar(this.m_ShowEditor, LightingEditor.Styles.environmentHeader);
     if (this.m_ShowEditor)
     {
         EditorGUI.indentLevel++;
         EditorGUILayout.PropertyField(this.m_SkyboxMaterial, LightingEditor.Styles.skyboxLabel, new GUILayoutOption[0]);
         Material material = this.m_SkyboxMaterial.objectReferenceValue as Material;
         if (material && !EditorMaterialUtility.IsBackgroundMaterial(material))
         {
             EditorGUILayout.HelpBox(LightingEditor.Styles.skyboxWarning.text, MessageType.Warning);
         }
         EditorGUILayout.PropertyField(this.m_Sun, LightingEditor.Styles.sunLabel, new GUILayoutOption[0]);
         EditorGUILayout.Space();
         EditorGUILayout.IntPopup(this.m_AmbientMode, LightingEditor.Styles.kFullAmbientModes, LightingEditor.Styles.kFullAmbientModeValues, LightingEditor.Styles.ambientModeLabel, new GUILayoutOption[0]);
         EditorGUI.indentLevel++;
         AmbientMode intValue = (AmbientMode)this.m_AmbientMode.intValue;
         if (intValue != AmbientMode.Trilight)
         {
             if (intValue != AmbientMode.Flat)
             {
                 if (intValue == AmbientMode.Skybox)
                 {
                     if (material == null)
                     {
                         EditorGUI.BeginChangeCheck();
                         Color colorValue = EditorGUILayout.ColorField(LightingEditor.Styles.ambient, this.m_AmbientSkyColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]);
                         if (EditorGUI.EndChangeCheck())
                         {
                             this.m_AmbientSkyColor.colorValue = colorValue;
                         }
                     }
                     else
                     {
                         EditorGUILayout.Slider(this.m_AmbientIntensity, 0f, 8f, LightingEditor.Styles.ambientIntensity, new GUILayoutOption[0]);
                     }
                 }
             }
             else
             {
                 EditorGUI.BeginChangeCheck();
                 Color colorValue2 = EditorGUILayout.ColorField(LightingEditor.Styles.ambient, this.m_AmbientSkyColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]);
                 if (EditorGUI.EndChangeCheck())
                 {
                     this.m_AmbientSkyColor.colorValue = colorValue2;
                 }
             }
         }
         else
         {
             EditorGUI.BeginChangeCheck();
             Color colorValue3 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientUp, this.m_AmbientSkyColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]);
             Color colorValue4 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientMid, this.m_AmbientEquatorColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]);
             Color colorValue5 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientDown, this.m_AmbientGroundColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]);
             if (EditorGUI.EndChangeCheck())
             {
                 this.m_AmbientSkyColor.colorValue     = colorValue3;
                 this.m_AmbientEquatorColor.colorValue = colorValue4;
                 this.m_AmbientGroundColor.colorValue  = colorValue5;
             }
         }
         EditorGUI.indentLevel--;
         this.m_ShowAmbientBakeMode.target = LightingEditor.ShowAmbientField();
         if (EditorGUILayout.BeginFadeGroup(this.m_ShowAmbientBakeMode.faded))
         {
             bool flag = Lightmapping.realtimeGI && Lightmapping.bakedGI;
             using (new EditorGUI.DisabledScope(!flag))
             {
                 if (flag)
                 {
                     EditorGUILayout.PropertyField(this.m_EnvironmentLightingMode, LightingEditor.Styles.SkyLightBaked, new GUILayoutOption[0]);
                 }
                 else
                 {
                     int num = (!Lightmapping.bakedGI) ? 0 : 1;
                     EditorGUILayout.LabelField(LightingEditor.Styles.SkyLightBaked, GUIContent.Temp(this.m_EnvironmentLightingMode.enumNames[num]), EditorStyles.popup, new GUILayoutOption[0]);
                 }
             }
         }
         EditorGUILayout.EndFadeGroup();
         EditorGUILayout.Space();
         EditorGUILayout.PropertyField(this.m_DefaultReflectionMode, LightingEditor.Styles.reflectionModeLabel, new GUILayoutOption[0]);
         EditorGUI.indentLevel++;
         Cubemap exists = this.m_CustomReflection.objectReferenceValue as Cubemap;
         DefaultReflectionMode intValue2 = (DefaultReflectionMode)this.m_DefaultReflectionMode.intValue;
         if ((!material && intValue2 == DefaultReflectionMode.FromSkybox) || (!exists && intValue2 == DefaultReflectionMode.Custom))
         {
             EditorGUILayout.HelpBox(LightingEditor.Styles.defReflectionWarning.text, MessageType.Warning);
         }
         if (intValue2 != DefaultReflectionMode.FromSkybox)
         {
             if (intValue2 == DefaultReflectionMode.Custom)
             {
                 EditorGUILayout.PropertyField(this.m_CustomReflection, LightingEditor.Styles.customReflection, new GUILayoutOption[0]);
             }
         }
         else
         {
             EditorGUILayout.IntPopup(this.m_DefaultReflectionResolution, LightingEditor.Styles.defaultReflectionSizes, LightingEditor.Styles.defaultReflectionSizesValues, LightingEditor.Styles.defaultReflectionResolution, new GUILayoutOption[]
             {
                 GUILayout.MinWidth(40f)
             });
         }
         EditorGUILayout.PropertyField(this.m_ReflectionCompression, LightingEditor.Styles.ReflectionCompression, new GUILayoutOption[0]);
         EditorGUI.indentLevel--;
         EditorGUILayout.Slider(this.m_ReflectionIntensity, 0f, 1f, LightingEditor.Styles.reflectionIntensity, new GUILayoutOption[0]);
         EditorGUILayout.IntSlider(this.m_ReflectionBounces, 1, 5, LightingEditor.Styles.reflectionBounces, new GUILayoutOption[0]);
         EditorGUI.indentLevel--;
         base.serializedObject.ApplyModifiedProperties();
         this.m_lightmapSettings.ApplyModifiedProperties();
     }
 }
コード例 #9
0
        private void DrawGUI()
        {
            Material skyboxMaterial = m_SkyboxMaterial.objectReferenceValue as Material;

            m_bShowEnvironment = EditorGUILayout.FoldoutTitlebar(m_bShowEnvironment, Styles.env_top, true);

            if (m_bShowEnvironment)
            {
                EditorGUI.indentLevel++;

                EditorGUILayout.PropertyField(m_SkyboxMaterial, Styles.env_skybox_mat);
                if (skyboxMaterial && !EditorMaterialUtility.IsBackgroundMaterial(skyboxMaterial))
                {
                    EditorGUILayout.HelpBox(Styles.skyboxWarning.text, MessageType.Warning);
                }

                EditorGUILayout.PropertyField(m_Sun, Styles.env_skybox_sun);
                EditorGUILayout.Space();

                EditorGUILayout.PropertyField(m_SubtractiveShadowColor, Styles.SubtractiveColor);
                EditorGUILayout.Space();

                EditorGUILayout.LabelField(Styles.env_amb_top);
                EditorGUI.indentLevel++;

                EditorGUILayout.IntPopup(m_AmbientSource, Styles.kFullAmbientSource, Styles.kFullAmbientSourceValues, Styles.env_amb_src);
                switch ((AmbientMode)m_AmbientSource.intValue)
                {
                case AmbientMode.Trilight:
                {
                    EditorGUI.BeginChangeCheck();
                    Color newValueUp   = EditorGUILayout.ColorField(Styles.ambientUp, m_AmbientSkyColor.colorValue, true, false, true);
                    Color newValueMid  = EditorGUILayout.ColorField(Styles.ambientMid, m_AmbientEquatorColor.colorValue, true, false, true);
                    Color newValueDown = EditorGUILayout.ColorField(Styles.ambientDown, m_AmbientGroundColor.colorValue, true, false, true);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_AmbientSkyColor.colorValue     = newValueUp;
                        m_AmbientEquatorColor.colorValue = newValueMid;
                        m_AmbientGroundColor.colorValue  = newValueDown;
                    }
                }
                break;

                case AmbientMode.Flat:
                {
                    EditorGUI.BeginChangeCheck();
                    Color newValue = EditorGUILayout.ColorField(Styles.ambient, m_AmbientSkyColor.colorValue, true, false, true);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_AmbientSkyColor.colorValue = newValue;
                    }
                }
                break;

                case AmbientMode.Skybox:
                    if (skyboxMaterial == null)
                    {
                        EditorGUI.BeginChangeCheck();
                        Color newValue = EditorGUILayout.ColorField(Styles.ambient, m_AmbientSkyColor.colorValue, true, false, true);
                        if (EditorGUI.EndChangeCheck())
                        {
                            m_AmbientSkyColor.colorValue = newValue;
                        }
                    }
                    else
                    {
                        // Ambient intensity - maximum is kEmissiveRGBMMax
                        EditorGUILayout.Slider(m_AmbientIntensity, 0.0F, 8.0F, Styles.env_amb_int);
                    }
                    break;
                }

                EditorGUI.indentLevel--;
                EditorGUILayout.Space();

                EditorGUILayout.LabelField(Styles.env_refl_top);
                EditorGUI.indentLevel++;

                EditorGUILayout.PropertyField(m_DefaultReflectionMode, Styles.env_refl_src);

                DefaultReflectionMode defReflectionMode = (DefaultReflectionMode)m_DefaultReflectionMode.intValue;
                switch (defReflectionMode)
                {
                case DefaultReflectionMode.FromSkybox:
                {
                    int[]        reflectionResolutionValuesArray = null;
                    GUIContent[] reflectionResolutionTextArray   = null;
                    ReflectionProbeEditor.GetResolutionArray(ref reflectionResolutionValuesArray, ref reflectionResolutionTextArray);
                    EditorGUILayout.IntPopup(m_DefaultReflectionResolution, reflectionResolutionTextArray, reflectionResolutionValuesArray, Styles.env_refl_res, GUILayout.MinWidth(40));
                }
                break;

                case DefaultReflectionMode.Custom:
                    EditorGUILayout.PropertyField(m_CustomReflection, Styles.customReflection);
                    break;
                }

                EditorGUILayout.PropertyField(m_ReflectionCompression, Styles.env_refl_cmp);
                EditorGUILayout.Slider(m_ReflectionIntensity, 0.0F, 1.0F, Styles.env_refl_int);
                EditorGUILayout.IntSlider(m_ReflectionBounces, 1, 5, Styles.env_refl_bnc);

                EditorGUI.indentLevel--;

                EditorGUI.indentLevel--;
                EditorGUILayout.Space();
            }
        }
コード例 #10
0
        public override void OnInspectorGUI()
        {
            base.serializedObject.Update();
            this.m_lightmapSettings.Update();
            EditorGUILayout.Space();
            this.m_ShowEditor = EditorGUILayout.FoldoutTitlebar(this.m_ShowEditor, Styles.environmentHeader);
            if (this.m_ShowEditor)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(this.m_SkyboxMaterial, Styles.skyboxLabel, new GUILayoutOption[0]);
                Material objectReferenceValue = this.m_SkyboxMaterial.objectReferenceValue as Material;
                if ((objectReferenceValue != null) && !EditorMaterialUtility.IsBackgroundMaterial(objectReferenceValue))
                {
                    EditorGUILayout.HelpBox(Styles.skyboxWarning.text, MessageType.Warning);
                }
                EditorGUILayout.PropertyField(this.m_Sun, Styles.sunLabel, new GUILayoutOption[0]);
                EditorGUILayout.Space();
                EditorGUILayout.IntPopup(this.m_AmbientMode, kFullAmbientModes, kFullAmbientModeValues, Styles.ambientModeLabel, new GUILayoutOption[0]);
                EditorGUI.indentLevel++;
                switch (this.m_AmbientMode.intValue)
                {
                    case 0:
                        if (objectReferenceValue == null)
                        {
                            EditorGUILayout.PropertyField(this.m_AmbientSkyColor, Styles.ambient, new GUILayoutOption[0]);
                        }
                        break;

                    case 1:
                        EditorGUILayout.PropertyField(this.m_AmbientSkyColor, Styles.ambientUp, new GUILayoutOption[0]);
                        EditorGUILayout.PropertyField(this.m_AmbientEquatorColor, Styles.ambientMid, new GUILayoutOption[0]);
                        EditorGUILayout.PropertyField(this.m_AmbientGroundColor, Styles.ambientDown, new GUILayoutOption[0]);
                        break;

                    case 3:
                        EditorGUILayout.PropertyField(this.m_AmbientSkyColor, Styles.ambient, new GUILayoutOption[0]);
                        break;
                }
                EditorGUI.indentLevel--;
                EditorGUILayout.Slider(this.m_AmbientIntensity, 0f, 8f, Styles.ambientIntensity, new GUILayoutOption[0]);
                if (Lightmapping.realtimeLightmapsEnabled && Lightmapping.bakedLightmapsEnabled)
                {
                    EditorGUILayout.PropertyField(this.m_EnvironmentLightingMode, Styles.SkyLightBaked, new GUILayoutOption[0]);
                }
                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(this.m_DefaultReflectionMode, Styles.reflectionModeLabel, new GUILayoutOption[0]);
                EditorGUI.indentLevel++;
                switch (((DefaultReflectionMode) this.m_DefaultReflectionMode.intValue))
                {
                    case DefaultReflectionMode.FromSkybox:
                    {
                        GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MinWidth(40f) };
                        EditorGUILayout.IntPopup(this.m_DefaultReflectionResolution, Styles.defaultReflectionSizes, Styles.defaultReflectionSizesValues, Styles.defaultReflectionResolution, options);
                        break;
                    }
                    case DefaultReflectionMode.Custom:
                        EditorGUILayout.PropertyField(this.m_CustomReflection, Styles.customReflection, new GUILayoutOption[0]);
                        break;
                }
                EditorGUILayout.PropertyField(this.m_ReflectionCompression, Styles.ReflectionCompression, new GUILayoutOption[0]);
                EditorGUI.indentLevel--;
                EditorGUILayout.Slider(this.m_ReflectionIntensity, 0f, 1f, Styles.reflectionIntensity, new GUILayoutOption[0]);
                EditorGUILayout.IntSlider(this.m_ReflectionBounces, 1, 5, Styles.reflectionBounces, new GUILayoutOption[0]);
                EditorGUI.indentLevel--;
                base.serializedObject.ApplyModifiedProperties();
                this.m_lightmapSettings.ApplyModifiedProperties();
            }
        }
コード例 #11
0
        private void DrawGUI()
        {
            Material material = this.m_SkyboxMaterial.objectReferenceValue as Material;

            this.m_bShowEnvironment = EditorGUILayout.FoldoutTitlebar(this.m_bShowEnvironment, LightingEditor.Styles.env_top, true);
            if (this.m_bShowEnvironment)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(this.m_SkyboxMaterial, LightingEditor.Styles.env_skybox_mat, new GUILayoutOption[0]);
                if (material && !EditorMaterialUtility.IsBackgroundMaterial(material))
                {
                    EditorGUILayout.HelpBox(LightingEditor.Styles.skyboxWarning.text, MessageType.Warning);
                }
                EditorGUILayout.PropertyField(this.m_Sun, LightingEditor.Styles.env_skybox_sun, new GUILayoutOption[0]);
                EditorGUILayout.Space();
                EditorGUILayout.LabelField(LightingEditor.Styles.env_amb_top, new GUILayoutOption[0]);
                EditorGUI.indentLevel++;
                EditorGUILayout.IntPopup(this.m_AmbientSource, LightingEditor.Styles.kFullAmbientSource, LightingEditor.Styles.kFullAmbientSourceValues, LightingEditor.Styles.env_amb_src, new GUILayoutOption[0]);
                AmbientMode intValue = (AmbientMode)this.m_AmbientSource.intValue;
                if (intValue != AmbientMode.Trilight)
                {
                    if (intValue != AmbientMode.Flat)
                    {
                        if (intValue == AmbientMode.Skybox)
                        {
                            if (material == null)
                            {
                                EditorGUI.BeginChangeCheck();
                                Color colorValue = EditorGUILayout.ColorField(LightingEditor.Styles.ambient, this.m_AmbientSkyColor.colorValue, true, false, true, new GUILayoutOption[0]);
                                if (EditorGUI.EndChangeCheck())
                                {
                                    this.m_AmbientSkyColor.colorValue = colorValue;
                                }
                            }
                            else
                            {
                                EditorGUILayout.Slider(this.m_AmbientIntensity, 0f, 8f, LightingEditor.Styles.env_amb_int, new GUILayoutOption[0]);
                            }
                        }
                    }
                    else
                    {
                        EditorGUI.BeginChangeCheck();
                        Color colorValue2 = EditorGUILayout.ColorField(LightingEditor.Styles.ambient, this.m_AmbientSkyColor.colorValue, true, false, true, new GUILayoutOption[0]);
                        if (EditorGUI.EndChangeCheck())
                        {
                            this.m_AmbientSkyColor.colorValue = colorValue2;
                        }
                    }
                }
                else
                {
                    EditorGUI.BeginChangeCheck();
                    Color colorValue3 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientUp, this.m_AmbientSkyColor.colorValue, true, false, true, new GUILayoutOption[0]);
                    Color colorValue4 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientMid, this.m_AmbientEquatorColor.colorValue, true, false, true, new GUILayoutOption[0]);
                    Color colorValue5 = EditorGUILayout.ColorField(LightingEditor.Styles.ambientDown, this.m_AmbientGroundColor.colorValue, true, false, true, new GUILayoutOption[0]);
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.m_AmbientSkyColor.colorValue     = colorValue3;
                        this.m_AmbientEquatorColor.colorValue = colorValue4;
                        this.m_AmbientGroundColor.colorValue  = colorValue5;
                    }
                }
                bool flag  = SupportedRenderingFeatures.IsLightmapBakeTypeSupported(LightmapBakeType.Realtime);
                bool flag2 = SupportedRenderingFeatures.IsLightmapBakeTypeSupported(LightmapBakeType.Baked);
                if ((this.m_EnabledBakedGI.boolValue || this.m_EnabledRealtimeGI.boolValue) && (flag2 || flag))
                {
                    int[] optionValues = new int[]
                    {
                        0,
                        1
                    };
                    if (this.m_EnabledBakedGI.boolValue && this.m_EnabledRealtimeGI.boolValue)
                    {
                        using (new EditorGUI.DisabledScope((this.m_AmbientLightingMode.intValue == 0 && flag && !flag2) || (this.m_AmbientLightingMode.intValue == 1 && flag2 && !flag)))
                        {
                            EditorGUILayout.IntPopup(this.m_AmbientLightingMode, LightingEditor.Styles.AmbientLightingModes, optionValues, LightingEditor.Styles.AmbientLightingMode, new GUILayoutOption[0]);
                        }
                        if ((this.m_AmbientLightingMode.intValue == 0 && !flag) || (this.m_AmbientLightingMode.intValue == 1 && !flag2))
                        {
                            EditorGUILayout.HelpBox("The following mode is not supported and will fallback on " + ((this.m_AmbientLightingMode.intValue != 0 || flag) ? "Realtime" : "Baked"), MessageType.Warning);
                        }
                    }
                    else if ((this.m_EnabledBakedGI.boolValue && flag2) || (this.m_EnabledRealtimeGI.boolValue && flag))
                    {
                        using (new EditorGUI.DisabledScope(true))
                        {
                            EditorGUILayout.IntPopup(LightingEditor.Styles.AmbientLightingMode, (!this.m_EnabledBakedGI.boolValue) ? 0 : 1, LightingEditor.Styles.AmbientLightingModes, optionValues, new GUILayoutOption[0]);
                        }
                    }
                }
                EditorGUI.indentLevel--;
                EditorGUILayout.Space();
                EditorGUILayout.LabelField(LightingEditor.Styles.env_refl_top, new GUILayoutOption[0]);
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(this.m_DefaultReflectionMode, LightingEditor.Styles.env_refl_src, new GUILayoutOption[0]);
                DefaultReflectionMode intValue2 = (DefaultReflectionMode)this.m_DefaultReflectionMode.intValue;
                if (intValue2 != DefaultReflectionMode.FromSkybox)
                {
                    if (intValue2 == DefaultReflectionMode.Custom)
                    {
                        EditorGUILayout.PropertyField(this.m_CustomReflection, LightingEditor.Styles.customReflection, new GUILayoutOption[0]);
                    }
                }
                else
                {
                    int[]        optionValues2    = null;
                    GUIContent[] displayedOptions = null;
                    ReflectionProbeEditor.GetResolutionArray(ref optionValues2, ref displayedOptions);
                    EditorGUILayout.IntPopup(this.m_DefaultReflectionResolution, displayedOptions, optionValues2, LightingEditor.Styles.env_refl_res, new GUILayoutOption[]
                    {
                        GUILayout.MinWidth(40f)
                    });
                }
                EditorGUILayout.PropertyField(this.m_ReflectionCompression, LightingEditor.Styles.env_refl_cmp, new GUILayoutOption[0]);
                EditorGUILayout.Slider(this.m_ReflectionIntensity, 0f, 1f, LightingEditor.Styles.env_refl_int, new GUILayoutOption[0]);
                EditorGUILayout.IntSlider(this.m_ReflectionBounces, 1, 5, LightingEditor.Styles.env_refl_bnc, new GUILayoutOption[0]);
                EditorGUI.indentLevel--;
                EditorGUI.indentLevel--;
                EditorGUILayout.Space();
            }
        }
コード例 #12
0
        public override void OnInspectorGUI()
        {
            base.serializedObject.Update();
            this.m_lightmapSettings.Update();
            EditorGUILayout.Space();
            this.m_ShowEditor = EditorGUILayout.FoldoutTitlebar(this.m_ShowEditor, Styles.environmentHeader);
            if (this.m_ShowEditor)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(this.m_SkyboxMaterial, Styles.skyboxLabel, new GUILayoutOption[0]);
                Material objectReferenceValue = this.m_SkyboxMaterial.objectReferenceValue as Material;
                if ((objectReferenceValue != null) && !EditorMaterialUtility.IsBackgroundMaterial(objectReferenceValue))
                {
                    EditorGUILayout.HelpBox(Styles.skyboxWarning.text, MessageType.Warning);
                }
                EditorGUILayout.PropertyField(this.m_Sun, Styles.sunLabel, new GUILayoutOption[0]);
                EditorGUILayout.Space();
                EditorGUILayout.IntPopup(this.m_AmbientMode, Styles.kFullAmbientModes, Styles.kFullAmbientModeValues, Styles.ambientModeLabel, new GUILayoutOption[0]);
                EditorGUI.indentLevel++;
                switch (((AmbientMode)this.m_AmbientMode.intValue))
                {
                case AmbientMode.Trilight:
                {
                    EditorGUI.BeginChangeCheck();
                    Color color  = EditorGUILayout.ColorField(Styles.ambientUp, this.m_AmbientSkyColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]);
                    Color color2 = EditorGUILayout.ColorField(Styles.ambientMid, this.m_AmbientEquatorColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]);
                    Color color3 = EditorGUILayout.ColorField(Styles.ambientDown, this.m_AmbientGroundColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]);
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.m_AmbientSkyColor.colorValue     = color;
                        this.m_AmbientEquatorColor.colorValue = color2;
                        this.m_AmbientGroundColor.colorValue  = color3;
                    }
                    break;
                }

                case AmbientMode.Flat:
                {
                    EditorGUI.BeginChangeCheck();
                    Color color4 = EditorGUILayout.ColorField(Styles.ambient, this.m_AmbientSkyColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]);
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.m_AmbientSkyColor.colorValue = color4;
                    }
                    break;
                }

                case AmbientMode.Skybox:
                    if (objectReferenceValue == null)
                    {
                        EditorGUI.BeginChangeCheck();
                        Color color5 = EditorGUILayout.ColorField(Styles.ambient, this.m_AmbientSkyColor.colorValue, true, false, true, ColorPicker.defaultHDRConfig, new GUILayoutOption[0]);
                        if (EditorGUI.EndChangeCheck())
                        {
                            this.m_AmbientSkyColor.colorValue = color5;
                        }
                    }
                    else
                    {
                        EditorGUILayout.Slider(this.m_AmbientIntensity, 0f, 8f, Styles.ambientIntensity, new GUILayoutOption[0]);
                    }
                    break;
                }
                EditorGUI.indentLevel--;
                this.m_ShowAmbientBakeMode.target = ShowAmbientField();
                if (EditorGUILayout.BeginFadeGroup(this.m_ShowAmbientBakeMode.faded))
                {
                    bool flag = Lightmapping.realtimeGI && Lightmapping.bakedGI;
                    using (new EditorGUI.DisabledScope(!flag))
                    {
                        if (flag)
                        {
                            EditorGUILayout.PropertyField(this.m_EnvironmentLightingMode, Styles.SkyLightBaked, new GUILayoutOption[0]);
                        }
                        else
                        {
                            int index = !Lightmapping.bakedGI ? 0 : 1;
                            EditorGUILayout.LabelField(Styles.SkyLightBaked, GUIContent.Temp(this.m_EnvironmentLightingMode.enumNames[index]), EditorStyles.popup, new GUILayoutOption[0]);
                        }
                    }
                }
                EditorGUILayout.EndFadeGroup();
                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(this.m_DefaultReflectionMode, Styles.reflectionModeLabel, new GUILayoutOption[0]);
                EditorGUI.indentLevel++;
                Cubemap cubemap = this.m_CustomReflection.objectReferenceValue as Cubemap;
                UnityEditor.DefaultReflectionMode intValue = (UnityEditor.DefaultReflectionMode) this.m_DefaultReflectionMode.intValue;
                if (((objectReferenceValue == null) && (intValue == UnityEditor.DefaultReflectionMode.FromSkybox)) || ((cubemap == null) && (intValue == UnityEditor.DefaultReflectionMode.Custom)))
                {
                    EditorGUILayout.HelpBox(Styles.defReflectionWarning.text, MessageType.Warning);
                }
                if (intValue == UnityEditor.DefaultReflectionMode.FromSkybox)
                {
                    GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MinWidth(40f) };
                    EditorGUILayout.IntPopup(this.m_DefaultReflectionResolution, Styles.defaultReflectionSizes, Styles.defaultReflectionSizesValues, Styles.defaultReflectionResolution, options);
                }
                else if (intValue == UnityEditor.DefaultReflectionMode.Custom)
                {
                    EditorGUILayout.PropertyField(this.m_CustomReflection, Styles.customReflection, new GUILayoutOption[0]);
                }
                EditorGUILayout.PropertyField(this.m_ReflectionCompression, Styles.ReflectionCompression, new GUILayoutOption[0]);
                EditorGUI.indentLevel--;
                EditorGUILayout.Slider(this.m_ReflectionIntensity, 0f, 1f, Styles.reflectionIntensity, new GUILayoutOption[0]);
                EditorGUILayout.IntSlider(this.m_ReflectionBounces, 1, 5, Styles.reflectionBounces, new GUILayoutOption[0]);
                EditorGUI.indentLevel--;
                base.serializedObject.ApplyModifiedProperties();
                this.m_lightmapSettings.ApplyModifiedProperties();
            }
        }
コード例 #13
0
        public override void OnInspectorGUI()
        {
            base.serializedObject.Update();
            this.m_lightmapSettings.Update();
            EditorGUILayout.Space();
            this.m_ShowEditor = EditorGUILayout.FoldoutTitlebar(this.m_ShowEditor, LightingEditor.Styles.environmentHeader);
            if (!this.m_ShowEditor)
            {
                return;
            }
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(this.m_SkyboxMaterial, LightingEditor.Styles.skyboxLabel, new GUILayoutOption[0]);
            Material material = this.m_SkyboxMaterial.objectReferenceValue as Material;

            if (material && !EditorMaterialUtility.IsBackgroundMaterial(material))
            {
                EditorGUILayout.HelpBox(LightingEditor.Styles.skyboxWarning.text, MessageType.Warning);
            }
            EditorGUILayout.PropertyField(this.m_Sun, LightingEditor.Styles.sunLabel, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            EditorGUILayout.IntPopup(this.m_AmbientMode, LightingEditor.kFullAmbientModes, LightingEditor.kFullAmbientModeValues, LightingEditor.Styles.ambientModeLabel, new GUILayoutOption[0]);
            EditorGUI.indentLevel++;
            switch (this.m_AmbientMode.intValue)
            {
            case 0:
                if (material == null)
                {
                    EditorGUILayout.PropertyField(this.m_AmbientSkyColor, LightingEditor.Styles.ambient, new GUILayoutOption[0]);
                }
                break;

            case 1:
                EditorGUILayout.PropertyField(this.m_AmbientSkyColor, LightingEditor.Styles.ambientUp, new GUILayoutOption[0]);
                EditorGUILayout.PropertyField(this.m_AmbientEquatorColor, LightingEditor.Styles.ambientMid, new GUILayoutOption[0]);
                EditorGUILayout.PropertyField(this.m_AmbientGroundColor, LightingEditor.Styles.ambientDown, new GUILayoutOption[0]);
                break;

            case 3:
                EditorGUILayout.PropertyField(this.m_AmbientSkyColor, LightingEditor.Styles.ambient, new GUILayoutOption[0]);
                break;
            }
            EditorGUI.indentLevel--;
            EditorGUILayout.Slider(this.m_AmbientIntensity, 0f, 1f, LightingEditor.Styles.ambientIntensity, new GUILayoutOption[0]);
            bool flag = Lightmapping.realtimeLightmapsEnabled && Lightmapping.bakedLightmapsEnabled;

            EditorGUI.BeginDisabledGroup(!flag);
            EditorGUILayout.PropertyField(this.m_EnvironmentLightingMode, LightingEditor.Styles.SkyLightBaked, new GUILayoutOption[0]);
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(this.m_DefaultReflectionMode, LightingEditor.Styles.reflectionModeLabel, new GUILayoutOption[0]);
            EditorGUI.indentLevel++;
            DefaultReflectionMode intValue = (DefaultReflectionMode)this.m_DefaultReflectionMode.intValue;

            if (intValue != DefaultReflectionMode.FromSkybox)
            {
                if (intValue == DefaultReflectionMode.Custom)
                {
                    EditorGUILayout.PropertyField(this.m_CustomReflection, LightingEditor.Styles.customReflection, new GUILayoutOption[0]);
                }
            }
            else
            {
                EditorGUILayout.IntPopup(this.m_DefaultReflectionResolution, LightingEditor.Styles.defaultReflectionSizes, LightingEditor.Styles.defaultReflectionSizesValues, LightingEditor.Styles.defaultReflectionResolution, new GUILayoutOption[]
                {
                    GUILayout.MinWidth(40f)
                });
            }
            EditorGUI.indentLevel--;
            EditorGUILayout.Slider(this.m_ReflectionIntensity, 0f, 1f, LightingEditor.Styles.reflectionIntensity, new GUILayoutOption[0]);
            EditorGUILayout.IntSlider(this.m_ReflectionBounces, 1, 5, LightingEditor.Styles.reflectionBounces, new GUILayoutOption[0]);
            EditorGUI.indentLevel--;
            base.serializedObject.ApplyModifiedProperties();
            this.m_lightmapSettings.ApplyModifiedProperties();
        }