Ejemplo n.º 1
0
	// draws a standard material property, optionally disabled, and either compact or full-sized. 
	// minimal flag on texture properties means hide UV tiling.
	private void DrawProperty(MaterialProperty prop, string label, string subLabel, bool disabled) {
		EditorGUI.BeginDisabledGroup(disabled);
		if( prop.type == MaterialProperty.PropType.Color ) {
			EditorGUIUtility.labelWidth = 134;
			EditorGUIUtility.fieldWidth = 84;
		}
		else if( prop.type == MaterialProperty.PropType.Texture ) {
			EditorGUIUtility.labelWidth = 220;
			EditorGUIUtility.fieldWidth = 84;
		}
		else {
			EditorGUIUtility.labelWidth = 134;
			EditorGUIUtility.fieldWidth = 84;
		}

		if( prop.type == MaterialProperty.PropType.Color ) {
			ShaderProperty(prop, label);
		}
		else if( prop.type == MaterialProperty.PropType.Texture ) {
			TextureProperty(prop, label);
			/*if( subLabel.Length > 0 ) {
				Rect r = GUILayoutUtility.GetLastRect();
				r.x = EditorGUIUtility.labelWidth - 21f;
				EditorGUI.BeginDisabledGroup(true);
				EditorGUI.LabelField(r, subLabel);
				EditorGUI.EndDisabledGroup();
			}*/
			GUILayout.Space(6);
		} else {
			ShaderProperty(prop, label);
		}
		EditorGUI.EndDisabledGroup();
	}
