bool ShaderPropertiesGUI(MaterialEditor materialEditor)
        {
            EditorGUI.BeginChangeCheck();

            materialEditor.ShaderProperty(_colorMode, "Color Mode");

            if (_colorMode.floatValue > 0)
            {
                var rect = EditorGUILayout.GetControlRect();
                rect.x += EditorGUIUtility.labelWidth;
                rect.width = (rect.width - EditorGUIUtility.labelWidth) / 2 - 2;
                materialEditor.ShaderProperty(rect, _color, "");
                rect.x += rect.width + 4;
                materialEditor.ShaderProperty(rect, _color2, "");
            }
            else
            {
                materialEditor.ShaderProperty(_color, " ");
            }

            EditorGUILayout.Space();

            materialEditor.ShaderProperty(_metallic, "Metallic");
            materialEditor.ShaderProperty(_smoothness, "Smoothness");

            EditorGUILayout.Space();

            materialEditor.TexturePropertySingleLine(_albedoText, _albedoMap, null);
            materialEditor.TexturePropertySingleLine(_normalMapText, _normalMap, _normalMap.textureValue ? _normalScale : null);
            materialEditor.TexturePropertySingleLine(_occlusionText, _occlusionMap, _occlusionMap.textureValue ? _occlusionStr : null);
            materialEditor.TextureScaleOffsetProperty(_albedoMap);

            return EditorGUI.EndChangeCheck();
        }
 public void OnGUI(ref Rect position, MaterialProperty prop, string label, MaterialEditor editor)
 {
   float height = position.height;
   position.height = 0.0f;
   if (this.m_DecoratorDrawers != null)
   {
     using (List<MaterialPropertyDrawer>.Enumerator enumerator = this.m_DecoratorDrawers.GetEnumerator())
     {
       while (enumerator.MoveNext())
       {
         MaterialPropertyDrawer current = enumerator.Current;
         position.height = current.GetPropertyHeight(prop, label, editor);
         float labelWidth = EditorGUIUtility.labelWidth;
         float fieldWidth = EditorGUIUtility.fieldWidth;
         current.OnGUI(position, prop, label, editor);
         EditorGUIUtility.labelWidth = labelWidth;
         EditorGUIUtility.fieldWidth = fieldWidth;
         position.y += position.height;
         height -= position.height;
       }
     }
   }
   position.height = height;
   if (this.m_PropertyDrawer == null)
     return;
   float labelWidth1 = EditorGUIUtility.labelWidth;
   float fieldWidth1 = EditorGUIUtility.fieldWidth;
   this.m_PropertyDrawer.OnGUI(position, prop, label, editor);
   EditorGUIUtility.labelWidth = labelWidth1;
   EditorGUIUtility.fieldWidth = fieldWidth1;
 }
        bool ShaderPropertiesGUI(MaterialEditor materialEditor)
        {
            EditorGUI.BeginChangeCheck();

            materialEditor.ShaderProperty(_blendMode, "Blend Mode");
            materialEditor.ShaderProperty(_colorMode, "Color Mode");

            if (_colorMode.floatValue > 0)
            {
                var rect = EditorGUILayout.GetControlRect();
                rect.x += EditorGUIUtility.labelWidth;
                rect.width = (rect.width - EditorGUIUtility.labelWidth) / 2 - 2;
                materialEditor.ShaderProperty(rect, _color, "");
                rect.x += rect.width + 4;
                materialEditor.ShaderProperty(rect, _color2, "");
            }
            else
            {
                materialEditor.ShaderProperty(_color, " ");
            }

            materialEditor.ShaderProperty(_mainTex, "Texture");

            return EditorGUI.EndChangeCheck();
        }
        bool ShaderPropertiesGUI(MaterialEditor materialEditor)
        {
            EditorGUI.BeginChangeCheck();

            // albedo
            materialEditor.TexturePropertySingleLine(_albedoText, _mainTex, _color);

            // metallic / smoothness
            if (_metallicGlossMap.textureValue == null)
                materialEditor.TexturePropertyTwoLines(_metallicText, _metallicGlossMap, _metallic, _smoothnessText, _glossiness);
            else
                materialEditor.TexturePropertySingleLine(_metallicText, _metallicGlossMap);

            // normal map
            materialEditor.TexturePropertySingleLine(_normalMapText, _bumpMap, _bumpMap.textureValue != null ? _bumpScale : null);

            // occlusion
            materialEditor.TexturePropertySingleLine(_occlusionText, _occlusionMap, _occlusionMap.textureValue != null ? _occlusionStrength : null);

            // emission
            bool hadEmissionTexture = _emissionMap.textureValue != null;
            materialEditor.TexturePropertyWithHDRColor(_emissionText, _emissionMap, _emissionColor, _colorPickerHDRConfig, false);

            // if texture was assigned and color was black set color to white
            if (_emissionMap.textureValue != null && !hadEmissionTexture)
                if (_emissionColor.colorValue.maxColorComponent <= 0)
                    _emissionColor.colorValue = Color.white;

            return EditorGUI.EndChangeCheck();
        }
 public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
 {
   base.OnGUI(materialEditor, props);
   materialEditor.LightmapEmissionProperty(0);
   foreach (Material target in materialEditor.targets)
     target.globalIlluminationFlags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
 }
