Example #1
0
    protected override AlloyFieldDrawer GenerateDrawer(AlloyInspectorBase editor)
    {
        AlloyFieldDrawer ret = null;

        for (int i = 0; i < Arguments.Length; i++)
        {
            var argument = Arguments[i];

            var valProp = argument.ArgumentToken as AlloyValueToken;


            switch (argument.ArgumentName)
            {
            case "Vector":

                if (valProp != null)
                {
                    ret = SetupVectorDrawer(editor, valProp, ret);
                }
                break;
            }
        }

        if (ret == null)
        {
            ret = new AlloyVectorDrawer(editor, MaterialProperty);
            ((AlloyVectorDrawer)ret).Mode = AlloyVectorDrawer.VectorMode.Vector4;
        }


        return(ret);
    }
    protected override AlloyFieldDrawer GenerateDrawer(AlloyInspectorBase editor) {
        AlloyFieldDrawer ret = null;

        for (int i = 0; i < Arguments.Length; i++) {
            var argument = Arguments[i];

            var valProp = argument.ArgumentToken as AlloyValueToken;


            switch (argument.ArgumentName) {
                case "Vector":

                    if (valProp != null) {
                        ret = SetupVectorDrawer(editor, valProp, ret);
                    }
                break;
            }
        }

        if (ret == null) {
            ret = new AlloyVectorDrawer(editor, MaterialProperty);
            ((AlloyVectorDrawer)ret).Mode = AlloyVectorDrawer.VectorMode.Vector4;
        }


        return ret;
    }
Example #3
0
 public static void Register(AlloyInspectorBase inspector, MaterialEditor keeper)
 {
     if (!s_inspectorKeeper.ContainsKey(inspector))
     {
         s_inspectorKeeper.Add(inspector, keeper);
     }
 }
Example #4
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;
	}
    public static AlloyFieldDrawer GetFieldDrawer(AlloyInspectorBase editor, MaterialProperty prop) {
        AlloyFieldParser parser = GetFieldParser(prop);

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

        return null;
    }
Example #6
0
    public static AlloyFieldDrawer GetFieldDrawer(AlloyInspectorBase editor, MaterialProperty prop)
    {
        AlloyFieldParser parser = GetFieldParser(prop);

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

        return(null);
    }
    public AlloyFieldDrawer GetDrawer(AlloyInspectorBase editor) {
        if (!HasSettings) {
            return null;
        }

        var drawer = GenerateDrawer(editor);
        if (drawer != null) {
            drawer.DisplayName = DisplayName;
        }

        return drawer;
    }
Example #8
0
    AlloyFieldDrawer SetupVectorDrawer(AlloyInspectorBase editor,
                                       AlloyValueToken valProp,
                                       AlloyFieldDrawer ret)
    {
        if (valProp.ValueType == AlloyValueToken.ValueTypeEnum.String)
        {
            switch (valProp.StringValue)
            {
            case "Euler":
                ret = new AlloyVectorDrawer(editor, MaterialProperty);
                ((AlloyVectorDrawer)ret).Mode = AlloyVectorDrawer.VectorMode.Euler;
                break;

            case "TexCoord":
                ret = new AlloyTexCoordDrawer(editor, MaterialProperty);
                break;

            case "Channels":
                ret = new AlloyMaskDrawer(editor, MaterialProperty);
                break;

            default:
                Debug.LogError("Non supported vector property!");
                break;
            }
        }
        else if (valProp.ValueType == AlloyValueToken.ValueTypeEnum.Float)
        {
            switch ((int)valProp.FloatValue)
            {
            case 2:
                ret = new AlloyVectorDrawer(editor, MaterialProperty);
                ((AlloyVectorDrawer)ret).Mode = AlloyVectorDrawer.VectorMode.Vector2;
                break;

            case 3:
                ret = new AlloyVectorDrawer(editor, MaterialProperty);
                ((AlloyVectorDrawer)ret).Mode = AlloyVectorDrawer.VectorMode.Vector3;
                break;

            case 4:
                ret = new AlloyVectorDrawer(editor, MaterialProperty);
                ((AlloyVectorDrawer)ret).Mode = AlloyVectorDrawer.VectorMode.Vector4;
                break;

            default:
                Debug.LogError("Non supported vector property!");
                break;
            }
        }
        return(ret);
    }