Ejemplo n.º 2
0
 public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
 {
     height    = position.height;
     this.prop = prop;
     props     = Func.GetProperties(editor);
     if (group != "" && group != "_")
     {
         EditorGUI.indentLevel++;
         if (needShow)
         {
             if (matchPropType)
             {
                 DrawProp(position, prop, label, editor);
             }
             else
             {
                 Debug.LogWarning($"{this.GetType()} does not support this MaterialProperty type:'{prop.type}'!");
                 editor.DefaultShaderProperty(prop, label.text);
             }
         }
         EditorGUI.indentLevel--;
     }
     else
     {
         if (matchPropType)
         {
             DrawProp(position, prop, label, editor);
         }
         else
         {
             Debug.LogWarning($"{this.GetType()} does not support this MaterialProperty type:'{prop.type}'!");
             editor.DefaultShaderProperty(prop, label.text);
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Constructs a new Material.
        /// </summary>
        /// <param name="material">Unmanaged AiMaterial struct.</param>
        internal Material(AiMaterial material)
        {
            _properties = new Dictionary<String, MaterialProperty>();
            _textures = new Dictionary<int, List<TextureSlot>>();

            if(material.NumProperties > 0 && material.Properties != IntPtr.Zero) {
                AiMaterialProperty[] properties = MemoryHelper.MarshalArray<AiMaterialProperty>(material.Properties, (int) material.NumProperties, true);
                for(int i = 0; i < properties.Length; i++) {
                    MaterialProperty prop = new MaterialProperty(properties[i]);
                    _properties.Add(prop.FullyQualifiedName, prop);
                }
            }
            //Idea is to look at each texture type, and get the "TextureSlot" struct of each one. They're essentially stored in a dictionary where each type contains a bucket
            //of textures. It seems just looping over properties will yield duplicates (no idea what the non $tex.file properties are, but they all seem to contain the same texture info).
            //So hopefully doing it this way will give a nice and concise list of textures that can easily be retrieved, and all pertinent info (file path, wrap mode, etc) will be available to
            //the user.
            foreach(var texType in Enum.GetValues(typeof(TextureType))) {
                TextureType type = (TextureType) texType;
                if(type != TextureType.None) {
                    uint count = AssimpMethods.GetMaterialTextureCount(ref material, type);
                    for(uint i = 0; i < count; i++) {
                        List<TextureSlot> slots;
                        if(!_textures.TryGetValue((int) type, out slots)) {
                            slots = new List<TextureSlot>();
                            _textures.Add((int) type, slots);
                        }
                        slots.Add(AssimpMethods.GetMaterialTexture(ref material, type, i));
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            EditorGUI.showMixedValue = prop.hasMixedValue;
            EditorGUI.BeginChangeCheck();
            var    value = EditorGUILayout.Toggle(label, prop.floatValue > 0.0f);
            string k     = Func.GetKeyWord(keyWord, prop.name);

            if (EditorGUI.EndChangeCheck())
            {
                prop.floatValue = value ? 1.0f : 0.0f;
                Func.SetShaderKeyWord(editor.targets, k, value);
            }
            else
            {
                if (!prop.hasMixedValue)
                {
                    Func.SetShaderKeyWord(editor.targets, k, value);
                }
            }
            if (GUIData.keyWord.ContainsKey(k))
            {
                GUIData.keyWord[k] = value;
            }
            else
            {
                GUIData.keyWord.Add(k, value);
            }
            EditorGUI.showMixedValue = false;
        }
    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
        //Debug.Log("OnGUI: " + label + " RTP_MaterialProp");

        if (!parsed)
        {
            parsed = true;
            parsedLabel = RTP_MatPropStringParser.Parse(label);
        }
        label = parsedLabel;

        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;

            if (customEditor.showFlag) {

                EditorGUI.BeginDisabledGroup(customEditor.inactiveFlag);
                                
                EditorGUIUtility.labelWidth = 300;
                EditorGUI.BeginChangeCheck();
                    float pval = prop.floatValue;
                    float nval = EditorGUI.Popup(position, label, (int)pval, props);
                if (EditorGUI.EndChangeCheck())
                {
                    prop.floatValue = nval;
                }

			    EditorGUI.EndDisabledGroup();
		    }
        }

    }
Ejemplo n.º 6
0
        protected override void FindMaterialProperties(MaterialProperty[] props)
        {
            FindMaterialLayerProperties(props);
            FindMaterialEmissiveProperties(props);

            // The next properties are only supported for regular Lit shader (not layered ones) because it's complicated to blend those parameters if they are different on a per layer basis.

            // Specular Color
            specularColor    = FindProperty(kSpecularColor, props);
            specularColorMap = FindProperty(kSpecularColorMap, props);

            // Anisotropy
            tangentMap    = FindProperty(kTangentMap, props);
            tangentMapOS  = FindProperty(kTangentMapOS, props);
            anisotropy    = FindProperty(kAnisotropy, props);
            anisotropyMap = FindProperty(kAnisotropyMap, props);

            // clear coat
            coatCoverage = FindProperty(kCoatCoverage, props);
            coatIOR      = FindProperty(kCoatIOR, props);

            // Transparency
            refractionMode        = FindProperty(kRefractionMode, props, false);
            transmittanceColor    = FindProperty(kTransmittanceColor, props, false);
            transmittanceColorMap = FindProperty(kTransmittanceColorMap, props, false);
            atDistance            = FindProperty(kATDistance, props, false);
            thicknessMultiplier   = FindProperty(kThicknessMultiplier, props, false);
            ior = FindProperty(kIOR, props, false);
            // We reuse thickness from SSS
        }
Ejemplo n.º 7
0
 bool IsMaterialValid(MaterialProperty property, float radius)
 {
     float minRadius =  Mathf.Round(property.MinRadius * _maxRadius);
     float maxRadius =  Mathf.Round(property.MaxRadius * _maxRadius);
     radius = Mathf.Round(radius);
     return radius >= minRadius && radius <= maxRadius;
 }
Ejemplo n.º 8
0
        void DoEmissiveTextureProperty(MaterialProperty color)
        {
            materialEditor.TexturePropertySingleLine(Styles.emissiveText, emissiveColorMap, color);

            // TODO: does not support multi-selection
            if (materials[0].GetTexture(kEmissiveColorMap))
            {
                EditorGUI.indentLevel++;
                if (UVEmissive != null) // Unlit does not have UVEmissive
                {
                    materialEditor.ShaderProperty(UVEmissive, Styles.UVEmissiveMappingText);
                    UVBaseMapping uvEmissiveMapping = (UVBaseMapping)UVEmissive.floatValue;

                    float X, Y, Z, W;
                    X = (uvEmissiveMapping == UVBaseMapping.UV0) ? 1.0f : 0.0f;
                    Y = (uvEmissiveMapping == UVBaseMapping.UV1) ? 1.0f : 0.0f;
                    Z = (uvEmissiveMapping == UVBaseMapping.UV2) ? 1.0f : 0.0f;
                    W = (uvEmissiveMapping == UVBaseMapping.UV3) ? 1.0f : 0.0f;

                    UVMappingMaskEmissive.colorValue = new Color(X, Y, Z, W);

                    if ((uvEmissiveMapping == UVBaseMapping.Planar) || (uvEmissiveMapping == UVBaseMapping.Triplanar))
                    {
                        materialEditor.ShaderProperty(TexWorldScaleEmissive, Styles.texWorldScaleText);
                    }
                }

                materialEditor.TextureScaleOffsetProperty(emissiveColorMap);
                EditorGUI.indentLevel--;
            }
        }
Ejemplo n.º 9
0
    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

        // Use default labelWidth
        EditorGUIUtility.labelWidth = 0f;

        // Detect any changes to the material
        EditorGUI.BeginChangeCheck();
        {
            GUILayout.Label (Styles.material0Header, EditorStyles.boldLabel);

            // Texture
            materialEditor.TexturePropertySingleLine (Styles.albedo, albedoMap);
            materialEditor.TexturePropertySingleLine (Styles.specular, specularMap);
            materialEditor.TexturePropertySingleLine (Styles.normal, bumpMap);
            materialEditor.TextureScaleOffsetProperty (albedoMap);

            GUILayout.Label (Styles.maskHeader, EditorStyles.boldLabel);

            materialEditor.TexturePropertySingleLine (Styles.blendMask, blendMask);
            materialEditor.TextureScaleOffsetProperty (blendMask);

            GUILayout.Label (Styles.material1Header, EditorStyles.boldLabel);

            materialEditor.TexturePropertySingleLine (Styles.albedo, albedoMap2);
            materialEditor.TexturePropertySingleLine (Styles.specular, specularMap2);
            materialEditor.TexturePropertySingleLine (Styles.normal, bumpMap2);
            materialEditor.TextureScaleOffsetProperty (albedoMap2);
        }
    }
    private static AlloyFieldParser GetFieldParser(MaterialProperty prop) {

        switch (prop.type) {
            case MaterialProperty.PropType.Texture:
                if (prop.textureDimension == MaterialProperty.TexDim.Cube) {
                    return new AlloyCubeParser(prop);
                }

                return new AlloyTextureParser(prop);

            case MaterialProperty.PropType.Range:
            case MaterialProperty.PropType.Float:
                return new AlloyFloatParser(prop);

            case MaterialProperty.PropType.Color:
                return new AlloyColorParser(prop);

            case MaterialProperty.PropType.Vector:
                return new AlloyVectorParser(prop);

            default:
                Debug.LogError("No appopriate parser found to generate a drawer");
                return null;
        }
    }
    override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("GetHeight: " + label + " RTP_EndAreaDecorator");
        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;
            if (customEditor.helperFlag)
            {
                customEditor.helperFlag = false;
                return 0;
            }
            customEditor.helperFlag = true;
            if (customEditor.showFlag)
            {
                EditorGUILayout.EndVertical();
                if (indent)
                {
                    // EditorGUI.indentLevel--;

                    EditorGUILayout.EndHorizontal();
                }
            }
        }
        return 0;
    }
Ejemplo n.º 12
0
 public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
 {
     if (GUILayout.Button("Edit"))
     {
         EditorWindow.GetWindow<MaterialNodeEditor>();
     }
 }
Ejemplo n.º 13
0
        private void DrawSurfaceProperties()
        {
            BeginPropertiesSubGroup();

            MaterialProperty isFakePerspectiveKeywordStateProperty = FindProperty("_Water2D_IsFakePerspectiveEnabled", _materialProperties);
            MaterialProperty surfaceLevelProperty  = FindProperty("_SurfaceLevel", _materialProperties);
            MaterialProperty submergeLevelProperty = FindProperty("_SubmergeLevel", _materialProperties);
            float            surfaceThickness      = 1f - surfaceLevelProperty.floatValue;
            float            currentSubmergeLevel  = Mathf.InverseLerp(surfaceLevelProperty.floatValue, 1f, submergeLevelProperty.floatValue);

            // Thickness Property
            EditorGUIUtility.labelWidth = 62f;
            EditorGUI.showMixedValue    = surfaceLevelProperty.hasMixedValue;
            EditorGUI.BeginChangeCheck();
            surfaceThickness = EditorGUILayout.Slider("Thickness", surfaceThickness, 0f, 1f);
            if (EditorGUI.EndChangeCheck())
            {
                surfaceLevelProperty.floatValue  = 1f - surfaceThickness;
                submergeLevelProperty.floatValue = Mathf.Lerp(surfaceLevelProperty.floatValue, 1f, currentSubmergeLevel);
            }
            EditorGUI.showMixedValue = false;

            // Submerge Level Property
            bool isRefractionEnabled = FindProperty("_Water2D_IsRefractionEnabled", _materialProperties).floatValue == 1f;

            EditorGUI.BeginDisabledGroup(!isRefractionEnabled);
            var   rect = EditorGUILayout.GetControlRect();
            float xmax = rect.xMax;

            rect.width = 14f;
            DrawShaderKeywordPropertyToggle(rect, isFakePerspectiveKeywordStateProperty, string.Empty, true, true);
            rect.xMax  = xmax;
            rect.xMin += 14f;
            EditorGUI.showMixedValue    = submergeLevelProperty.hasMixedValue;
            EditorGUIUtility.labelWidth = 106f;
            EditorGUI.BeginChangeCheck();
            currentSubmergeLevel = EditorGUI.Slider(rect, "Submerge Level", currentSubmergeLevel, 0f, 1f);
            if (EditorGUI.EndChangeCheck())
            {
                submergeLevelProperty.floatValue = Mathf.Lerp(surfaceLevelProperty.floatValue, 1f, currentSubmergeLevel);
            }
            EditorGUI.showMixedValue = false;
            EditorGUI.EndDisabledGroup();

            if (isRefractionEnabled && isFakePerspectiveKeywordStateProperty.floatValue == 1f)
            {
                EditorGUILayout.HelpBox("You can choose which object layers to render as partially submerged into water in the \"Refraction Properties\" and the \"Reflection Properties\" in the water component inspector.", MessageType.Info);
            }

            EndPropertiesSubGroup();

            BeginPropertiesSubGroup("Color Properties");
            DrawColorProperties("_SurfaceColor");
            EndPropertiesSubGroup();

            BeginPropertiesSubGroup("Texture Properties");
            DrawTextureProperties("_SurfaceTexture", 2);
            EndPropertiesSubGroup();
        }
Ejemplo n.º 14
0
        void GetProperties()
        {
            //MAIN SETTINGS
            _Radius         = FindProperty("_Radius", _properties);
            _Arcrange       = FindProperty("_Arcrange", _properties);
            _Fillpercentage = FindProperty("_Fillpercentage", _properties);
            _Globalopacity  = FindProperty("_Globalopacity", _properties);
            _Rotation       = FindProperty("_Rotation", _properties);

            //MAINBAR
            _Barmincolor            = FindProperty("_Barmincolor", _properties);
            _Barmaxcolor            = FindProperty("_Barmaxcolor", _properties);
            _Mainbarborderopacity   = FindProperty("_Mainbarborderopacity", _properties);
            _Barsecondarymincolor   = FindProperty("_Barsecondarymincolor", _properties);
            _Barsecondarymaxcolor   = FindProperty("_Barsecondarymaxcolor", _properties);
            _Bordermincolor         = FindProperty("_Bordermincolor", _properties);
            _Bordermaxcolor         = FindProperty("_Bordermaxcolor", _properties);
            _Mainborderradialwidth  = FindProperty("_Mainborderradialwidth", _properties);
            _Mainbordertangentwidth = FindProperty("_Mainbordertangentwidth", _properties);

            //MAIN TEX
            _Maintex             = FindProperty("_Maintex", _properties);
            _Maintexcontrast     = FindProperty("_Maintexcontrast", _properties);
            _Maintexopacity      = FindProperty("_Maintexopacity", _properties);
            _Invertmaintex       = FindProperty("_Invertmaintex", _properties);
            _Maintextiling       = FindProperty("_Maintextiling", _properties);
            _Maintexoffset       = FindProperty("_Maintexoffset", _properties);
            _Maintexscrollrotate = FindProperty("_Mainscrollrotate", _properties);
            _Maintexscrollspeed  = FindProperty("_Maintexscrollspeed", _properties);
            _Maintexrotatespeed  = FindProperty("_Maintexrotationspeed", _properties);

            //SECONDARY TEX
            _Secondarytex             = FindProperty("_Secondarytex", _properties);
            _Secondarytexcontrast     = FindProperty("_Secondarytexcontrast", _properties);
            _Invertsecondarytex       = FindProperty("_Invertsecondarytex", _properties);
            _Secondarytexopacity      = FindProperty("_Secondarytexopacity", _properties);
            _Secondarytextiling       = FindProperty("_Secondarytextiling", _properties);
            _Secondarytexoffset       = FindProperty("_Secondarytexoffset", _properties);
            _Secondarytexscrollrotate = FindProperty("_Secondaryscrollrotate", _properties);
            _Secondarytexscrollspeed  = FindProperty("_Secondarytexscrollspeed", _properties);
            _Secondarytexrotatespeed  = FindProperty("_Secondarytexrotationspeed", _properties);

            //NOISE TEX
            _Noisetex         = FindProperty("_Noisetex", _properties);
            _Invertnoisetex   = FindProperty("_Invertnoisetex", _properties);
            _Noisetexcontrast = FindProperty("_Noisetexcontrast", _properties);
            _Noiseintensity   = FindProperty("_Noiseintensity", _properties);
            _Noisetexspeed    = FindProperty("_Noisetexspeed", _properties);
            _Noisetextiling   = FindProperty("_Noisetextiling", _properties);
            _Noisetexoffset   = FindProperty("_Noisetexoffset", _properties);

            //BACKGROUND
            _Backgroundbordercolor        = FindProperty("_Backgroundbordercolor", _properties);
            _Backgroundopacity            = FindProperty("_Backgroundopacity", _properties);
            _Backgroundfillcolor          = FindProperty("_Backgroundfillcolor", _properties);
            _Backgroundborderopacity      = FindProperty("_Backgroundborderopacity", _properties);
            _Backgroundborderradialwidth  = FindProperty("_Backgroundborderradialwidth", _properties);
            _Backgroundbordertangentwidth = FindProperty("_Backgroundbordertangentwidth", _properties);
        }
Ejemplo n.º 15
0
    public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Calculate help box height
        bool scrollBar = (Screen.width - InspectorWidth) > 20;
        var  height    = TCP2_GUI.HelpBoxRichTextStyle.CalcHeight(new GUIContent(message, icon), Screen.width - (scrollBar ? 51 : 34));

        return(height + 6f);
    }