Exemplo n.º 6
0
		override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
			if (!checkVisible (editor)) return;

			Color col = GUI.contentColor;
			Color bcol = GUI.backgroundColor;
			GUI.contentColor = new Color(1f, 1f, 0.8f, 1f);
			GUI.backgroundColor = backgroundColor;
			//position.y -= 15;
			Rect pos=new Rect(position);
			pos.y += 3;
			pos.height -= 3;
			//if (visibilityProp1==null || visibilityProp1=="indent") {
	//			pos.height -= 10;
	//			pos.y += 10;
			//}

			if (visibilityProp1!=null) {
				pos.x+=12;
				pos.width-=12;
			}
	//		pos.height = 17;
			EditorGUI.HelpBox(pos, (foldoutFlag ? "     ":"")+label, MessageType.None);

			if (foldoutFlag) {
				Rect fpos = new Rect(pos);
				fpos.x += 15;
				fpos.y += 1;
				bool state = EditorGUI.Foldout(fpos, prop.floatValue==1, "", true);
				prop.floatValue = state ? 1 : 0;
			}

			GUI.contentColor = col;
			GUI.backgroundColor = bcol;
		}
		public void OnGUI(ref Rect position, MaterialProperty prop, string label, MaterialEditor editor)
		{
			float num = position.height;
			position.height = 0f;
			if (this.m_DecoratorDrawers != null)
			{
				foreach (MaterialPropertyDrawer current in this.m_DecoratorDrawers)
				{
					position.height = current.GetPropertyHeight(prop, label, editor);
					float labelWidth = EditorGUIUtility.labelWidth;
					float fieldWidth = EditorGUIUtility.fieldWidth;
					current.OnGUI(position, prop, label, editor);
					EditorGUIUtility.labelWidth = labelWidth;
					EditorGUIUtility.fieldWidth = fieldWidth;
					position.y += position.height;
					num -= position.height;
				}
			}
			position.height = num;
			if (this.m_PropertyDrawer != null)
			{
				float labelWidth = EditorGUIUtility.labelWidth;
				float fieldWidth = EditorGUIUtility.fieldWidth;
				this.m_PropertyDrawer.OnGUI(position, prop, label, editor);
				EditorGUIUtility.labelWidth = labelWidth;
				EditorGUIUtility.fieldWidth = fieldWidth;
			}
		}
 public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
 {
     if (!IsPropertyTypeSuitable(prop))
     {
         return 40f;
     }
     return base.GetPropertyHeight(prop, label, editor);
 }
