protected virtual bool RenderModes() { bool dataChanged = false; //Lighting Mode { EditorGUI.BeginChangeCheck(); eLightMode lightMode = GetMaterialLightMode((Material)_materialEditor.target); EditorGUI.showMixedValue = false; foreach (Material material in _materialEditor.targets) { if (lightMode != GetMaterialLightMode(material)) { EditorGUI.showMixedValue = true; break; } } lightMode = (eLightMode)EditorGUILayout.Popup(_lightingModeText, (int)lightMode, _lightingModeOptions); if (EditorGUI.EndChangeCheck()) { foreach (Material material in _materialEditor.targets) { switch (lightMode) { case eLightMode.VertexLit: if (material.shader.name != kShaderVertexLit) { _materialEditor.SetShader(Shader.Find(kShaderVertexLit), false); } break; case eLightMode.PixelLit: if (material.shader.name != kShaderPixelLit) { _materialEditor.SetShader(Shader.Find(kShaderPixelLit), false); } break; case eLightMode.Unlit: if (material.shader.name != kShaderUnlit) { _materialEditor.SetShader(Shader.Find(kShaderUnlit), false); } break; } } dataChanged = true; } } //Blend Mode { eBlendMode blendMode = GetMaterialBlendMode((Material)_materialEditor.target); EditorGUI.showMixedValue = false; foreach (Material material in _materialEditor.targets) { if (blendMode != GetMaterialBlendMode(material)) { EditorGUI.showMixedValue = true; break; } } EditorGUI.BeginChangeCheck(); blendMode = (eBlendMode)EditorGUILayout.Popup(_blendModeText, (int)blendMode, _blendModeOptions); if (EditorGUI.EndChangeCheck()) { foreach (Material mat in _materialEditor.targets) { SetBlendMode(mat, blendMode); } dataChanged = true; } } // GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); // m_MaterialEditor.RenderQueueField(); // m_MaterialEditor.EnableInstancingField(); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = _renderQueue.hasMixedValue; int renderQueue = EditorGUILayout.IntSlider(_rendererQueueText, (int)_renderQueue.floatValue, 0, 49); if (EditorGUI.EndChangeCheck()) { SetInt("_RenderQueue", renderQueue); dataChanged = true; } EditorGUI.BeginChangeCheck(); eCulling culling = (eCulling)Mathf.RoundToInt(_culling.floatValue); EditorGUI.showMixedValue = _culling.hasMixedValue; culling = (eCulling)EditorGUILayout.Popup(_cullingModeText, (int)culling, _cullingModeOptions); if (EditorGUI.EndChangeCheck()) { SetInt("_Cull", (int)culling); dataChanged = true; } EditorGUI.showMixedValue = false; EditorGUI.BeginChangeCheck(); _materialEditor.ShaderProperty(_pixelSnap, _pixelSnapText); if (EditorGUI.EndChangeCheck()) { dataChanged = true; } return(dataChanged); }
protected virtual bool RenderModes() { bool dataChanged = false; //Lighting Mode dataChanged |= RenderLightingModes(); //Blend Mode { eBlendMode blendMode = GetMaterialBlendMode((Material)_materialEditor.target); EditorGUI.showMixedValue = false; foreach (Material material in _materialEditor.targets) { if (blendMode != GetMaterialBlendMode(material)) { EditorGUI.showMixedValue = true; break; } } EditorGUI.BeginChangeCheck(); blendMode = (eBlendMode)EditorGUILayout.Popup(_blendModeText, (int)blendMode, _blendModeOptions); if (EditorGUI.EndChangeCheck()) { foreach (Material mat in _materialEditor.targets) { SetBlendMode(mat, blendMode); } dataChanged = true; } } // GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel); // m_MaterialEditor.RenderQueueField(); // m_MaterialEditor.EnableInstancingField(); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = _renderQueue.hasMixedValue; _renderQueueAbsolute = EditorGUILayout.Toggle(_rendererQueueAbsoluteText, _renderQueueAbsolute); if (!_renderQueueAbsolute && _renderQueueWasAbsolute) { _renderQueueWasAbsolute = _renderQueueAbsolute; int val = ((Material)_materialEditor.targets[0]).renderQueue; val = Mathf.Clamp((int)_renderQueue.floatValue - val, 0, 49); _renderQueue.floatValue = val; } else if (_renderQueueAbsolute && !_renderQueueWasAbsolute) { _renderQueueWasAbsolute = _renderQueueAbsolute; _renderQueue.floatValue = ((Material)_materialEditor.targets[0]).renderQueue; } int renderQueue = _renderQueueAbsolute ? EditorGUILayout.IntSlider(_rendererQueueText, (int)_renderQueue.floatValue, -1, 5000) : EditorGUILayout.IntSlider(_rendererQueueText, (int)_renderQueue.floatValue, 0, 49); if (EditorGUI.EndChangeCheck()) { SetInt("_RenderQueue", renderQueue); dataChanged = true; } EditorGUI.BeginChangeCheck(); eCulling culling = (eCulling)Mathf.RoundToInt(_culling.floatValue); EditorGUI.showMixedValue = _culling.hasMixedValue; culling = (eCulling)EditorGUILayout.Popup(_cullingModeText, (int)culling, _cullingModeOptions); if (EditorGUI.EndChangeCheck()) { SetInt("_Cull", (int)culling); dataChanged = true; } EditorGUI.showMixedValue = false; EditorGUI.BeginChangeCheck(); _materialEditor.ShaderProperty(_pixelSnap, _pixelSnapText); if (EditorGUI.EndChangeCheck()) { dataChanged = true; } return(dataChanged); }
protected virtual void ShaderPropertiesGUI(Material material) { using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); var showAdvancedLabel = new GUIContent("Show Advanced", "Show extra options under all sections. This only affects the inspector. The Material's resulting shader is still compiled/optimized based on what features you actually use and don't use."); float lw = GUI.skin.toggle.CalcSize(showAdvancedLabel).x; EditorGUIUtility.labelWidth = lw; showAdvanced = EditorGUILayout.Toggle(showAdvancedLabel, showAdvanced); EditorGUIUtility.labelWidth = 0f; } EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); { LightingModePopup(); BlendModePopup(); if (showAdvanced) { EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); int renderQueue = EditorGUILayout.IntSlider("Renderer Queue Offset", (int)_renderQueue.floatValue, 0, 49); if (EditorGUI.EndChangeCheck()) { material.SetInt("_RenderQueue", renderQueue); } EditorGUI.BeginChangeCheck(); eCulling culling = (eCulling)Mathf.RoundToInt(_culling.floatValue); culling = (eCulling)EditorGUILayout.EnumPopup("Culling", culling); if (EditorGUI.EndChangeCheck()) { material.SetInt("_Cull", (int)culling); } EditorGUI.BeginChangeCheck(); bool fog = EditorGUILayout.Toggle("Use fog", material.IsKeywordEnabled("_FOG")); if (EditorGUI.EndChangeCheck()) { SetKeyword(material, "_FOG", fog); } } using (new SpineInspectorUtility.BoxScope()) RenderTextureProperties("Main Maps", material); if (showAdvanced) { using (new SpineInspectorUtility.BoxScope()) { Heading("Depth and Cast Shadow"); EditorGUI.BeginChangeCheck(); bool writeTodepth = EditorGUILayout.Toggle(new GUIContent("Write to Depth", "Write to Depth Buffer by clipping alpha."), _writeToDepth.floatValue != 0.0f); if (EditorGUI.EndChangeCheck()) { material.SetInt("_ZWrite", writeTodepth ? 1 : 0); } if (writeTodepth) { _materialEditor.RangeProperty(_depthAlphaCutoff, "Depth Alpha Cutoff"); } EditorGUILayout.Space(); _materialEditor.RangeProperty(_shadowAlphaCutoff, "Shadow Alpha Cutoff"); } if (_fixedNormal != null) { using (new SpineInspectorUtility.BoxScope()) { Heading("Normals"); bool meshNormals = UseMeshNormalsCheckbox(material); if (!meshNormals) { Vector3 normal; EditorGUI.BeginChangeCheck(); normal = showAdvanced ? EditorGUILayout.Vector3Field(new GUIContent("Fixed Normal", "Defined in Camera Space. Should normally be (0,0,-1)."), _fixedNormal.vectorValue) : (Vector3)_fixedNormal.vectorValue; if (EditorGUI.EndChangeCheck()) { _fixedNormal.vectorValue = new Vector4(normal.x, normal.y, normal.z, 1.0f); } bool backRendering; EditorGUI.BeginChangeCheck(); if (showAdvanced) { backRendering = EditorGUILayout.Toggle(new GUIContent("Fixed Normal Back Rendering", "Tick only if you are going to rotate the sprite to face away from the camera, the fixed normal will be flipped to compensate."), material.IsKeywordEnabled("_FIXED_NORMALS_BACK_RENDERING")); } else { backRendering = material.IsKeywordEnabled("_FIXED_NORMALS_BACK_RENDERING"); } if (EditorGUI.EndChangeCheck()) { SetKeyword(material, "_FIXED_NORMALS_BACK_RENDERING", backRendering); SetKeyword(material, "_FIXED_NORMALS", !backRendering); } } } } } else { using (new SpineInspectorUtility.BoxScope()) { EditorGUI.BeginChangeCheck(); bool writeTodepth = EditorGUILayout.Toggle(new GUIContent("Write to Depth", "Write to Depth Buffer by clipping alpha."), _writeToDepth.floatValue != 0.0f); if (EditorGUI.EndChangeCheck()) { material.SetInt("_ZWrite", writeTodepth ? 1 : 0); } if (_fixedNormal != null) { UseMeshNormalsCheckbox(material); } } } using (new SpineInspectorUtility.BoxScope()) RenderColorProperties("Color Adjustment", material); if (_emissionMap != null && _emissionColor != null && _rimColor != null) { Heading("Extra Lighting"); if (_emissionMap != null && _emissionColor != null) { using (new SpineInspectorUtility.BoxScope()) RenderEmissionProperties(material); } if (_rimColor != null) { using (new SpineInspectorUtility.BoxScope()) RenderRimLightingProperties(material); } } } if (EditorGUI.EndChangeCheck()) { foreach (var obj in _blendMode.targets) { MaterialChanged((Material)obj); } } }