Example #9
0
    //Passed in by the base editor
    public AlloyTextureFieldDrawer(AlloyInspectorBase editor, MaterialProperty property)
        : base(editor, property)
    {
        m_tabGroup      = AlloyTabGroup.GetTabGroup();
        m_tabOpen.speed = 4.0f;

        m_scale  = Serialized.FindPropertyRelative("m_Scale");
        m_offset = Serialized.FindPropertyRelative("m_Offset");

        m_shaderVarName = Property.name;


        CacheTextureProps(editor, m_shaderVarName, out m_velocityProp, out m_spinProp, out m_uvProp);
    }
Example #10
0
    public AlloyTexCoordDrawer(AlloyInspectorBase editor, MaterialProperty property)
        : base(editor, property)
    {
        m_shaderVarName = Property.name.Replace("_ST", "");
        m_tabGroup      = AlloyTabGroup.GetTabGroup();

        m_tabOpen.value = m_tabGroup.IsOpen(SaveName);

        AlloyTextureFieldDrawer.CacheTextureProps(editor,
                                                  m_shaderVarName,
                                                  out m_scrollProp,
                                                  out m_spinProp,
                                                  out m_uvProp);
    }
Example #11
0
    public AlloyFieldDrawer GetDrawer(AlloyInspectorBase editor)
    {
        if (!HasSettings)
        {
            return(null);
        }

        var drawer = GenerateDrawer(editor);

        if (drawer != null)
        {
            drawer.DisplayName = DisplayName;
        }

        return(drawer);
    }
    private AlloyFieldDrawer SetupVectorDrawer(AlloyInspectorBase editor, AlloyValueToken valProp,
        AlloyFieldDrawer ret) {
        if (valProp.ValueType == AlloyValueToken.ValueTypeEnum.String) {
            switch (valProp.StringValue) {
                case "Euler":
                    ret = new AlloyVectorDrawer(editor, MaterialProperty);
                    ((AlloyVectorDrawer) ret).Mode = AlloyVectorDrawer.VectorMode.Euler;
                    break;

                case "TexCoord":
                    ret = new AlloyTexCoordDrawer(editor, MaterialProperty);
                    break;

                case "Mask":
                    ret = new AlloyMaskDrawer(editor, MaterialProperty);
                    break;

                default:
                    Debug.LogError("Non supported vector property!");
                    break;
            }
        }
        else if (valProp.ValueType == AlloyValueToken.ValueTypeEnum.Float) {
            switch ((int) valProp.FloatValue) {
                case 2:
                    ret = new AlloyVectorDrawer(editor, MaterialProperty);
                    ((AlloyVectorDrawer) ret).Mode = AlloyVectorDrawer.VectorMode.Vector2;
                    break;

                case 3:
                    ret = new AlloyVectorDrawer(editor, MaterialProperty);
                    ((AlloyVectorDrawer) ret).Mode = AlloyVectorDrawer.VectorMode.Vector3;
                    break;

                case 4:
                    ret = new AlloyVectorDrawer(editor, MaterialProperty);
                    ((AlloyVectorDrawer) ret).Mode = AlloyVectorDrawer.VectorMode.Vector4;
                    break;

                default:
                    Debug.LogError("Non supported vector property!");
                    break;
            }
        }
        return ret;
    }
Example #13
0
    public static void CacheTextureProps(AlloyInspectorBase editor,
                                         string shaderVarName,
                                         out SerializedProperty scrollProp,
                                         out SerializedProperty spinProp,
                                         out SerializedProperty uvProp)
    {
        string velName = shaderVarName + "Velocity";

        scrollProp = editor.GetProperty(MaterialProperty.PropType.Vector, velName);

        string spinName = shaderVarName + "Spin";

        spinProp = editor.GetProperty(MaterialProperty.PropType.Float, spinName);

        string uvName = shaderVarName + "UV";

        uvProp = editor.GetProperty(MaterialProperty.PropType.Float, uvName);
    }