Exemplo n.º 9
0
        public override void OnGUI(MaterialEditor _materialEditor, MaterialProperty[] _properties)
        {
            FindProperties(this, _properties);

            DoGeneral(_materialEditor);
            DoNormalMap(_materialEditor);
            DoRim(_materialEditor);
        }
 void Vector3Property(MaterialEditor materialEditor, MaterialProperty prop, string label)
 {
     EditorGUI.BeginChangeCheck();
     EditorGUI.showMixedValue = prop.hasMixedValue;
     var newValue = EditorGUILayout.Vector3Field(label, prop.vectorValue);
     EditorGUI.showMixedValue = false;
     if (EditorGUI.EndChangeCheck()) prop.vectorValue = newValue;
 }
Exemplo n.º 11
0
 public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
 {
     FindProperties(properties);
     if (ShaderPropertiesGUI(materialEditor) || _initial)
         foreach (Material m in materialEditor.targets)
             UpdateMaterial(m);
     _initial = false;
 }
		public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
		{
			if (prop.type != MaterialProperty.PropType.Range)
			{
				return 40f;
			}
			return base.GetPropertyHeight(prop, label, editor);
		}
Exemplo n.º 13
0
		bool checkVisible(MaterialEditor editor) {
			if (visibilityProp != "") {
				Material mat=editor.target as Material;
				if (mat.HasProperty(visibilityProp)) {
					return mat.GetFloat(visibilityProp)==1 ? true:false;
				}
			}
			return true;
		}
Exemplo n.º 14
0
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            m_MaterialEditor = materialEditor;

            Material material = materialEditor.target as Material;

            FindProperties (material, props);
            ShaderPropertiesGUI (material);
        }
Exemplo n.º 15
0
		override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor) {
			bool inactiveFlag=false;
			if (!checkSpecUsage(editor.target as Material, label)) return -2;
			if (!checkEmissiveUsage(editor.target as Material, label)) return -2;
			if (checkVisible(editor, ref inactiveFlag)) {
				return MaterialEditor.GetDefaultPropertyHeight(prop);
			}
			return -2;
		}
 bool ShaderPropertiesGUI(MaterialEditor materialEditor)
 {
     EditorGUI.BeginChangeCheck();
     materialEditor.TexturePropertySingleLine(_textCubemap, _cubemap, _tint);
     Vector3Property(materialEditor, _euler, "Rotation");
     materialEditor.ShaderProperty(_exposure, "Exposure");
     materialEditor.ShaderProperty(_saturation, "Saturation");
     return EditorGUI.EndChangeCheck();
 }
		public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
		{
			if (prop.type != MaterialProperty.PropType.Range)
			{
				GUIContent label2 = EditorGUIUtility.TempContent("PowerSlider used on a non-range property: " + prop.name, EditorGUIUtility.GetHelpIcon(MessageType.Warning));
				EditorGUI.LabelField(position, label2, EditorStyles.helpBox);
				return;
			}
			MaterialEditor.DoPowerRangeProperty(position, prop, label, this.power);
		}
Exemplo n.º 18
0
		bool checkVisible(MaterialEditor editor) {
			bool visible = true;
			if (visibilityProp != "") {
				Material mat=editor.target as Material;
				if (mat.HasProperty(visibilityProp)) {
					return (mat.GetFloat(visibilityProp)==1);
				}
			}
			return visible;
		}
		public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
		{
			base.OnGUI(materialEditor, props);
			materialEditor.LightmapEmissionProperty(0);
			UnityEngine.Object[] targets = materialEditor.targets;
			for (int i = 0; i < targets.Length; i++)
			{
				Material material = (Material)targets[i];
				material.globalIlluminationFlags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
			}
		}