Ejemplo n.º 16
0
    //Passed in by the base editor
    public AlloyTextureFieldDrawer(AlloyInspectorBase editor, MaterialProperty property)
        : base(editor, property)
    {
        TabGroup = AlloyTabGroup.GetTabGroup();

        m_tabOpen.value = TabGroup.IsOpen(SaveName);
        m_tabOpen.speed = 4.0f;
    }
Ejemplo n.º 17
0
        private void Save(MaterialProperty prop)
        {
            Debug.Log(prop.textureValue.ToString());
            Texture saved_texture = TextureHelper.SaveTextureAsPNG(texture, PATH.TEXTURES_DIR + "curves/" + curve.GetHashCode() + ".png", null);

            prop.textureValue = saved_texture;
            saved             = true;
        }
Ejemplo n.º 18
0
    //Set Alpha cuttoff slider
    void SetAlpha()
    {
        MaterialProperty sli = FindProperty("_AlphaCut");

        EditorGUI.indentLevel += 2;
        editor.ShaderProperty(sli, MakeLabel(sli));
        EditorGUI.indentLevel -= 2;
    }
Ejemplo n.º 19
0
        protected override void FindProperties(MaterialProperty[] props)
        {
            base.FindProperties(props);

            baseColor     = FindProperty("_BaseColor", props);
            wireColor     = FindProperty("_WireColor", props);
            wireThickness = FindProperty("_WireThickness", props);
        }