Example #14
0
    public AlloyBlendModeDropdownDrawer(AlloyInspectorBase editor, MaterialProperty property, BlendModeOptionConfig[] blendModeOptionConfigs) : base(editor, property)
    {
        BlendModeOptionConfigs = blendModeOptionConfigs;

        // Get default from keyword.
        var keywords = editor.Target.shaderKeywords;

        property.floatValue = 0.0f;

        foreach (var setting in BlendModeOptionConfigs)
        {
            if (keywords.Contains(setting.Keyword))
            {
                property.floatValue = setting.Type;
                break;
            }
        }
    }
Example #15
0
    protected override AlloyFieldDrawer GenerateDrawer(AlloyInspectorBase editor)
    {
        var ret = new AlloyTextureFieldDrawer(editor, MaterialProperty);

        foreach (var token in Arguments)
        {
            var argName  = token.ArgumentName;
            var argToken = token.ArgumentToken;

            switch (argName)
            {
            case "Visualize": {
                var container = argToken as AlloyCollectionToken;
                if (container != null)
                {
                    ret.DisplayModes = container.SubTokens.Select(t => (AlloyTextureFieldDrawer.TextureVisualizeMode)Enum.Parse(typeof(AlloyTextureFieldDrawer.TextureVisualizeMode), t.Token)).ToArray();
                }
            }

            break;

            case "Parent": {
                ret.ParentTexture = argToken.Token;
            }

            break;

            case "Controls":
                var valueToken = argToken as AlloyValueToken;
                if (valueToken != null)
                {
                    ret.Controls = valueToken.BoolValue;
                }
                break;

                //				case "Keyword":
                //					ret.Keyword = argToken.Token;
                //					break;
            }
        }

        return(ret);
    }
Example #16
0
    public AlloySpeedTreeGeometryTypeDrawer(AlloyInspectorBase editor, MaterialProperty property) : base(editor, property)
    {
        // The original SpeedTree shader seemed to pick the dropdown value from
        // whichever keyword is already set on the material after import.

        // Note: Multi edit will override the _GeometryValue on other materials with whatever keywords the first material has set
        string[] keywords = editor.Target.shaderKeywords;
        property.floatValue = 0.0f;

        for (int i = 0; i < s_speedTreeKeywordSettings.Length; i++)
        {
            SpeedTreeKeywordSetting setting = s_speedTreeKeywordSettings[i];

            if (!keywords.Contains(setting.Keyword))
            {
                continue;
            }

            property.floatValue = (int)setting.GeometryType;
            break;
        }
    }
    protected override AlloyFieldDrawer GenerateDrawer(AlloyInspectorBase editor) {
        var ret = new AlloyTextureFieldDrawer(editor, MaterialProperty);

        foreach (var token in Arguments) {
            var argName = token.ArgumentName;
            var argToken = token.ArgumentToken;

            switch (argName) {
                case "Visualize": {
                        var container = argToken as AlloyCollectionToken;
                        if (container != null) {
                            ret.DisplayModes = container.SubTokens.Select(t => (AlloyTextureFieldDrawer.TextureVisualizeMode)Enum.Parse(typeof(AlloyTextureFieldDrawer.TextureVisualizeMode), t.Token)).ToArray();
                        }
                    }

                    break;

                case "Parent": {
                        ret.ParentTexture = argToken.Token;
                    }

                    break;

                case "Controls":
                    var valueToken = argToken as AlloyValueToken;
                    if (valueToken != null) {
                        ret.Controls = valueToken.BoolValue;
                    }
                    break;

                //				case "Keyword":
                //					ret.Keyword = argToken.Token;
                //					break;
            }
        }

        return ret;
    }
