Example #1
0
        private void UpdatePresetField()
        {
            var presetParent = rootVisualElement.Q <VisualElement>("Preset");

            presetParent.Clear();
            PresetData.LoadPresets(this.currentTypeInfo.type, this.presetList);

            if (this.presetList.Count > 0)
            {
                presetPopup = new PopupField <PresetData>(this.presetList, 0, PresetDataToString, PresetDataToString);

#if UNITY_2019_1_OR_NEWER || UNITY_2019_OR_NEWER
                presetPopup.RegisterValueChangedCallback((val) =>
                {
                    this.currentPreset = val.newValue;
                });
#else
                presetPopup.OnValueChanged((val) =>
                {
                    this.currentPreset = val.newValue;
                });
#endif

                currentPreset = this.presetList[0];
                presetParent.Add(presetPopup);
            }
        }
Example #2
0
        public static bool ApplyPreset <T>(string preset)
        {
            if (!PresetData.IsPresetExists(preset, typeof(T)))
            {
                return(false);
            }

            return(true);
        }
Example #3
0
 public static void SaveToPresetData(object obj, string name)
 {
     if (string.IsNullOrEmpty(name))
     {
         EditorUtility.DisplayDialog("No preset name", "Please input preset name", "ok");
         return;
     }
     if (PresetData.IsPresetExists(name, obj.GetType()))
     {
         bool res = EditorUtility.DisplayDialog("Overwrite?", "Preset " + name + " is already exist.overwrite?", "ok", "cancel");
     }
     PresetData.SavePreset(name, obj);
 }
Example #4
0
 private static string PresetDataToString(PresetData data)
 {
     return(data.name);
 }