Ejemplo n.º 20
0
    //Metallic slider
    void MetallicSlide()
    {
        MaterialProperty slider = FindProperty("_metal");

        EditorGUI.indentLevel += 2;
        editor.ShaderProperty(slider, MakeLabel(slider));
        EditorGUI.indentLevel -= 2;
    }
    void DrawStandard(MaterialProperty property)
    {
        string displayName = property.displayName;

        // Remove everything in square brackets.
        displayName = Regex.Replace(displayName, @" ?\[.*?\]", string.Empty);
        _editor.ShaderProperty(property, displayName);
    }
Ejemplo n.º 22
0
 /// <summary>
 /// Creates a triangle through P_0, P_1, P_2 with given material property and normal.
 /// </summary>
 /// /// <param name="p0">starting point</param>
 /// <param name="p1">second point in mathematical positive sense</param>
 /// <param name="p2">third point in mathematical positive sense</param>
 /// <param name="normal">normal of the triangle, defines the front face</param>
 /// <param name="materialProperty"></param>
 public Triangle(vec4 p0, vec4 p1, vec4 p2, vec4 normal, MaterialProperty materialProperty)
 {
     _p0                = p0;
     _p1                = p1;
     _p2                = p2;
     _normal            = glm.normalize(normal);
     _material_property = materialProperty;
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Creates a triangle through the points P_0, P_1, P_2 with given material property and calculates the normal.
 /// The front face is defined in mathematic positve sense.
 /// </summary>
 /// <param name="p0">starting point</param>
 /// <param name="p1">second point in mathematical positive sense</param>
 /// <param name="p2">third point in mathematical positive sense</param>
 /// <param name="materialProperty"></param>
 public Triangle(vec4 p0, vec4 p1, vec4 p2, MaterialProperty materialProperty)
 {
     _p0                = p0;
     _p1                = p1;
     _p2                = p2;
     _normal            = getTriangleNormal();
     _material_property = materialProperty;
 }
Ejemplo n.º 24
0
        public static void SetupMaterialPropertyBlock(MaterialProperty materialProp, int changedMask, Renderer target)
        {
            MaterialPropertyBlock materialPropertyBlock = new MaterialPropertyBlock();

            target.GetPropertyBlock(materialPropertyBlock);
            materialProp.WriteToMaterialPropertyBlock(materialPropertyBlock, changedMask);
            target.SetPropertyBlock(materialPropertyBlock);
        }
Ejemplo n.º 25
0
    //smooth slider
    void SmoothSlide()
    {
        MaterialProperty slider = FindProperty("_smooth");

        EditorGUI.indentLevel += 2;
        editor.ShaderProperty(slider, MakeLabel(slider));
        EditorGUI.indentLevel -= 2;
    }
 static GUIContent MakeLabel(
     MaterialProperty property, string tooltip = null
     )
 {
     staticLabel.text    = property.displayName;
     staticLabel.tooltip = tooltip;
     return(staticLabel);
 }
 void FindProperties(MaterialProperty[] props)
 {
     _cubemap = FindProperty("_Cubemap", props);
     _tint = FindProperty("_Tint", props);
     _euler = FindProperty("_Euler", props);
     _exposure = FindProperty("_Exposure", props);
     _saturation = FindProperty("_Saturation", props);
 }
 public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
 {
     if (!IsPropertyTypeSuitable(prop))
     {
         return(EditorGUIUtility.singleLineHeight * 2.5f);
     }
     return(base.GetPropertyHeight(prop, label, editor));
 }
        private void DrawEmissionColorProperties()
        {
            MaterialProperty emissionColor     = FindProperty("_EmissionColor", _materialProperties);
            MaterialProperty emissionIntensity = FindProperty("_EmissionColorIntensity", _materialProperties);

            _materialEditor.ShaderProperty(emissionColor, "Color");
            _materialEditor.ShaderProperty(emissionIntensity, "Intensity");
        }
Ejemplo n.º 30
0
 public LCDDisplayProperties(MaterialProperty[] properties)
 {
     pixelMask         = BaseShaderGUI.FindProperty("_PixelMask", properties, false);
     pixelLuma         = BaseShaderGUI.FindProperty("_PixelLuma", properties, false);
     pixelLayout       = BaseShaderGUI.FindProperty("_PixelLayout", properties, false);
     pixelLayoutOffset = BaseShaderGUI.FindProperty("_PixelLayoutOffset", properties, false);
     colorWashout      = BaseShaderGUI.FindProperty("_ColorWashout", properties, false);
 }
 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;
 }
