Esempio n. 1
0
 //draws presets if exists
 public void drawPresets(MaterialProperty[] props, Material[] materials)
 {
     if (hasPresets && presetsLoaded)
     {
         int pressetPreset = EditorGUILayout.Popup(selectedPreset, presetOptions, GUILayout.MaxWidth(100));
         if (pressetPreset != selectedPreset)
         {
             ;
             if (pressetPreset < presetOptions.Length - 2)
             {
                 applyPreset(presetOptions[pressetPreset], props, materials);
             }
             if (pressetPreset == presetOptions.Length - 2)
             {
                 PresetEditor.open();
             }
         }
         if (pressetPreset == presetOptions.Length - 1)
         {
             selectedPreset = pressetPreset;
         }
         else
         {
             selectedPreset = 0;
         }
         if (pressetPreset == presetOptions.Length - 1)
         {
             drawNewPreset(props, materials);
         }
     }
     else if (hasPresets && !presetsLoaded)
     {
         GUILayout.Label("Presets File Missing");
     }
 }
            void OnGUI()
            {
                GUILayout.Label(Locale.editor.Get("presets"), EditorStyles.boldLabel);

                if (GUILayout.Button(Locale.editor.Get("manage_presets")))
                {
                    PresetEditor.open();
                }
                presetHandler.drawNewPreset();

                float listMaxHeight = this.position.height - 30;

                scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.MaxHeight(listMaxHeight));
                for (int i = 0; i < presetHandler.presetOptions.Length; i++)
                {
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button(Locale.editor.Get("apply_preset")))
                    {
                        presetHandler.applyPreset(presetHandler.presetOptions[i], presetHandler.props, presetHandler.materials);
                    }
                    EditorGUILayout.LabelField(presetHandler.presetOptions[i]);
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndScrollView();
                if (GUI.Button(new Rect(0, this.position.height - 30, this.position.width, 30), "Close"))
                {
                    this.Close();
                }
            }