private void InitType() {
            // Color生成
            var colProps = type.colProps;
            this.editColors = new EditColor[colProps.Length];
            for (int i=0; i<colProps.Length; i++) {
                var colProp = colProps[i];
                var ec = new EditColor(null, colProp.colorType);
                if (material != null) {
                    ec.Set( material.GetColor(colProps[i].propId) );
                } else {
                    ec.Set( colProps[i].defaultVal );
                }
                editColors[i] = ec;
            }

            // float生成
            var props = type.fProps;
            this.editVals = new EditValue[props.Length];
            for (int i=0; i<props.Length; i++) {
                float val = props[i].defaultVal;
                if (material != null) {
                    val = material.GetFloat(props[i].propId);
                }
                editVals[i] = new EditValue(val, props[i].range);
            }
        }
        private bool drawValueSlider(string label, ref EditColor edit, int idx, ref float sliderVal)
        {
            bool changed     = false;
            bool fontChanged = false;

            GUILayout.BeginHorizontal(optItemHeight);
            try {
                drawLabel(ref label);

                if (!edit.isSyncs[idx])
                {
                    SetTextColor(uiParams.textStyleSC, ref txtColorRed);
                    fontChanged = true;
                }

                EditRange range = edit.GetRange(idx);
                var       val2  = GUILayout.TextField(edit.editVals[idx], uiParams.textStyleSC, optInputWidth);
                if (edit.editVals[idx] != val2)   // 直接書き換えられたケース
                {
                    edit.Set(idx, val2, range);
                }

                changed |= drawSlider(ref sliderVal, range.editMin, range.editMax);
                GUILayout.Space(buttonMargin);
            } catch (Exception e) {
                LogUtil.DebugF("{0}, idx={1}, color={2}, vals.length={3}, syncs.length={4}, e={5}",
                               label, idx, edit.val, edit.editVals.Length, edit.isSyncs.Length, e);
                throw;
            } finally {
                GUILayout.EndHorizontal();
                if (fontChanged)
                {
                    SetTextColor(uiParams.textStyleSC, ref txtColor);
                }
            }
            return(changed);
        }
        private bool drawValueSlider(string label, ref EditColor edit, int idx, ref float sliderVal) {
            bool changed = false;
            bool fontChanged = false;
            GUILayout.BeginHorizontal(optItemHeight);
            try {
                drawLabel(ref label);

                if (!edit.isSyncs[idx]) {
                    SetTextColor(uiParams.textStyleSC, ref txtColorRed);
                    fontChanged = true;
                }

                EditRange range = edit.GetRange(idx);
                var val2 = GUILayout.TextField(edit.editVals[idx], uiParams.textStyleSC, optInputWidth);
                if (edit.editVals[idx] != val2) { // 直接書き換えられたケース
                    edit.Set(idx, val2, range);
                }

                changed |= drawSlider(ref sliderVal, range.editMin, range.editMax);
                GUILayout.Space(buttonMargin);

            } catch(Exception e) {
                LogUtil.DebugF("{0}, idx={1}, color={2}, vals.length={3}, syncs.length={4}, e={5}",
                               label, idx, edit.val, edit.editVals.Length, edit.isSyncs.Length, e);
                throw;
            } finally {
                GUILayout.EndHorizontal();
                if (fontChanged) {
                    SetTextColor(uiParams.textStyleSC, ref txtColor);
                }
            }
            return changed;
        }
        private void setColorSlider(string label, ref EditColor edit, ColorType colType) {
            GUILayout.BeginHorizontal();
            GUILayout.Label(label, uiParams.lStyle, optItemHeight);


            Color c = edit.val.Value;
            bool changed = false;
            float[] vals = {0, 0.5f, 1f, 1.5f, 2f};
            foreach (var val in vals) {
                string blabel = val.ToString();
                if (GUILayout.Button(blabel, bStyleSS,  (blabel.Length> 1)? bWidthWOpt : bWidthOpt)) {
                    c.r = c.g = c.b = val;
                    changed = true;
                }
            }
            if (GUILayout.Button("-", bStyleSS, bWidthOpt)) {                
                if (c.r < delta) c.r = 0;
                else c.r -= delta;
                if (c.g < delta) c.g = 0;
                else c.g -= delta;
                if (c.b < delta) c.b = 0;
                else c.b -= delta;

                changed = true;                
            }            
            if (GUILayout.Button("+", bStyleSS, bWidthOpt)) {
                if (c.r + delta > 2.0f) c.r = 2;
                else c.r += delta;
                if (c.g + delta > 2.0f) c.g = 2;
                else c.g += delta;
                if (c.b + delta > 2.0f) c.b = 2;
                else c.b += delta;
                changed = true;                
            }            
            GUILayout.EndHorizontal();
 
            int idx = 0;
            if (colType == ColorType.rgb || colType == ColorType.rgba) {
                changed |= drawValueSlider("R", ref edit, idx++, ref c.r);
                changed |= drawValueSlider("G", ref edit, idx++, ref c.g);
                changed |= drawValueSlider("B", ref edit, idx++, ref c.b);
            }
            if (colType == ColorType.rgba || colType == ColorType.a) {
                changed |= drawValueSlider("A", ref edit, idx, ref c.a);
            }
            if (changed) {
                edit.Set(c);
            }
        }
        public void Update(ShaderType sdrType) {
            if (this.type == sdrType) return;
            // TODO 変更前のマテリアルから設定値をロード


            // 同一長の場合でも更新(Alphaの有無が異なるケースがある)            
            var colProps = sdrType.colProps;
            var createdColors = new EditColor[colProps.Length];
            for (int i=0; i<colProps.Length; i++) {
                var colProp = colProps[i];
                if (i < this.editColors.Length && editColors[i].val.HasValue) {
                    // カラータイプが異なる場合は、インスタンスを作り直して色をコピー
                    if (editColors[i].type == colProp.colorType) {
                        createdColors[i] = editColors[i];
                    } else {
                        createdColors[i] = new EditColor(editColors[i].val, colProp.colorType); 
                    }
                } else {
                    var ec = new EditColor(null, colProp.colorType);
                    if (material != null) {
                        ec.Set( material.GetColor(colProps[i].propId) );
                    } else {
                        ec.Set( (original != null)? original.GetColor(i): colProps[i].defaultVal );
                    }
                    createdColors[i] = ec;
                }
            }
            editColors = createdColors;
            
            
            var props = sdrType.fProps;
            var createdVals = new EditValue[props.Length];
            for (int i=0; i<props.Length; i++) {
                float val;
                if (material != null) {
                    val = material.GetFloat(props[i].propId);
                } else {
                    val = props[i].defaultVal;//(original != null)? original.GetColor(i): Color.white;
                }
                createdVals[i] = new EditValue(val, props[i].range);
            }
            this.editVals = createdVals;

            // テクスチャ情報の初期化
            foreach (var texProp in sdrType.texProps) {
                // セットしてないテクスチャは空テクスチャをセット
                if (!material.HasProperty(texProp.keyName)) {
                    material.SetTexture(texProp.propId, new Texture());
                }
            }

            type = sdrType;
        }
        private void setColorSlider(string label, ref EditColor edit, ColorType colType)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(label, uiParams.lStyle, optItemHeight);


            Color c       = edit.val.Value;
            bool  changed = false;

            float[] vals = { 0, 0.5f, 1f, 1.5f, 2f };
            foreach (var val in vals)
            {
                string blabel = val.ToString();
                if (GUILayout.Button(blabel, bStyleSS, (blabel.Length > 1)? bWidthWOpt : bWidthOpt))
                {
                    c.r     = c.g = c.b = val;
                    changed = true;
                }
            }
            if (GUILayout.Button("-", bStyleSS, bWidthOpt))
            {
                if (c.r < delta)
                {
                    c.r = 0;
                }
                else
                {
                    c.r -= delta;
                }
                if (c.g < delta)
                {
                    c.g = 0;
                }
                else
                {
                    c.g -= delta;
                }
                if (c.b < delta)
                {
                    c.b = 0;
                }
                else
                {
                    c.b -= delta;
                }

                changed = true;
            }
            if (GUILayout.Button("+", bStyleSS, bWidthOpt))
            {
                if (c.r + delta > 2.0f)
                {
                    c.r = 2;
                }
                else
                {
                    c.r += delta;
                }
                if (c.g + delta > 2.0f)
                {
                    c.g = 2;
                }
                else
                {
                    c.g += delta;
                }
                if (c.b + delta > 2.0f)
                {
                    c.b = 2;
                }
                else
                {
                    c.b += delta;
                }
                changed = true;
            }
            GUILayout.EndHorizontal();

            int idx = 0;

            if (colType == ColorType.rgb || colType == ColorType.rgba)
            {
                changed |= drawValueSlider("R", ref edit, idx++, ref c.r);
                changed |= drawValueSlider("G", ref edit, idx++, ref c.g);
                changed |= drawValueSlider("B", ref edit, idx++, ref c.b);
            }
            if (colType == ColorType.rgba || colType == ColorType.a)
            {
                changed |= drawValueSlider("A", ref edit, idx, ref c.a);
            }
            if (changed)
            {
                edit.Set(c);
            }
        }
        // Token: 0x06000347 RID: 839 RVA: 0x0001AD6C File Offset: 0x00018F6C
        public void Show(bool reload)
        {
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            try
            {
                //ACCMaterialsView.<>c__DisplayClass4 CS$<>8__locals1 = new ACCMaterialsView.<>c__DisplayClass4();
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                try
                {
                    GUIContent content = this.expand ? ACCMaterialsView.MinusIcon : ACCMaterialsView.PlusIcon;
                    if (GUILayout.Button(content, ACCMaterialsView.bStyleLeft, new GUILayoutOption[]
                    {
                        ACCMaterialsView.optUnitHeight,
                        ACCMaterialsView.optIconWidth
                    }))
                    {
                        this.expand = !this.expand;
                    }
                    if (GUILayout.Button(this.edited.name, ACCMaterialsView.bStyleLeft, new GUILayoutOption[]
                    {
                        ACCMaterialsView.optUnitHeight
                    }))
                    {
                        this.expand = !this.expand;
                    }
                    if (!this.expand)
                    {
                        return;
                    }
                }
                finally
                {
                    GUILayout.EndHorizontal();
                }
                if (this.edited.type == ShaderType.UNKNOWN)
                {
                    GUILayout.Label("shader: " + this.edited.material.shader.name, new GUILayoutOption[0]);
                }
                else
                {
                    GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                    try
                    {
                        if (GUILayout.Button(ACCMaterialsView.CopyIcon, new GUILayoutOption[]
                        {
                            ACCMaterialsView.optUnitHeight,
                            ACCMaterialsView.optButonWidthS
                        }))
                        {
                            ACCMaterialsView.clipHandler.SetClipboard(MateHandler.Instance.ToText(this.edited));
                            if (this.tipsCall != null)
                            {
                                this.tipsCall("マテリアル情報をクリップボードに\nコピーしました");
                            }
                        }
                        GUI.enabled &= ACCMaterialsView.clipHandler.isMateText;
                        GUIContent[] array = ACCMaterialsView.PasteIcons;
                        if (GUILayout.Button(array[0], new GUILayoutOption[]
                        {
                            ACCMaterialsView.optUnitHeight,
                            ACCMaterialsView.optButonWidthS
                        }))
                        {
                            try
                            {
                                MateHandler.Instance.Write(this.edited, ACCMaterialsView.clipHandler.mateText);
                                if (this.tipsCall != null)
                                {
                                    this.tipsCall("マテリアル情報を貼付けました");
                                }
                            }
                            catch (Exception ex)
                            {
                                LogUtil.Error(new object[]
                                {
                                    "failed to import mateText",
                                    ex
                                });
                            }
                        }
                        ACCMaterialsView.includeOthers = GUILayout.Toggle(ACCMaterialsView.includeOthers, "CF", ACCMaterialsView.uiParams.tStyleSS, new GUILayoutOption[0]);
                        ACCMaterialsView.includeShader = GUILayout.Toggle(ACCMaterialsView.includeShader, "S", ACCMaterialsView.uiParams.tStyleSS, new GUILayoutOption[0]);
                        ACCMaterialsView.includeTex    = GUILayout.Toggle(ACCMaterialsView.includeTex, "T", ACCMaterialsView.uiParams.tStyleSS, new GUILayoutOption[0]);
                        GUI.enabled &= (ACCMaterialsView.includeTex | ACCMaterialsView.includeShader | ACCMaterialsView.includeOthers);
                        if (GUILayout.Button(array[1], new GUILayoutOption[]
                        {
                            ACCMaterialsView.optUnitHeight,
                            ACCMaterialsView.optButonWidth
                        }))
                        {
                            try
                            {
                                int num = 0;
                                if (ACCMaterialsView.includeTex)
                                {
                                    num |= MateHandler.MATE_TEX;
                                }
                                if (ACCMaterialsView.includeShader)
                                {
                                    num |= MateHandler.MATE_SHADER;
                                }
                                if (ACCMaterialsView.includeOthers)
                                {
                                    num |= (MateHandler.MATE_COLOR | MateHandler.MATE_FLOAT);
                                }
                                LogUtil.DebugF("material pasting from cp... tex={0}, shader={1}, others={2}", new object[]
                                {
                                    ACCMaterialsView.includeTex,
                                    ACCMaterialsView.includeShader,
                                    ACCMaterialsView.includeOthers
                                });
                                MateHandler.Instance.Write(this.edited, ACCMaterialsView.clipHandler.mateText, num);
                            }
                            catch (Exception ex2)
                            {
                                LogUtil.Error(new object[]
                                {
                                    "failed to import mateText",
                                    ex2
                                });
                            }
                            if (this.tipsCall != null)
                            {
                                this.tipsCall("マテリアル情報を貼付けました");
                            }
                        }
                    }
                    finally
                    {
                        GUI.enabled = true;
                        GUILayout.EndHorizontal();
                    }
                    var material = this.edited.material;
                    int idx      = this.edited.type.idx;
                    if (this.shaderCombo == null)
                    {
                        GUIContent buttonContent = (idx >= 0 && idx < ACCMaterialsView.ShaderNames.Length) ? ACCMaterialsView.ShaderNames[idx] : GUIContent.none;
                        this.shaderCombo = new ComboBoxLO(buttonContent, ACCMaterialsView.ShaderNames, ACCMaterialsView.uiParams.bStyleSC, ACCMaterialsView.uiParams.boxStyle, ACCMaterialsView.uiParams.listStyle, false);
                    }
                    else
                    {
                        this.shaderCombo.SelectedItemIndex = idx;
                    }
                    this.shaderCombo.Show(GUILayout.ExpandWidth(true));
                    int selectedItemIndex = this.shaderCombo.SelectedItemIndex;
                    if (idx != selectedItemIndex && selectedItemIndex != -1)
                    {
                        LogUtil.Debug(new object[]
                        {
                            "shader changed",
                            idx,
                            "=>",
                            selectedItemIndex
                        });
                        string text = ACCMaterialsView.ShaderNames[selectedItemIndex].text;
                        this.edited.ChangeShader(text, selectedItemIndex);
                    }
                    if (reload)
                    {
                        this.edited.renderQueue.Set(material.renderQueue);
                    }
                    this.sliderHelper.SetupFloatSlider("RQ", this.edited.renderQueue, this.edited.renderQueue.range.editMin, this.edited.renderQueue.range.editMax, delegate(float rq)
                    {
                        material.SetFloat(ShaderPropType.RenderQueue.propId, rq);
                        material.renderQueue = (int)rq;
                    }, ShaderPropType.RenderQueue.opts, ShaderPropType.RenderQueue.presetVals, ACCMaterialsView.rqResolver.Resolve(this.slotIdx));
                    ShaderType type = this.edited.type;
                    for (int i = 0; i < type.colProps.Length; i++)
                    {
                        ShaderPropColor shaderPropColor = type.colProps[i];
                        EditColor       editColor       = this.edited.editColors[i];
                        ColorPicker     picker          = this.edited.pickers[i];
                        if (reload)
                        {
                            editColor.Set(material.GetColor(shaderPropColor.propId));
                        }
                        if (this.sliderHelper.DrawColorSlider(shaderPropColor, ref editColor, picker))
                        {
                            material.SetColor(shaderPropColor.propId, editColor.val);
                        }
                    }
                    for (int j = 0; j < type.fProps.Length; j++)
                    {
                        //ACCMaterialsView.<>c__DisplayClass8 CS$<>8__locals2 = new ACCMaterialsView.<>c__DisplayClass8();
                        //CS$<>8__locals2.CS$<>8__locals5 = CS$<>8__locals1;
                        var prop = type.fProps[j];
                        if (reload)
                        {
                            this.edited.editVals[j].Set(material.GetFloat(prop.propId));
                        }
                        switch (prop.valType)
                        {
                        case ValType.Float:
                        {
                            ShaderPropFloat fprop = prop;
                            this.sliderHelper.SetupFloatSlider(fprop, this.edited.editVals[j], delegate(float val)
                                {
                                    fprop.SetValue(material, val);
                                });
                            break;
                        }

                        case ValType.Bool:
                            this.cbHelper.ShowCheckBox(prop.name, this.edited.editVals[j], delegate(float val)
                            {
                                prop.SetValue(material, val);
                            });
                            break;

                        case ValType.Enum:
                            this.cbHelper.ShowComboBox(prop.name, this.edited.editVals[j], delegate(int val)
                            {
                                prop.SetValue(material, (float)val);
                            });
                            break;
                        }
                    }
                }
            }
            finally
            {
                GUILayout.EndVertical();
            }
        }