Example #18
0
    protected override AlloyFieldDrawer GenerateDrawer(AlloyInspectorBase editor)
    {
        AlloyFieldDrawer retDrawer = null;

        foreach (var token in Arguments)
        {
            var argName  = token.ArgumentName;
            var argToken = token.ArgumentToken;

            switch (argName)
            {
            case "Min":
                AlloyFloatDrawer minDrawer = null;
                var minValToken            = argToken as AlloyValueToken;

                if (retDrawer != null)
                {
                    minDrawer = retDrawer as AlloyFloatDrawer;
                }

                if (minDrawer == null)
                {
                    minDrawer = new AlloyFloatDrawer(editor, MaterialProperty);
                }

                minDrawer.HasMin   = true;
                minDrawer.MinValue = minValToken.FloatValue;
                retDrawer          = minDrawer;
                break;

            case "Max":
                AlloyFloatDrawer maxDrawer = null;
                var maxValToken            = argToken as AlloyValueToken;

                if (retDrawer != null)
                {
                    maxDrawer = retDrawer as AlloyFloatDrawer;
                }

                if (maxDrawer == null)
                {
                    maxDrawer = new AlloyFloatDrawer(editor, MaterialProperty);
                }

                maxDrawer.HasMax   = true;
                maxDrawer.MaxValue = maxValToken.FloatValue;
                retDrawer          = maxDrawer;
                break;

            case "Section":
                retDrawer = new AlloySectionDrawer(editor, MaterialProperty);
                SetSectionOption(retDrawer, argToken);
                break;

            case "Feature":
                retDrawer = new AlloyFeatureDrawer(editor, MaterialProperty);
                SetSectionOption(retDrawer, argToken);
                break;

            case "Toggle":
                retDrawer = new AlloyToggleDrawer(editor, MaterialProperty);
                SetToggleOption(retDrawer, argToken);
                break;

            case "SpeedTreeGeometryType":
                retDrawer = new AlloySpeedTreeGeometryTypeDrawer(editor, MaterialProperty);
                SetDropdownOption(retDrawer, argToken);
                break;

            case "RenderingMode":
                retDrawer = new AlloyRenderingModeDrawer(editor, MaterialProperty);
                SetDropdownOption(retDrawer, argToken);
                break;

            case "Dropdown":
                retDrawer = new AlloyDropdownDrawer(editor, MaterialProperty);
                SetDropdownOption(retDrawer, argToken);
                break;

            case "LightmapEmissionProperty":
                retDrawer = new AlloyLightmapEmissionDrawer(editor, MaterialProperty);
                break;

            case "RenderQueue":
                retDrawer = new AlloyRenderQueueDrawer(editor, MaterialProperty);
                break;

            case "EnableInstancing":
                retDrawer = new AlloyEnableInstancingDrawer(editor, MaterialProperty);
                break;

            case "DoubleSidedGI":
                retDrawer = new AlloyDoubleSidedGiDrawer(editor, MaterialProperty);
                break;
            }
        }

        if (retDrawer == null)
        {
            retDrawer = new AlloyFloatDrawer(editor, MaterialProperty);
        }

        return(retDrawer);
    }
    protected override AlloyFieldDrawer GenerateDrawer(AlloyInspectorBase editor) {
        AlloyFieldDrawer retDrawer = null;

        foreach (var token in Arguments) {
            var argName = token.ArgumentName;
            var argToken = token.ArgumentToken;

            switch (argName) {
                case "Min":
                    AlloyFloatDrawer minDrawer = null;
                    var minValToken = argToken as AlloyValueToken;
                        
                    if (retDrawer != null)
                        minDrawer = retDrawer as AlloyFloatDrawer;
                        
                    if (minDrawer == null)
                        minDrawer = new AlloyFloatDrawer(editor, MaterialProperty);

                    minDrawer.HasMin = true;
                    minDrawer.MinValue = minValToken.FloatValue;
                    retDrawer = minDrawer;
                    break;

                case "Max":
                    AlloyFloatDrawer maxDrawer = null;
                    var maxValToken = argToken as AlloyValueToken;
                    
                    if (retDrawer != null)
                        maxDrawer = retDrawer as AlloyFloatDrawer;

                    if (maxDrawer == null)
                        maxDrawer = new AlloyFloatDrawer(editor, MaterialProperty);

                    maxDrawer.HasMax = true;
                    maxDrawer.MaxValue = maxValToken.FloatValue;
                    retDrawer = maxDrawer;
                    break;

                case "Section":
                    var section = new AlloySectionDrawer(editor, MaterialProperty);
                    section.Color = ParseColor(argToken);
                    retDrawer = section;
                    break;

                case "Feature":
                    var feature = new AlloyFeatureDrawer(editor, MaterialProperty);
                    feature.Color = ParseColor(argToken);
                    retDrawer = feature;
                    break;

                case "Toggle":
                    retDrawer = new AlloyToggleDrawer(editor, MaterialProperty);
                    SetToggleOption(retDrawer, argToken);
                    break;
                    
                case "SpeedTreeGeometryType":
                    retDrawer = new AlloySpeedTreeGeometryTypeDrawer(editor, MaterialProperty);
                    SetDropdownOption(retDrawer, argToken);
                    break;

                case "RenderingMode":
                    retDrawer = new AlloyRenderingModeDrawer(editor, MaterialProperty);
                    SetDropdownOption(retDrawer, argToken);
                    break;

                case "Dropdown":
                    retDrawer = new AlloyDropdownDrawer(editor, MaterialProperty);
                    SetDropdownOption(retDrawer, argToken);
                    break;

                case "LightmapEmissionProperty":
                    retDrawer = new AlloyLightmapEmissionDrawer(editor, MaterialProperty);
                    break;

                case "DecalSortOrder":
                    retDrawer = new AlloyDecalSortOrderDrawer(editor, MaterialProperty);
                    break;
            }
        }

        if (retDrawer == null)
            retDrawer = new AlloyFloatDrawer(editor, MaterialProperty);

        return retDrawer;
    }
    //Passed in by the base editor
    public AlloyTextureFieldDrawer(AlloyInspectorBase editor, MaterialProperty property)
        : base(editor, property) {
        m_tabGroup = AlloyTabGroup.GetTabGroup();
        m_tabOpen.speed = 4.0f;

        m_scale = Serialized.FindPropertyRelative("m_Scale");
        m_offset = Serialized.FindPropertyRelative("m_Offset");

        m_shaderVarName = Property.name;


        CacheTextureProps(editor, m_shaderVarName, out m_velocityProp, out m_spinProp, out m_uvProp);
    }
    public static void CacheTextureProps(AlloyInspectorBase editor,
        string shaderVarName,
        out SerializedProperty scrollProp,
        out SerializedProperty spinProp,
        out SerializedProperty uvProp) {
        string velName = shaderVarName + "Velocity";
        scrollProp = editor.GetProperty(MaterialProperty.PropType.Vector, velName);

        string spinName = shaderVarName + "Spin";
        spinProp = editor.GetProperty(MaterialProperty.PropType.Float, spinName);

        string uvName = shaderVarName + "UV";
        uvProp = editor.GetProperty(MaterialProperty.PropType.Float, uvName);
    }
 protected override AlloyFieldDrawer GenerateDrawer(AlloyInspectorBase editor) {
     var ret = new AlloyColorDrawer(editor, MaterialProperty);
     return ret;
 }
    public AlloySpeedTreeGeometryTypeDrawer(AlloyInspectorBase editor, MaterialProperty property) : base(editor, property)
    {
        // The original SpeedTree shader seemed to pick the dropdown value from
        // whichever keyword is already set on the material after import.

        // Note: Multi edit will override the _GeometryValue on other materials with whatever keywords the first material has set
        string[] keywords = editor.Target.shaderKeywords;
        property.floatValue = 0.0f;
        
        for (int i = 0; i < s_speedTreeKeywordSettings.Length; i++) {
            SpeedTreeKeywordSetting setting = s_speedTreeKeywordSettings[i];

            if (!keywords.Contains(setting.Keyword)) {
                continue;
            }

            property.floatValue = (int) setting.GeometryType;
            break;
        }
    }