Exemplo n.º 20
0
		override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
			bool inactiveFlag = false;
			if (!checkSpecUsage(editor.target as Material, label)) return;
			if (!checkEmissiveUsage(editor.target as Material, label)) return;
			if (checkVisible (editor, ref inactiveFlag)) {
				EditorGUI.BeginDisabledGroup(inactiveFlag);
				
				prop.floatValue = EditorGUI.Toggle(position, label, prop.floatValue==1) ? 1:0;
				
				EditorGUI.EndDisabledGroup();
			}
		}
 public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
 {
     if (prop.type != MaterialProperty.PropType.Range)
     {
         GUIContent content = EditorGUIUtility.TempContent("IntRange used on a non-range property: " + prop.name, EditorGUIUtility.GetHelpIcon(MessageType.Warning));
         EditorGUI.LabelField(position, content, EditorStyles.helpBox);
     }
     else
     {
         MaterialEditor.DoIntRangeProperty(position, prop, label);
     }
 }
Exemplo n.º 22
0
        private void DoDiffuseLUT(MaterialEditor _materialEditor)
        {
            if (!BeginGroup("Diffuse LUT"))
                return;

            if (DoKeyword(_materialEditor, m_DiffuseLUTOn, "Use Diffuse LUT"))
            {
                _materialEditor.TextureProperty(m_DiffuseLUTTex, "Diffuse LUT (Grayscale)");
            }

            EndGroup();
        }
 public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
 {
   this.FindProperties(props);
   this.m_MaterialEditor = materialEditor;
   Material target = materialEditor.target as Material;
   if (this.m_FirstTimeApply)
   {
     StandardShaderGUI.SetMaterialKeywords(target, this.m_WorkflowMode);
     this.m_FirstTimeApply = false;
   }
   this.ShaderPropertiesGUI(target);
 }
Exemplo n.º 24
0
        private void DoNormalMap(MaterialEditor _materialEditor)
        {
            if (!BeginGroup("Normal Map"))
                return;

            if (DoKeyword(_materialEditor, m_NormalMapOn, "Use Normal Map"))
            {
                _materialEditor.TextureProperty(m_NormalMapTex, "Normal Map");
            }

            EndGroup();
        }
Exemplo n.º 25
0
		override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
			bool inactiveFlag = false;
			if (!checkNormalmapsUsage(editor.target as Material, label)) return;
			if (!checkIBLUsage(editor.target as Material, label)) return;

			if (checkVisible (editor, ref inactiveFlag)) {
				EditorGUI.BeginDisabledGroup(inactiveFlag);
				position.x+=12;
				position.width-=12;
				EditorGUI.HelpBox(position, label, MessageType.Warning);
				EditorGUI.EndDisabledGroup();
			}
		}
Exemplo n.º 26
0
		override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor) {
			if (!checkVisible(editor)) return -2;

	//		if (foldoutFlag) {
	//			if (prop.floatValue==1) {
	//				return 17;
	//			} else {
	//				return 17;
	//			}
	//		} else {
				return 20;
	//		}
		}
Exemplo n.º 27
0
		override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
			bool inactiveFlag = false;
			if (!checkNormalmapsUsage(editor.target as Material, label)) return;
			if (!checkDetailUsage(editor.target as Material, label)) return;
			if (!checkSpecUsage(editor.target as Material, label)) return;
			#if UNITY_5
				if (prop.name=="unity_SpecCube" || prop.name=="unity_SpecCube1") return;
			#endif

			if (checkVisible (editor, label, ref inactiveFlag)) {
				EditorGUI.BeginDisabledGroup(inactiveFlag);
				switch (prop.type) {
					case MaterialProperty.PropType.Range: // float ranges
					{
						editor.RangeProperty(position, prop, label);
						break;
					}
					case MaterialProperty.PropType.Float: // floats
					{
						editor.FloatProperty(position, prop, label);
						break;
					}
					case MaterialProperty.PropType.Color: // colors
					{
						editor.ColorProperty(position, prop, label);
						break;
					}
					case MaterialProperty.PropType.Texture: // textures
					{
						editor.TextureProperty(position, prop, label, texTileOffset);
						break;
					}
					case MaterialProperty.PropType.Vector: // vectors
					{
						position.x+=12;
						position.width-=12;
						editor.VectorProperty(position, prop, label);
						break;
					}
					default:
					{
						GUILayout.Label("Unknown prop type... ("+label+")");
						break;
					}
				}
				EditorGUI.EndDisabledGroup();
			}
		}
