Beispiel #1
0
    // Function to draw title + enable toggle options as well as setting keyword.
    private bool DrawTogglePanel(FoldoutType type, string label, bool toggle, string keyword)
    {
        float old_LabelWidth = EditorGUIUtility.labelWidth;
        float old_FieldWidth = EditorGUIUtility.fieldWidth;

        EditorGUI.indentLevel = 0;
        Rect rect = EditorGUILayout.GetControlRect(false, 22);

        GUI.Label(rect, GUIContent.none, Group_Label);
        if (GUI.Button(new Rect(rect.x, rect.y, 250, rect.height), label, Group_Label_Left))
        {
            switch (type)
            {
            case FoldoutType.underlay:
                m_foldout.underlay = !m_foldout.underlay;
                break;

            case FoldoutType.bevel:
                m_foldout.bevel = !m_foldout.bevel;
                break;

            case FoldoutType.light:
                m_foldout.light = !m_foldout.light;
                break;

            case FoldoutType.bump:
                m_foldout.bump = !m_foldout.bump;
                break;

            case FoldoutType.env:
                m_foldout.env = !m_foldout.env;
                break;

            case FoldoutType.glow:
                m_foldout.glow = !m_foldout.glow;
                break;
            }
        }

        EditorGUIUtility.labelWidth = 70;

        EditorGUI.BeginChangeCheck();

        Material mat = target as Material;

        if (mat.HasProperty("_FaceShininess") == false || keyword != "BEVEL_ON") // Show Enable Toggle only if material is not Surface Shader.
        {
            toggle = EditorGUI.Toggle(new Rect(rect.width - 90, rect.y + 3, 90, 22), new GUIContent("Enable ->"), toggle);
            if (EditorGUI.EndChangeCheck())
            {
                SetKeyword(toggle, keyword);
                havePropertiesChanged = true;
            }
        }

        EditorGUIUtility.labelWidth = old_LabelWidth;
        EditorGUIUtility.fieldWidth = old_FieldWidth;

        return(toggle);
    }
    private bool DrawTogglePanel(FoldoutType type, string label, bool toggle, string keyword)
    {
        float labelWidth = EditorGUIUtility.labelWidth;
        float fieldWidth = EditorGUIUtility.fieldWidth;

        EditorGUI.indentLevel = 0;
        Rect controlRect = EditorGUILayout.GetControlRect(false, 22f);

        GUI.Label(controlRect, GUIContent.none, TMP_UIStyleManager.Group_Label);
        if (GUI.Button(new Rect(controlRect.x, controlRect.y, 250f, controlRect.height), label, TMP_UIStyleManager.Group_Label_Left))
        {
            switch (type)
            {
            case FoldoutType.outline:
                m_foldout.outline = !m_foldout.outline;
                break;

            case FoldoutType.underlay:
                m_foldout.underlay = !m_foldout.underlay;
                break;

            case FoldoutType.bevel:
                m_foldout.bevel = !m_foldout.bevel;
                break;

            case FoldoutType.light:
                m_foldout.light = !m_foldout.light;
                break;

            case FoldoutType.bump:
                m_foldout.bump = !m_foldout.bump;
                break;

            case FoldoutType.env:
                m_foldout.env = !m_foldout.env;
                break;

            case FoldoutType.glow:
                m_foldout.glow = !m_foldout.glow;
                break;
            }
        }
        EditorGUIUtility.labelWidth = 70f;
        EditorGUI.BeginChangeCheck();
        Material material = base.target as Material;

        if (!material.HasProperty("_FaceShininess") || keyword != "BEVEL_ON")
        {
            toggle = EditorGUI.Toggle(new Rect(controlRect.width - 90f, controlRect.y + 3f, 90f, 22f), new GUIContent("Enable ->"), toggle);
            if (EditorGUI.EndChangeCheck())
            {
                SetKeyword(toggle, keyword);
                havePropertiesChanged = true;
            }
        }
        EditorGUIUtility.labelWidth = labelWidth;
        EditorGUIUtility.fieldWidth = fieldWidth;
        return(toggle);
    }
    // Function to draw title + enable toggle options as well as setting keyword.
    private bool DrawTogglePanel(FoldoutType type, string label, bool toggle, string keyword)
    {
        float old_LabelWidth = EditorGUIUtility.labelWidth;
        float old_FieldWidth = EditorGUIUtility.fieldWidth;

        EditorGUI.indentLevel = 0;
        Rect rect = EditorGUILayout.GetControlRect(false, 22);
        GUI.Label(rect, GUIContent.none, TMP_UIStyleManager.Group_Label);
        if (GUI.Button(new Rect(rect.x, rect.y, 250, rect.height), label, TMP_UIStyleManager.Group_Label_Left))
        {
            switch (type)
            {
                case FoldoutType.underlay:
                    m_foldout.underlay = !m_foldout.underlay;
                    break;
                case FoldoutType.bevel:
                    m_foldout.bevel = !m_foldout.bevel;
                    break;
                case FoldoutType.light:
                    m_foldout.light = !m_foldout.light;
                    break;
                case FoldoutType.bump:
                    m_foldout.bump = !m_foldout.bump;
                    break;
                case FoldoutType.env:
                    m_foldout.env = !m_foldout.env;
                    break;
                case FoldoutType.glow:
                    m_foldout.glow = !m_foldout.glow;
                    break;
            }
        }

        EditorGUIUtility.labelWidth = 70;
      
        EditorGUI.BeginChangeCheck();

        Material mat = target as Material;

        if (mat.HasProperty("_FaceShininess") == false || keyword != "BEVEL_ON") // Show Enable Toggle only if material is not Surface Shader.
        {
            toggle = EditorGUI.Toggle(new Rect(rect.width - 90, rect.y + 3, 90, 22), new GUIContent("Enable ->"), toggle);
            if (EditorGUI.EndChangeCheck())
            {               
                SetKeyword(toggle, keyword);
                havePropertiesChanged = true;
            }
        }      

        EditorGUIUtility.labelWidth = old_LabelWidth;
        EditorGUIUtility.fieldWidth = old_FieldWidth;

        return toggle;
    }
	public CoherentExposePropertyInfo(FoldoutType category = FoldoutType.General)
	{
		this.Category = category;
	}
 public CoherentUIGTExposePropertyInfo(FoldoutType category)
 {
     this.Category = category;
 }