static tk2dPreferences Load() { tk2dPreferences returnValue = null; string keyName = "tk2dPreferences"; if (EditorPrefs.HasKey(keyName)) { try { string s = EditorPrefs.GetString(keyName, ""); if (s.Length > 0) { System.IO.MemoryStream ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(s)); System.Xml.XmlReader reader = new System.Xml.XmlTextReader(ms); System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(tk2dPreferences)); returnValue = (tk2dPreferences)x.Deserialize(reader); } } catch { } } if (returnValue == null) { returnValue = new tk2dPreferences(); } return(returnValue); }
void OnGUI() { tk2dPreferences prefs = tk2dPreferences.inst; EditorGUIUtility.LookLikeControls(150.0f); prefs.displayTextureThumbs = EditorGUILayout.Toggle(label_spriteThumbnails, prefs.displayTextureThumbs); int had = EditorGUILayout.Popup(label_animationFrames, prefs.horizontalAnimDisplay?0:1, new GUIContent[] { label_animFrames_Horizontal, label_animFrames_Vertical }); prefs.horizontalAnimDisplay = (had == 0)?true:false; EditorGUILayout.Toggle(label_groupAnimDisplay, prefs.groupAnimDisplay); int newNumGroupedAnimationFrames = EditorGUILayout.IntField(label_numGroupedAnimationFrames, prefs.numGroupedAnimationFrames); prefs.numGroupedAnimationFrames = Mathf.Max(newNumGroupedAnimationFrames, 30); // sanity check prefs.autoRebuild = EditorGUILayout.Toggle(label_autoRebuild, prefs.autoRebuild); prefs.showIds = EditorGUILayout.Toggle(label_showIds, prefs.showIds); if (GUILayout.Button("Reset Sprite Collection Editor Sizes")) { prefs.spriteCollectionListWidth = tk2dPreferences.default_spriteCollectionListWidth; prefs.spriteCollectionInspectorWidth = tk2dPreferences.default_spriteCollectionInspectorWidth; } #if (UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4) prefs.isProSkin = EditorGUILayout.Toggle(label_proSkin, prefs.isProSkin); #endif }
void OnGUI() { tk2dPreferences prefs = tk2dPreferences.inst; EditorGUIUtility.LookLikeControls(150.0f); prefs.displayTextureThumbs = EditorGUILayout.Toggle(label_spriteThumbnails, prefs.displayTextureThumbs); int had = EditorGUILayout.Popup(label_animationFrames, prefs.horizontalAnimDisplay?0:1, new GUIContent[] { label_animFrames_Horizontal, label_animFrames_Vertical }); prefs.horizontalAnimDisplay = (had == 0)?true:false; }
void OnGUI() { tk2dPreferences prefs = tk2dPreferences.inst; EditorGUIUtility.LookLikeControls(150.0f); prefs.displayTextureThumbs = EditorGUILayout.Toggle(label_spriteThumbnails, prefs.displayTextureThumbs); int had = EditorGUILayout.Popup(label_animationFrames, prefs.horizontalAnimDisplay?0:1, new GUIContent[] { label_animFrames_Horizontal, label_animFrames_Vertical }); prefs.horizontalAnimDisplay = (had == 0)?true:false; EditorGUILayout.Toggle(label_groupAnimDisplay, prefs.groupAnimDisplay); int newNumGroupedAnimationFrames = EditorGUILayout.IntField(label_numGroupedAnimationFrames, prefs.numGroupedAnimationFrames); prefs.numGroupedAnimationFrames = Mathf.Max(newNumGroupedAnimationFrames, 30); // sanity check prefs.autoRebuild = EditorGUILayout.Toggle(label_autoRebuild, prefs.autoRebuild); prefs.showIds = EditorGUILayout.Toggle(label_showIds, prefs.showIds); if (GUILayout.Button("Reset Editor Sizes")) { prefs.spriteCollectionListWidth = tk2dPreferences.default_listWidth; prefs.spriteCollectionInspectorWidth = tk2dPreferences.default_InspectorWidth; prefs.animListWidth = tk2dPreferences.default_listWidth; prefs.animInspectorWidth = tk2dPreferences.default_InspectorWidth; prefs.animFrameWidth = -1; } if (tk2dSystem.inst_NoCreate != null) { string newPlatform = tk2dGuiUtility.PlatformPopup(tk2dSystem.inst_NoCreate, "Platform", prefs.platform); if (newPlatform != prefs.platform) { prefs.platform = newPlatform; tk2dEditorUtility.UnloadUnusedAssets(); } } #if (UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4) prefs.isProSkin = EditorGUILayout.Toggle(label_proSkin, prefs.isProSkin); #endif }
void OnGUI() { tk2dPreferences prefs = tk2dPreferences.inst; EditorGUIUtility.LookLikeControls(150.0f); prefs.displayTextureThumbs = EditorGUILayout.Toggle(label_spriteThumbnails, prefs.displayTextureThumbs); int had = EditorGUILayout.Popup(label_animationFrames, prefs.horizontalAnimDisplay?0:1, new GUIContent[] { label_animFrames_Horizontal, label_animFrames_Vertical }); prefs.horizontalAnimDisplay = (had == 0)?true:false; prefs.autoRebuild = EditorGUILayout.Toggle(label_autoRebuild, prefs.autoRebuild); prefs.showIds = EditorGUILayout.Toggle(label_showIds, prefs.showIds); #if (UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4) prefs.isProSkin = EditorGUILayout.Toggle(label_proSkin, prefs.isProSkin); #endif }
static tk2dPreferences Load() { tk2dPreferences returnValue = null; string keyName = "tk2dPreferences"; if (EditorPrefs.HasKey(keyName)) { try { string s = EditorPrefs.GetString(keyName, ""); if (s.Length > 0) { System.IO.MemoryStream ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(s)); System.Xml.XmlReader reader = new System.Xml.XmlTextReader(ms); System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(tk2dPreferences)); returnValue = (tk2dPreferences)x.Deserialize(reader); } } catch { } } if (returnValue == null) { returnValue = new tk2dPreferences(); } return returnValue; }
void OnGUI() { tk2dPreferences prefs = tk2dPreferences.inst; scroll = GUILayout.BeginScrollView(scroll, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); EditorGUIUtility.LookLikeControls(150.0f); prefs.displayTextureThumbs = EditorGUILayout.Toggle(label_spriteThumbnails, prefs.displayTextureThumbs); prefs.displayEditSpriteButton = EditorGUILayout.Toggle(label_displayEditButton, prefs.displayEditSpriteButton); prefs.autoRebuild = EditorGUILayout.Toggle(label_autoRebuild, prefs.autoRebuild); prefs.showIds = EditorGUILayout.Toggle(label_showIds, prefs.showIds); prefs.gridType = (tk2dGrid.Type)EditorGUILayout.EnumPopup("Grid Type", prefs.gridType); if (prefs.gridType == tk2dGrid.Type.Custom) { EditorGUI.indentLevel++; prefs.customGridColor0 = EditorGUILayout.ColorField("Color 0", prefs.customGridColor0); prefs.customGridColor1 = EditorGUILayout.ColorField("Color 1", prefs.customGridColor1); EditorGUI.indentLevel--; } GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(" "); Rect r = GUILayoutUtility.GetRect(64, 64); GUILayout.FlexibleSpace(); tk2dGrid.Draw(r); GUILayout.EndHorizontal(); if (GUILayout.Button("Reset Editor Sizes")) { prefs.spriteCollectionListWidth = tk2dPreferences.Defaults.spriteCollectionListWidth; prefs.spriteCollectionInspectorWidth = tk2dPreferences.Defaults.spriteCollectionInspectorWidth; prefs.animListWidth = tk2dPreferences.Defaults.animListWidth; prefs.animInspectorWidth = tk2dPreferences.Defaults.animInspectorWidth; prefs.animFrameWidth = tk2dPreferences.Defaults.animFrameWidth; GUI.changed = true; } if (tk2dSystem.inst_NoCreate != null) { string newPlatform = tk2dGuiUtility.PlatformPopup(tk2dSystem.inst_NoCreate, "Platform", prefs.platform); if (newPlatform != prefs.platform) { prefs.platform = newPlatform; tk2dSystem.CurrentPlatform = prefs.platform; // mirror to where it matters tk2dSystemUtility.PlatformChanged(); // tell the editor things have changed tk2dEditorUtility.UnloadUnusedAssets(); } } #if (UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4) prefs.isProSkin = EditorGUILayout.Toggle(label_proSkin, prefs.isProSkin); #endif GUILayout.EndScrollView(); if (GUI.changed) { tk2dPreferences.inst.Save(); } }
void OnGUI() { tk2dPreferences prefs = tk2dPreferences.inst; scroll = GUILayout.BeginScrollView(scroll, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); EditorGUIUtility.LookLikeControls(150.0f); prefs.displayTextureThumbs = EditorGUILayout.Toggle(label_spriteThumbnails, prefs.displayTextureThumbs); prefs.autoRebuild = EditorGUILayout.Toggle(label_autoRebuild, prefs.autoRebuild); prefs.showIds = EditorGUILayout.Toggle(label_showIds, prefs.showIds); prefs.gridType = (tk2dGrid.Type)EditorGUILayout.EnumPopup("Grid Type", prefs.gridType); if (prefs.gridType == tk2dGrid.Type.Custom) { EditorGUI.indentLevel++; prefs.customGridColor0 = EditorGUILayout.ColorField("Color 0", prefs.customGridColor0); prefs.customGridColor1 = EditorGUILayout.ColorField("Color 1", prefs.customGridColor1); EditorGUI.indentLevel--; } GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(" "); Rect r = GUILayoutUtility.GetRect(64, 64); GUILayout.FlexibleSpace(); tk2dGrid.Draw(r); GUILayout.EndHorizontal(); if (GUILayout.Button("Reset Editor Sizes")) { prefs.spriteCollectionListWidth = tk2dPreferences.Defaults.spriteCollectionListWidth; prefs.spriteCollectionInspectorWidth = tk2dPreferences.Defaults.spriteCollectionInspectorWidth; prefs.animListWidth = tk2dPreferences.Defaults.animListWidth; prefs.animInspectorWidth = tk2dPreferences.Defaults.animInspectorWidth; prefs.animFrameWidth = tk2dPreferences.Defaults.animFrameWidth; GUI.changed = true; } if (tk2dSystem.inst_NoCreate != null) { string newPlatform = tk2dGuiUtility.PlatformPopup(tk2dSystem.inst_NoCreate, "Platform", prefs.platform); if (newPlatform != prefs.platform) { prefs.platform = newPlatform; UnityEditor.EditorPrefs.SetString("tk2d_platform", newPlatform); tk2dSystem.CurrentPlatform = prefs.platform; // mirror to where it matters tk2dSystemUtility.PlatformChanged(); // tell the editor things have changed tk2dEditorUtility.UnloadUnusedAssets(); } } prefs.enableSpriteHandles = EditorGUILayout.Toggle(label_enableSpriteHandles, prefs.enableSpriteHandles); bool oldGuiEnable = GUI.enabled; GUI.enabled = prefs.enableSpriteHandles; EditorGUI.indentLevel++; prefs.enableMoveHandles = EditorGUILayout.Toggle(label_enableMoveHandles, prefs.enableMoveHandles); EditorGUI.indentLevel--; GUI.enabled = oldGuiEnable; EditorGUILayout.LabelField("Tilemap Paint Mode Colors"); ++EditorGUI.indentLevel; EditorGUI.BeginChangeCheck(); prefs.tileMapToolColor_brush = EditorGUILayout.ColorField("Brush", prefs.tileMapToolColor_brush); prefs.tileMapToolColor_brushRandom = EditorGUILayout.ColorField("Random", prefs.tileMapToolColor_brushRandom); prefs.tileMapToolColor_erase = EditorGUILayout.ColorField("Erase", prefs.tileMapToolColor_erase); prefs.tileMapToolColor_eyedropper = EditorGUILayout.ColorField("Eyedropper", prefs.tileMapToolColor_eyedropper); prefs.tileMapToolColor_cut = EditorGUILayout.ColorField("Cut", prefs.tileMapToolColor_cut); if (EditorGUI.EndChangeCheck()) { updateTilemapCursorColor = true; } --EditorGUI.indentLevel; GUILayout.EndScrollView(); if (GUI.changed) { tk2dPreferences.inst.Save(); } }