Exemplo n.º 28
0
 public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
 {
     float num = 0f;
     if (this.m_DecoratorDrawers != null)
     {
         foreach (MaterialPropertyDrawer drawer in this.m_DecoratorDrawers)
         {
             num += drawer.GetPropertyHeight(prop, label, editor);
         }
     }
     if (this.m_PropertyDrawer != null)
     {
         num += this.m_PropertyDrawer.GetPropertyHeight(prop, label, editor);
     }
     return num;
 }
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            FindProperties (props); // MaterialProperties can be animated so we do not cache them but fetch them every event to ensure animated values are updated correctly
            m_MaterialEditor = materialEditor;
            Material material = materialEditor.target as Material;

            ShaderPropertiesGUI (material);

            // Make sure that needed keywords are set up if we're switching some existing
            // material to a standard shader.
            if (m_FirstTimeApply)
            {
                SetMaterialKeywords (material);
                m_FirstTimeApply = false;
            }
        }
Exemplo n.º 30
0
 override public void OnGUI(Rect position, MaterialProperty prop, string label,
                            UnityEditor.MaterialEditor editor)
 {
     EditorGUI.BeginChangeCheck();
     prop.textureValue = editor.TextureProperty(prop, label);
     if (EditorGUI.EndChangeCheck())
     {
         if (prop.textureValue == null)
         {
             (editor.target as Material).DisableKeyword(keywordName + "_ON");
         }
         else
         {
             (editor.target as Material).EnableKeyword(keywordName + "_ON");
         }
     }
 }
 public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
 {
   float num = 0.0f;
   if (this.m_DecoratorDrawers != null)
   {
     using (List<MaterialPropertyDrawer>.Enumerator enumerator = this.m_DecoratorDrawers.GetEnumerator())
     {
       while (enumerator.MoveNext())
       {
         MaterialPropertyDrawer current = enumerator.Current;
         num += current.GetPropertyHeight(prop, label, editor);
       }
     }
   }
   if (this.m_PropertyDrawer != null)
     num += this.m_PropertyDrawer.GetPropertyHeight(prop, label, editor);
   return num;
 }
Exemplo n.º 32
0
        public override void OnGUI(UnityEditor.MaterialEditor materialEditor, UnityEditor.MaterialProperty[] properties)
        {
            ////	base.OnGUI(materialEditor, properties);

            //Material targetMat = materialEditor.target as Material;

            //// see if redify is set, and show a checkbox
            //bool redify = Array.IndexOf(targetMat.shaderKeywords, "EMOJI_ANIMATION") != -1;
            //EditorGUI.BeginChangeCheck();
            //redify = EditorGUILayout.Toggle("Emoji Animation", redify);
            //if (EditorGUI.EndChangeCheck())
            //{
            //	// enable or disable the keyword based on checkbox
            //	if (redify)
            //		targetMat.EnableKeyword("EMOJI_ANIMATION");
            //	else
            //		targetMat.DisableKeyword("EMOJI_ANIMATION");
            //}
        }
Exemplo n.º 33
0
        override public void OnGUI(
            UnityEditor.MaterialEditor materialEditor,
            MaterialProperty[] properties)
        {
            if (!cachedEditor_)
            {
                var       material        = materialEditor.target as Material;
                var       shader          = material.shader;
                var       generators      = Utils.FindAllAssets <Generator>();
                Generator targetGenerator = null;
                foreach (var generator in generators)
                {
                    if (generator.shaderReference == shader)
                    {
                        targetGenerator = generator;
                        break;
                    }
                }
                if (targetGenerator)
                {
                    cachedEditor_ = Editor.CreateEditor(targetGenerator);
                }
            }

            if (cachedEditor_)
            {
                cachedEditor_.OnInspectorGUI();
                EditorGUILayout.Space();
            }

            folded_ = Utils.Foldout("Material Properties", folded_);
            if (folded_)
            {
                ++EditorGUI.indentLevel;
                base.OnGUI(materialEditor, properties);
                --EditorGUI.indentLevel;
            }
        }