Ejemplo n.º 32
0
        override protected void FindMaterialProperties(MaterialProperty[] props)
        {
            color    = FindProperty(kColor, props);
            colorMap = FindProperty(kColorMap, props);

            emissiveColor    = FindProperty(kEmissiveColor, props);
            emissiveColorMap = FindProperty(kEmissiveColorMap, props);
        }
Ejemplo n.º 33
0
 public static void UpdateTextureValue(MaterialProperty prop, Texture texture)
 {
     foreach (UnityEngine.Object m in prop.targets)
     {
         ((Material)m).SetTexture(prop.name, texture);
     }
     prop.textureValue = texture;
 }
    void DoAlphaCutoff()
    {
        MaterialProperty slider = FindProperty("_Cutoff");

        EditorGUI.indentLevel += 2;
        editor.ShaderProperty(slider, MakeLabel(slider));
        EditorGUI.indentLevel -= 2;
    }
Ejemplo n.º 35
0
 override protected void FindMaterialProperties(MaterialProperty[] props)
 {
     color             = FindProperty("_Color", props);
     colorMap          = FindProperty("_ColorMap", props);
     emissiveColor     = FindProperty("_EmissiveColor", props);
     emissiveColorMap  = FindProperty(kEmissiveColorMap, props);
     emissiveIntensity = FindProperty("_EmissiveIntensity", props);
 }
        public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor materialEditor)
        {
            GUILayout.Space(top);

            materialEditor.TexturePropertySingleLine(new GUIContent(prop.displayName), prop);

            GUILayout.Space(down);
        }
        public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
        {
            GUIStyle styleLabel = new GUIStyle(EditorStyles.label)
            {
                richText = true,
                alignment = TextAnchor.MiddleCenter,
                wordWrap = true
            };

            if (Resources.Load<TextAsset>(file) != null)
            {
                var layersPath = AssetDatabase.GetAssetPath(Resources.Load<TextAsset>(file));

                StreamReader reader = new StreamReader(layersPath);

                options = reader.ReadLine();

                reader.Close();
            }

            string[] enumSplit = options.Split(char.Parse(" "));
            List<string> enumOptions = new List<string>(enumSplit.Length / 2);
            List<int> enumIndices = new List<int>(enumSplit.Length / 2);

            for (int i = 0; i < enumSplit.Length; i++)
            {
                if (i % 2 == 0)
                {
                    enumOptions.Add(enumSplit[i].Replace("_", " "));
                }
                else
                {
                    enumIndices.Add(int.Parse(enumSplit[i]));
                }
            }

            GUILayout.Space(top);

            int index = (int)prop.floatValue;
            int realIndex = enumIndices[0];

            for (int i = 0; i < enumIndices.Count; i++)
            {
                if (enumIndices[i] == index)
                {
                    realIndex = i;
                }
            }

            realIndex = EditorGUILayout.Popup(prop.displayName, realIndex, enumOptions.ToArray());

            //Debug Value
            //EditorGUILayout.LabelField(enumIndices[realIndex].ToString());

            prop.floatValue = enumIndices[realIndex];

            GUILayout.Space(down);
        }