Example #24
0
 protected override AlloyFieldDrawer GenerateDrawer(AlloyInspectorBase editor)
 {
     return(new AlloyDefaultDrawer(editor, MaterialProperty));
 }
Example #25
0
 public AlloyFieldDrawer(AlloyInspectorBase editor, MaterialProperty property)
 {
     Serialized = editor.GetProperty(property.type, property.name);
     Property   = property;
 }
Example #26
0
 public AlloyFieldDrawer(AlloyInspectorBase editor, MaterialProperty property)
 {
     Property  = property;
     MatEditor = editor.MatEditor;
 }
Example #27
0
 public AlloySpeedTreeGeometryTypeDrawer(AlloyInspectorBase editor, MaterialProperty property)
     : base(editor, property, s_geometryTypes)
 {
 }
Example #28
0
 public AlloyRenderingModeDrawer(AlloyInspectorBase editor, MaterialProperty property)
     : base(editor, property, s_renderingModes)
 {
 }
Example #29
0
 public AlloyDecalSortOrderDrawer(AlloyInspectorBase editor, MaterialProperty property) : base(editor, property)
 {
 }
Example #30
0
 protected AlloyTabDrawer(AlloyInspectorBase editor, MaterialProperty property)
     : base(editor, property)
 {
     m_foldoutAction = all => r => GUI.Label(r, all ? "v" : ">", EditorStyles.whiteLabel);
 }