Exemplo n.º 34
0
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            if (prop.type != MaterialProperty.PropType.Range)
            {
                GUIContent c = EditorGUIUtility.TempContent("IntRange used on a non-range property: " + prop.name,
                                                            EditorGUIUtility.GetHelpIcon(MessageType.Warning));
                EditorGUI.LabelField(position, c, EditorStyles.helpBox);
                return;
            }

            MaterialEditor.DoIntRangeProperty(position, prop, label);
        }
Exemplo n.º 35
0
 public virtual float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
 {
     return(EditorGUI.kSingleLineHeight);
 }
Exemplo n.º 36
0
 public virtual void OnMaterialPreviewSettingsGUI(MaterialEditor materialEditor)
 {
     materialEditor.DefaultPreviewSettingsGUI();
 }
Exemplo n.º 37
0
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            if (!IsPropertyTypeSuitable(prop))
            {
                GUIContent c = EditorGUIUtility.TempContent("KeywordEnum used on a non-float property: " + prop.name,
                                                            EditorGUIUtility.GetHelpIcon(MessageType.Warning));
                EditorGUI.LabelField(position, c, EditorStyles.helpBox);
                return;
            }

            EditorGUI.BeginChangeCheck();

            EditorGUI.showMixedValue = prop.hasMixedValue;
            var value = (int)prop.floatValue;

            value = EditorGUI.Popup(position, label, value, keywords);
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                prop.floatValue = value;
                SetKeyword(prop, value);
            }
        }
Exemplo n.º 38
0
        public static void DoPopup(GUIContent label, MaterialProperty property, string[] options, MaterialEditor materialEditor)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            EditorGUI.showMixedValue = property.hasMixedValue;

            var mode = property.floatValue;

            EditorGUI.BeginChangeCheck();
            mode = EditorGUILayout.Popup(label, (int)mode, options);
            if (EditorGUI.EndChangeCheck())
            {
                materialEditor.RegisterPropertyChangeUndo(label.text);
                property.floatValue = mode;
            }

            EditorGUI.showMixedValue = false;
        }
 public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
 {
     if (!MaterialToggleLeftDrawer.IsPropertyTypeSuitable(prop))
     {
         EditorGUI.HelpBox(position, "Toggle used on a non-float property: " + prop.name, MessageType.Error);
     }
     else
     {
         EditorGUI.BeginChangeCheck();
         bool flag = Math.Abs(prop.floatValue) > 0.001f;
         EditorGUI.showMixedValue = prop.hasMixedValue;
         flag = EditorGUI.ToggleLeft(position, label, flag);
         EditorGUI.showMixedValue = false;
         if (EditorGUI.EndChangeCheck())
         {
             prop.floatValue = ((!flag) ? 0f : 1f);
             this.SetKeyword(prop, flag);
         }
     }
 }
Exemplo n.º 40
0
 public virtual void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
 {
     OnGUI(position, prop, label.text, editor);
 }
 private float ShowProp(MaterialEditor materialEditor, MaterialProperty prop)
 {
     materialEditor.ShaderProperty(prop, prop.displayName);
     return(prop.floatValue);
 }
Exemplo n.º 42
0
 public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
 {
     position.y += 8f;
     position    = EditorGUI.IndentedRect(position);
     GUI.Label(position, this.header, EditorStyles.boldLabel);
 }