Ejemplo n.º 38
0
    void findProperties(MaterialProperty[] props)
    {
        mainTexture          = FindProperty("_MainTex", props);
        mainTexturePower     = FindProperty("_MainTexPower", props);
        layoutTexture        = FindProperty("_LayoutTexture", props);
        layoutTexturePower   = FindProperty("_LayoutTexturePower", props);
        distanceLightTexture = FindProperty("_LightRampTexture", props);

        mainColor       = FindProperty("_MainColor", props);
        mainColorBottom = FindProperty("_MainColorBottom", props);

        topLight   = FindProperty("_TopLight", props);
        frontLight = FindProperty("_FrontLight", props);
        rightLight = FindProperty("_RightLight", props);

        topColor         = FindProperty("_TopColor", props);
        topColorBottom   = FindProperty("_TopColorBottom", props);
        frontColor       = FindProperty("_FrontColor", props);
        frontColorBottom = FindProperty("_FrontColorBottom", props);
        rightColor       = FindProperty("_RightColor", props);
        rightColorBottom = FindProperty("_RightColorBottom", props);

        gradientStartY = FindProperty("_GradientStartY", props);
        gradientHeight = FindProperty("_GradientHeight", props);

        rimColor       = FindProperty("_RimColor", props);
        rimColorBottom = FindProperty("_RimColorBottom", props);
        rimPower       = FindProperty("_RimPower", props);

        ambientColor = FindProperty("_AmbientColor", props);
        ambientPower = FindProperty("_AmbientPower", props);

        tintColor = FindProperty("_LightTint", props);

        lightmapColor       = FindProperty("_LightmapColor", props);
        lightmapPower       = FindProperty("_LightmapPower", props);
        lightmapShadowLight = FindProperty("_ShadowPower", props);

        fogColor  = FindProperty("_FogColor", props);
        fogStartY = FindProperty("_FogYStartPos", props);
        fogHeight = FindProperty("_FogHeight", props);

        fogDistanceStart   = FindProperty("_FogStart", props);
        fogDistanceEnd     = FindProperty("_FogEnd", props);
        fogDistanceDensity = FindProperty("_FogDensity", props);

        distanceLightDistance = FindProperty("_LightMaxDistance", props);
        distanceLightPosition = FindProperty("_LightPos", props);

        alpha  = FindProperty("_Alpha", props);
        cutout = FindProperty("_Cutoff", props);

        lightProbePower = FindProperty("_LightProbePower", props);

        specularColor = FindProperty("_SpecColorc", props);
        specularGloss = FindProperty("_Shininess", props);
        specularPower = FindProperty("_Specular", props);
    }
Ejemplo n.º 39
0
   void DrawLayer(MaterialEditor editor, int i, MaterialProperty[] props, string[] keyWords, Workflow workflow, 
      bool hasGloss, bool hasSpec, bool isParallax, bool hasEmis, bool hasDistBlend)
   {
      EditorGUIUtility.labelWidth = 0f;
      var albedoMap = FindProperty ("_Tex" + i, props);
      var tint = FindProperty("_Tint" + i, props);
      var normalMap = FindProperty ("_Normal" + i, props);
      var smoothness = FindProperty("_Glossiness" + i, props);
      var glossinessMap = FindProperty("_GlossinessTex" + i, props, false);
      var metallic = FindProperty("_Metallic" + i, props, false);
      var emissionTex = FindProperty("_Emissive" + i, props);
      var emissionMult = FindProperty("_EmissiveMult" + i, props);
      var parallax = FindProperty("_Parallax" + i, props);
      var texScale = FindProperty("_TexScale" + i, props);
      var specMap = FindProperty("_SpecGlossMap" + i, props, false);
      var specColor = FindProperty("_SpecColor" + i, props, false);
      var distUVScale = FindProperty("_DistUVScale" + i, props, false);

      editor.TexturePropertySingleLine(new GUIContent("Albedo/Height"), albedoMap);
      editor.ShaderProperty(tint, "Tint");
      editor.TexturePropertySingleLine(new GUIContent("Normal"), normalMap);
      if (workflow == Workflow.Metallic)
      {
         editor.TexturePropertySingleLine(new GUIContent("Metal(R)/Smoothness(A)"), glossinessMap);
      }
      else
      {
         editor.TexturePropertySingleLine(new GUIContent("Specular(RGB)/Gloss(A)"), specMap);
      }
      if (workflow == Workflow.Metallic && !hasGloss)
      { 
         editor.ShaderProperty(smoothness, "Smoothness");
         editor.ShaderProperty(metallic, "Metallic");
      }
      else if (workflow == Workflow.Specular && !hasSpec)
      {
         editor.ShaderProperty(smoothness, "Smoothness");
         editor.ShaderProperty(specColor, "Specular Color");
      }
      editor.TexturePropertySingleLine(new GUIContent("Emission"), emissionTex);
      editor.ShaderProperty(emissionMult, "Emissive Multiplier");

      editor.ShaderProperty(texScale, "Texture Scale");
      if (hasDistBlend)
      {
         editor.ShaderProperty(distUVScale, "Distance UV Scale");
      }
      if (isParallax)
      {
         editor.ShaderProperty(parallax, "Parallax Height");
      }

      if (i != 1)
      {
         editor.ShaderProperty(FindProperty("_Contrast"+i, props), "Interpolation Contrast");
      }
   }
    public static AlloyFieldDrawer GetFieldDrawer(AlloyInspectorBase editor, MaterialProperty prop) {
        AlloyFieldParser parser = GetFieldParser(prop);

        if (parser != null) {
            return parser.GetDrawer(editor);
        }

        return null;
    }
