Пример #1
0
 public void StructGUI(PresetsPopupGUI popupGUI, bool reapply)
 {
     if (preset != null)
     {
         EditorGUI.BeginChangeCheck();
         isOn = EditorGUILayout.ToggleLeft(name, isOn);
         if (EditorGUI.EndChangeCheck())
         {
             popupGUI.Revert();
             popupGUI.reapply = true;
         }
         if (reapply && isOn)
         {
             Presets.Apply(preset, popupGUI.shaderEditor);
         }
     }
     foreach (KeyValuePair <string, PresetStruct> struc in dict)
     {
         Rect r = GUILayoutUtility.GetRect(new GUIContent(), Styles.dropDownHeader);
         r.x      = EditorGUI.indentLevel * 15;
         r.width -= r.x;
         GUI.Box(r, struc.Key, Styles.dropDownHeader);
         if (Event.current.type == EventType.Repaint)
         {
             var toggleRect = new Rect(r.x + 4f, r.y + 2f, 13f, 13f);
             EditorStyles.foldout.Draw(toggleRect, false, false, struc.Value.isOpen, false);
         }
         if (Event.current.type == EventType.MouseDown && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
         {
             struc.Value.isOpen = !struc.Value.isOpen;
             ShaderEditor.input.Use();
         }
         if (struc.Value.isOpen)
         {
             EditorGUI.indentLevel += 1;
             struc.Value.StructGUI(popupGUI, reapply);
             EditorGUI.indentLevel -= 1;
         }
     }
 }