コード例 #1
0
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
        {
            if (materialEditor.target is Material material)
            {
                string          current          = material.GetTag(TAG_RENDER_TYPE, false);
                BlendModeOption currentBlendMode = BlendModeOption.Opaque;

                switch (current)
                {
                case "":
                case TAG_RENDER_TYPE_OPAQUE:
                    currentBlendMode = BlendModeOption.Opaque;
                    break;

                case TAG_RENDER_TYPE_CUTOUT:
                    currentBlendMode = BlendModeOption.Cutout;
                    break;

                case TAG_RENDER_TYPE_FADE:
                    currentBlendMode = BlendModeOption.Fade;
                    break;

                case TAG_RENDER_TYPE_TRANSPARENT:
                    currentBlendMode = BlendModeOption.Transparent;
                    break;
                }
                GUILayout.BeginHorizontal();
                GUILayout.Label("Blend Mode");
                BlendModeOption blend = (BlendModeOption)EditorGUILayout.EnumPopup(currentBlendMode);
                GUILayout.EndHorizontal();

                if (blend != currentBlendMode)
                {
                    ConfigureBlendMode(material, blend);
                }

                uvTransform = TextureRotationSlider(material, uvTransform, mainTexScaleTransform, mainTexRotation, true);
                if (uvTransform.HasValue)
                {
                    if (uvTransform.Value.rotation != 0)
                    {
                        material.EnableKeyword(KW_UV_ROTATION);
                    }
                    else
                    {
                        material.DisableKeyword(KW_UV_ROTATION);
                    }
                }

                if (GUI.changed)
                {
                    EditorUtility.SetDirty(material);
                }
            }

            base.OnGUI(materialEditor, properties);
        }
コード例 #2
0
        public static void ConfigureBlendMode(Material material, BlendModeOption mode)
        {
            switch (mode)
            {
            case BlendModeOption.Opaque:
                SetOpaqueMode(material);
                break;

            case BlendModeOption.Cutout:
                SetAlphaModeMask(material, material.GetFloat(cutoffPropId));
                break;

            case BlendModeOption.Fade:
                SetAlphaModeBlend(material);
                break;

            case BlendModeOption.Transparent:
                SetAlphaModeTransparent(material);
                break;
            }
        }