Example #31
0
 protected abstract AlloyFieldDrawer GenerateDrawer(AlloyInspectorBase editor);
 public AlloyLightmapEmissionDrawer(AlloyInspectorBase editor, MaterialProperty property) : base(editor, property) {
 }
	public static void Register(AlloyInspectorBase inspector, MaterialEditor keeper) {
		if (!s_inspectorKeeper.ContainsKey(inspector)) {
			s_inspectorKeeper.Add(inspector, keeper);
		}
	}
 public AlloyFieldDrawer(AlloyInspectorBase editor, MaterialProperty property) {
     Serialized = editor.GetProperty(property.type, property.name);
     Property = property;
 }
Example #35
0
 public AlloyRenderQueueDrawer(AlloyInspectorBase editor, MaterialProperty property) : base(editor, property)
 {
 }
 protected abstract AlloyFieldDrawer GenerateDrawer(AlloyInspectorBase editor);
Example #37
0
 public AlloyEnableInstancingDrawer(AlloyInspectorBase editor, MaterialProperty property) : base(editor, property)
 {
 }
 public AlloyRenderingModeDrawer(AlloyInspectorBase editor, MaterialProperty property) : base(editor, property) {
 }
Example #39
0
 public AlloyDoubleSidedGiDrawer(AlloyInspectorBase editor, MaterialProperty property) : base(editor, property)
 {
 }
 public AlloyDecalSortOrderDrawer(AlloyInspectorBase editor, MaterialProperty property) : base(editor, property) {
 }
 protected AlloyTabDrawer(AlloyInspectorBase editor, MaterialProperty property)
     : base(editor, property) {
     m_foldoutAction = all => r => GUI.Label(r, all ? "v" : ">", EditorStyles.whiteLabel);
 }
 public AlloyColorDrawer(AlloyInspectorBase editor, MaterialProperty property) : base(editor, property) {
 }
 protected override AlloyFieldDrawer GenerateDrawer(AlloyInspectorBase editor) {
     return new AlloyDefaultDrawer(editor, MaterialProperty);
 }
Example #44
0
    protected override AlloyFieldDrawer GenerateDrawer(AlloyInspectorBase editor)
    {
        var ret = new AlloyColorDrawer(editor, MaterialProperty);

        return(ret);
    }
    public AlloyTexCoordDrawer(AlloyInspectorBase editor, MaterialProperty property)
        : base(editor, property) {

        m_shaderVarName = Property.name.Replace("_ST", "");
        m_tabGroup = AlloyTabGroup.GetTabGroup();

        m_tabOpen.value = m_tabGroup.IsOpen(SaveName);

        AlloyTextureFieldDrawer.CacheTextureProps(editor,
            m_shaderVarName,
            out m_scrollProp,
            out m_spinProp,
            out m_uvProp);
    }
Example #46
0
 public AlloyMaskDrawer(AlloyInspectorBase editor, MaterialProperty property) : base(editor, property)
 {
 }
Example #47
0
 public AlloyLightmapEmissionDrawer(AlloyInspectorBase editor, MaterialProperty property) : base(editor, property)
 {
 }