Exemplo n.º 43
0
        public void OnGUI(ref Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            float oldLabelWidth, oldFieldWidth;
            var   propHeight = position.height;

            position.height = 0;
            if (m_DecoratorDrawers != null)
            {
                foreach (var decorator in m_DecoratorDrawers)
                {
                    position.height = decorator.GetPropertyHeight(prop, label.text, editor);

                    oldLabelWidth = EditorGUIUtility.labelWidth;
                    oldFieldWidth = EditorGUIUtility.fieldWidth;
                    decorator.OnGUI(position, prop, label, editor);
                    EditorGUIUtility.labelWidth = oldLabelWidth;
                    EditorGUIUtility.fieldWidth = oldFieldWidth;

                    position.y += position.height;
                    propHeight -= position.height;
                }
            }

            position.height = propHeight;
            if (m_PropertyDrawer != null)
            {
                oldLabelWidth = EditorGUIUtility.labelWidth;
                oldFieldWidth = EditorGUIUtility.fieldWidth;
                m_PropertyDrawer.OnGUI(position, prop, label, editor);
                EditorGUIUtility.labelWidth = oldLabelWidth;
                EditorGUIUtility.fieldWidth = oldFieldWidth;
            }
        }
Exemplo n.º 44
0
        public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
        {
            if (prop.type != MaterialProperty.PropType.Float && prop.type != MaterialProperty.PropType.Range)
            {
                GUIContent label2 = EditorGUIUtility.TempContent("Enum used on a non-float property: " + prop.name, EditorGUIUtility.GetHelpIcon(MessageType.Warning));
                EditorGUI.LabelField(position, label2, EditorStyles.helpBox);
                return;
            }
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = prop.hasMixedValue;
            int num = (int)prop.floatValue;

            num = EditorGUI.IntPopup(position, label, num, this.names, this.values);
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                prop.floatValue = (float)num;
            }
        }
Exemplo n.º 45
0
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            if (prop.type == MaterialProperty.PropType.Vector)
            {
                position = EditorGUI.IndentedRect(position);
                var v = prop.vectorValue;
                position.height = height;
                GUI.Label(position, label);

                EditorGUI.BeginChangeCheck();
                EditorGUI.indentLevel += 1;
                for (int i = 0; i < this.labels.Length; i++)
                {
                    position.y += height;
                    v[i]        = EditorGUI.FloatField(position, this.labels[i], v[i]);
                }
                EditorGUI.indentLevel -= 1;
                if (EditorGUI.EndChangeCheck())
                {
                    prop.vectorValue = v;
                }
            }
            else
            {
                editor.DefaultShaderProperty(prop, label.text);
            }
        }
Exemplo n.º 46
0
        ////////////////////////////////////
        // Helper Functions               //
        ////////////////////////////////////
        #region HelperFunctions

        public static void TwoFloatSingleLine(GUIContent title, MaterialProperty prop1, GUIContent prop1Label,
                                              MaterialProperty prop2, GUIContent prop2Label, MaterialEditor materialEditor, float labelWidth = 30f)
        {
            const int kInterFieldPadding = 2;

            MaterialEditor.BeginProperty(prop1);
            MaterialEditor.BeginProperty(prop2);

            Rect rect = EditorGUILayout.GetControlRect();

            EditorGUI.PrefixLabel(rect, title);

            var indent        = EditorGUI.indentLevel;
            var preLabelWidth = EditorGUIUtility.labelWidth;

            EditorGUI.indentLevel       = 0;
            EditorGUIUtility.labelWidth = labelWidth;

            Rect propRect1 = new Rect(rect.x + preLabelWidth, rect.y,
                                      (rect.width - preLabelWidth) * 0.5f - 1, EditorGUIUtility.singleLineHeight);

            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = prop1.hasMixedValue;
            var prop1val = EditorGUI.FloatField(propRect1, prop1Label, prop1.floatValue);

            if (EditorGUI.EndChangeCheck())
            {
                prop1.floatValue = prop1val;
            }

            Rect propRect2 = new Rect(propRect1.x + propRect1.width + kInterFieldPadding, rect.y,
                                      propRect1.width, EditorGUIUtility.singleLineHeight);

            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = prop2.hasMixedValue;
            var prop2val = EditorGUI.FloatField(propRect2, prop2Label, prop2.floatValue);

            if (EditorGUI.EndChangeCheck())
            {
                prop2.floatValue = prop2val;
            }

            EditorGUI.indentLevel       = indent;
            EditorGUIUtility.labelWidth = preLabelWidth;

            EditorGUI.showMixedValue = false;

            MaterialEditor.EndProperty();
            MaterialEditor.EndProperty();
        }
