示例#1
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;
    }