Ejemplo n.º 41
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        FindProperties(properties);

        if (ShaderPropertiesGUI(materialEditor) || _initial)
            foreach (Material m in materialEditor.targets)
                SetMaterialKeywords(m);

        _initial = false;
    }
 //TODO: see if there is a better callback function
 public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
 {
     string content = File.ReadAllText(TEMPLATE_PATH);
     content = content.Replace(ORIGINAL_SHADER_NAME, string.Format(SHADER_NAME_SYNTAX, materialEditor.target.name.Split(' ')[0]));
     content = content.Replace(PRE_EDITOR, EDITOR);
     File.WriteAllText(string.Format(OUTPUT_PATH, materialEditor.target.name.Split(' ')[0] + ".shader"), content);
     AssetDatabase.ImportAsset (string.Format(RELATIVE_OUTPUT_PATH, materialEditor.target.name.Split(' ')[0] + ".shader"));
     Shader shader = Shader.Find(string.Format(SHADER_NAME_SYNTAX, materialEditor.target.name));
     materialEditor.SetShader(shader);
 }
	override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor) {
		bool inactiveFlag=false;
		if (checkVisible(editor, ref inactiveFlag)) {
			if (prop.floatValue==1) {
				return MaterialEditor.GetDefaultPropertyHeight(prop);
			} else {
				return MaterialEditor.GetDefaultPropertyHeight(prop)-5;
			}
		}
		return -2;
	}
Ejemplo n.º 44
0
	void FindProperties(MaterialProperty[] props)
	{
		_albedoMap         = FindProperty("_MainTex", props);
		_albedoColor       = FindProperty("_Color", props);
		_metallic          = FindProperty("_Metallic", props, false);
		_smoothness        = FindProperty("_Glossiness", props);
		_bumpMap           = FindProperty("_BumpMap", props);
		_occlusionStrength = FindProperty("_OcclusionStrength", props);
		_occlusionMap      = FindProperty("_OcclusionMap", props);
		_mapScale          = FindProperty("_MapScale", props);
	}
Ejemplo n.º 45
0
    public void FindProperties(MaterialProperty[] props)
    {
        blendMask = FindProperty ("_Mask", props);

        albedoMap = FindProperty ("_MainTex", props);
        albedoMap2 = FindProperty ("_MainTex2", props);

        specularMap = FindProperty ("_SpecGlossMap", props);
        specularMap2 = FindProperty ("_SpecGlossMap2", props);

        bumpMap = FindProperty ("_NormalMap", props);
        bumpMap2 = FindProperty ("_NormalMap2", props);
    }
 override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
 {
     if (editor is RTP_CustomShaderGUI)
     {
         RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;
         if (customEditor.showFlag)
         {
             return 20;
         }
         return -2;
     }
     return 0;
 }
	override public void Apply(MaterialProperty prop) {
		if (myEditor!=null) {
			Material mat=myEditor.target as Material;
			if (prop.floatValue==0) {
				mat.DisableKeyword(myKeyword+"_ON");
				mat.EnableKeyword(myKeyword+"_OFF");
			} else {
				mat.DisableKeyword(myKeyword+"_OFF");
				mat.EnableKeyword(myKeyword+"_ON");
			}
		}

	}
	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();
		}
	}
    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
    {
        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;

            if (customEditor.showFlag)
            {
                Rect rect = GUILayoutUtility.GetLastRect();
                rect.width = Mathf.Min(rect.width, EditorGUIUtility.labelWidth);
                EditorGUI.LabelField(rect, new GUIContent("", toolTip));
            }
        }
    }
    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("OnGUI: " + label + " RTP_HeaderDecorator");

        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;

            if (customEditor.showFlag)
            {
                customEditor.nextLabelWidth = nextLabelWidth;
            }
        }
    }
    override public float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor) {
        //Debug.Log("GetHeight: " + label+ " RTP_MaterialProp" );

        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;
            if (customEditor.showFlag)
            {
                return 20;
            }
            return -2;
        }
        return MaterialEditor.GetDefaultPropertyHeight(prop);
    }
	override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
		bool inactiveFlag = false;
		if (checkVisible (editor, ref inactiveFlag)) {
			EditorGUI.BeginDisabledGroup(inactiveFlag);

			Color col = GUI.color;
			GUI.color = new Color(0.3f,0.9f,1,1f);
			position.x+=12;
			bool state = EditorGUI.Foldout(position, prop.floatValue==1, label, true);
			GUI.color = col;
			prop.floatValue = state ? 1 : 0;

			EditorGUI.EndDisabledGroup();
		}
	}
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        base.OnGUI(materialEditor, properties);
        Material mat = materialEditor.target as Material;
        string[] keywords = mat.shaderKeywords;
        // mat.renderQueue

        int order = mat.renderQueue - GeometryQueueNum;
        EditorGUI.BeginChangeCheck();
        order = EditorGUILayout.IntPopup("Render Order (Relative to Geometry)", order, optionNames, options);
        mat.renderQueue = GeometryQueueNum + order;
        if (EditorGUI.EndChangeCheck())
        {
            EditorUtility.SetDirty(mat);
        }
    }
    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("OnGUI: " + label + " RTP_HeaderDecorator");

        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;

            if (customEditor.showFlag)
            {
                EditorGUI.BeginDisabledGroup(customEditor.inactiveFlag);
                position.y += 2;
                EditorGUI.LabelField(position, headerLabel + (active_layer_flag ? " " +(customEditor.active_layer+1) : ""), EditorStyles.boldLabel);
                EditorGUI.EndDisabledGroup();
            }
        }
    }
	override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;

            if (!customEditor.showFlag) return;

            if (!parsed)
            {
                parsed = true;
                parsedLabel = RTP_MatPropStringParser.Parse(label);
            }
            label = parsedLabel;

            Color col = GUI.contentColor;
            Color bcol = GUI.backgroundColor;
            GUI.contentColor = new Color(1f, 1f, 0.8f, 1f);
            GUI.backgroundColor = backgroundColor;

            Rect pos = new Rect(position);
            pos.y += 3;
            pos.height -= 3;

            //if (visibilityProp1 != null)
            //{
            //    pos.x += 12;
            //    pos.width -= 12;
            //}

            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;
        }
    }
    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
        //Debug.Log("OnGUI: " + label + " RTP_MaterialProp");

        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;

            if (customEditor.showFlag) {
                bool featureActive = customEditor.CheckDefine(prop.name, false);
                EditorGUI.BeginDisabledGroup(customEditor.inactiveFlag);
                EditorGUI.BeginChangeCheck();
                bool feature_doesntFit = (featureActive != prop.floatValue > 0);
                Color col = GUI.color;
                if (feature_doesntFit)
                {
                    GUI.color = new Color(1,0.6f,0.6f,1);
                }
                float nval=EditorGUILayout.ToggleLeft(new GUIContent(label, toolTip), prop.floatValue>0 ? true:false, feature_doesntFit ? EditorStyles.boldLabel : EditorStyles.label) ? 1:0;
                GUI.color = col;
                if (EditorGUI.EndChangeCheck())
                {
                    prop.floatValue = nval;
                    if (nval==0 && dependentFeatures!=null)
                    {
                        for(int i=0; i<dependentFeatures.Length; i++)
                        {
                            if ((editor.target as Material).HasProperty(dependentFeatures[i]))
                            {
                                foreach(Material mat in editor.targets)
                                {
                                    mat.SetFloat(dependentFeatures[i], 0);
                                }
                            }
                        }
                    }
                }

			    EditorGUI.EndDisabledGroup();
		    }
        }

    }