Exemplo n.º 47
0
 public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
 {
 }
Exemplo n.º 48
0
 protected static void DrawTileOffset(MaterialEditor materialEditor, MaterialProperty textureProp)
 {
     materialEditor.TextureScaleOffsetProperty(textureProp);
 }
Exemplo n.º 49
0
 public virtual void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
 {
     EditorGUI.LabelField(position, new GUIContent(label), EditorGUIUtility.TempContent("No GUI Implemented"));
 }
Exemplo n.º 50
0
 public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor) =>
 24f;
Exemplo n.º 51
0
 public override float GetPropertyHeight(MaterialProperty prop, string label,
                                         UnityEditor.MaterialEditor editor)
 {
     return(0);
 }
Exemplo n.º 52
0
 public virtual void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
 {
     materialEditor.PropertiesDefaultGUI(properties);
 }
Exemplo n.º 53
0
 public virtual void OnMaterialInteractivePreviewGUI(MaterialEditor materialEditor, Rect r, GUIStyle background)
 {
     materialEditor.DefaultPreviewGUI(r, background);
 }
Exemplo n.º 54
0
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            if (prop.type != MaterialProperty.PropType.Float && prop.type != MaterialProperty.PropType.Range)
            {
                GUIContent c = EditorGUIUtility.TempContent("Enum used on a non-float property: " + prop.name,
                                                            EditorGUIUtility.GetHelpIcon(MessageType.Warning));
                EditorGUI.LabelField(position, c, EditorStyles.helpBox);
                return;
            }

            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = prop.hasMixedValue;

            var value         = prop.floatValue;
            int selectedIndex = -1;

            for (var index = 0; index < values.Length; index++)
            {
                var i = values[index];
                if (i == value)
                {
                    selectedIndex = index;
                    break;
                }
            }

            var selIndex = EditorGUI.Popup(position, label, selectedIndex, names);

            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                prop.floatValue = values[selIndex];
            }
        }
Exemplo n.º 55
0
 public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
 {
     return(this.height);
 }
Exemplo n.º 56
0
        ////////////////////////////////////
        // Helper Functions               //
        ////////////////////////////////////
        #region HelperFunctions

        public static void TwoFloatSingleLine(GUIContent title, MaterialProperty prop1, GUIContent prop1Label,
                                              MaterialProperty prop2, GUIContent prop2Label, MaterialEditor materialEditor, float labelWidth = 30f)
        {
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = prop1.hasMixedValue || prop2.hasMixedValue;
            Rect rect = EditorGUILayout.GetControlRect();

            EditorGUI.PrefixLabel(rect, title);
            var indent        = EditorGUI.indentLevel;
            var preLabelWidth = EditorGUIUtility.labelWidth;

            EditorGUI.indentLevel       = 0;
            EditorGUIUtility.labelWidth = labelWidth;
            Rect propRect1 = new Rect(rect.x + preLabelWidth, rect.y,
                                      (rect.width - preLabelWidth) * 0.5f, EditorGUIUtility.singleLineHeight);
            var prop1val = EditorGUI.FloatField(propRect1, prop1Label, prop1.floatValue);

            Rect propRect2 = new Rect(propRect1.x + propRect1.width, rect.y,
                                      propRect1.width, EditorGUIUtility.singleLineHeight);
            var prop2val = EditorGUI.FloatField(propRect2, prop2Label, prop2.floatValue);

            EditorGUI.indentLevel       = indent;
            EditorGUIUtility.labelWidth = preLabelWidth;

            if (EditorGUI.EndChangeCheck())
            {
                materialEditor.RegisterPropertyChangeUndo(title.text);
                prop1.floatValue = prop1val;
                prop2.floatValue = prop2val;
            }

            EditorGUI.showMixedValue = false;
        }