private void GUISavePreset() { if (GUILayout.Button("Save To Preset", GUILayout.ExpandWidth(true))) { PresetData.Save(saveData); } }
public override void OnInspectorGUI() { PresetData presetData = serializedObject.targetObject as PresetData; if (presetData == null) { return; } EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("PresetTool Texture", GUILayout.Width(110.0f)); presetData.texture = EditorGUILayout.ObjectField(presetData.texture, typeof(Texture2D), false) as Texture2D; } EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(presetData); } float size = ((Screen.width > Screen.height) ? Screen.height : Screen.width) - 30.0f; EditorGUILayout.LabelField(new GUIContent(presetData.texture), GUILayout.Width(size), GUILayout.Height(size)); }
private void GUIPresetButton() { if (presetList == null || presetList.Count == 0) { return; } int xCount = (int)(Screen.width / 100.0f); if (xCount > presetList.Count) { xCount = presetList.Count; } float size = Screen.width / xCount; if (buttonStyle == null) { buttonStyle = new GUIStyle("Button"); buttonStyle.margin = new RectOffset(0, 0, 0, 0); buttonStyle.padding = new RectOffset(3, 3, 3, 3); //buttonStyle.border = new RectOffset(0,0,0,0); } scrollViewPos = GUILayout.BeginScrollView(scrollViewPos, false, false, GUIStyle.none, GUIStyle.none); { int index = 0; GUIContent content = null; for (int i = 0; i < presetList.Count; ++i) { GUILayout.BeginHorizontal(); { for (int k = 0; k < xCount; ++k) { index = (i * xCount) + k; if (index >= presetList.Count) { break; } PresetData presetData = presetList[index]; if (presetData.texture == null) { content = new GUIContent(presetData.name); } else { content = new GUIContent(presetData.texture); } if (GUILayout.Button(content, buttonStyle, GUILayout.Width(size), GUILayout.Height(size))) { OnBtn(presetData); } } } GUILayout.EndHorizontal(); } } GUILayout.EndScrollView(); }
public static void Save(SaveData saveData) { #if UNITY_EDITOR PresetData presetData = ScriptableObject.CreateInstance <PresetData>(); presetData.LoadFromSaveData(saveData); string filePath = string.Format("{0}/Preset/PresetData_{1}_{2}.asset", PathEF.assetPath, saveData.GetHashCode(), UnityEngine.Random.Range(int.MinValue, int.MaxValue)); UnityEditor.AssetDatabase.CreateAsset(presetData, filePath); UnityEditor.AssetDatabase.SaveAssets(); UnityEditor.AssetDatabase.Refresh(); #endif }
private void OnBtn(PresetData presetData) { if (presetData != null) { Undo.RecordObject(selectedEasyflow.saveData, "NAsoft_EasyFlow_Undo_Point"); presetData.LoadToSaveData(ref selectedEasyflow.saveData); selectedEasyflow.Init(); selectedEasyflow.Init(); selectedEasyflow.InitTexture(); EditorUtility.SetDirty(selectedEasyflow); EditorUtility.SetDirty(selectedEasyflow.saveData); } }