Ejemplo n.º 57
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        // render the default gui
        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, "REDIFY_ON") != -1;
        EditorGUI.BeginChangeCheck();
        redify = EditorGUILayout.Toggle("Redify material", redify);
        if (EditorGUI.EndChangeCheck())
        {
            // enable or disable the keyword based on checkbox
            if (redify)
                targetMat.EnableKeyword("REDIFY_ON");
            else
                targetMat.DisableKeyword("REDIFY_ON");
        }
    }
Ejemplo n.º 58
0
	//Draws a property that's also a section header (usually a checkbox) along with a collapse/expand triangle. Returns true if block is expanded.
	public void DrawPropertyHeader(PropertyBlock block, MaterialProperty prop, string label) {
		float controlSize = 110;
		EditorGUIUtility.fieldWidth = controlSize;
		EditorGUIUtility.labelWidth = 0;
		
		EditorGUILayout.BeginHorizontal();
		
		//draw folding triangle and retrieve state
		Rect r = EditorGUILayout.GetControlRect(GUILayout.Width(0), GUILayout.Height(16));
		block.open = EditorGUI.Foldout(r, block.open, "", false);

		if( !block.label ) {
			//draw a 10-pixel checkbox or a control-sized whatever-else (combo box usually)
			r = EditorGUILayout.GetControlRect(GUILayout.Width(block.checkbox ? 10 : controlSize), GUILayout.Height(16));			
			//draw property with label to the right
			ShaderProperty(r, prop, "");
		}
		EditorGUILayout.LabelField(label);
		
		EditorGUILayout.EndHorizontal();
	}
	override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
		if (!checkVisible(editor)) return;
		myEditor = editor;
		float nval;
		//label += "#" + myKeyword + "#";
		if (myMode=="RIGHT") {
			nval = EditorGUI.Toggle(position, label, prop.floatValue==1) ? 1:0;
		} else {
			if (label.Substring(0,1)==" ") {
				position.x+=12;
				position.width-=12;
				nval = EditorGUI.ToggleLeft(position, label.Substring(3), prop.floatValue==1, EditorStyles.boldLabel) ? 1:0;
			} else {
				nval = EditorGUI.ToggleLeft(position, label, prop.floatValue==1, EditorStyles.boldLabel) ? 1:0;
			}
		}
		if (nval!=prop.floatValue) {
			prop.floatValue = nval;
			if (myKeyword!="") Apply(prop);
		}
	}
Ejemplo n.º 60
0
    public override void OnEnable()
    {
        base.OnEnable();

        targetMaterial = target as Material;
        keyWords = targetMaterial.shaderKeywords;

        Material[] mats = new Material[] { targetMaterial };

        _FragTex = GetMaterialProperty(mats, "_FragTex");
        _FragTexStrength = GetMaterialProperty(mats, "_FragTexStrength");
        _FragPow = GetMaterialProperty(mats, "_FragPow");

        _DisAmount = GetMaterialProperty(mats, "_DisAmount");

        _FragmentScale = GetMaterialProperty(mats, "_FragmentScale");
        _DistanceToPlane = GetMaterialProperty(mats, "_DistanceToPlane");

        _Color = GetMaterialProperty(mats, "_Color");
        _MainTex = GetMaterialProperty(mats, "_MainTex");
        _Emission = GetMaterialProperty(mats, "_Emission");
    }