public void DrawSerializationSettings() { Color tmp1 = GUI.color; showSerializationSettings = GUILayoutx.BeginFadeArea (showSerializationSettings,"serializationSettings",20,EditorGUILayoutx.defaultAreaStyle); Color tmp2 = GUI.color; GUI.color = tmp1; GUILayout.BeginHorizontal (); if (GUILayout.Button ("Save & Load",EditorGUILayoutx.defaultLabelStyle)) { showSerializationSettings = !showSerializationSettings; GUI.changed = true; } if (script.astarData.cacheStartup && script.astarData.data_cachedStartup != null && script.astarData.data_cachedStartup.Length > 0) { tmp1 *= Color.yellow; GUI.color = tmp1; GUILayout.Label ("Startup cached",thinHelpBox,GUILayout.Height (15)); GUILayout.Space (20); } GUI.color = tmp2; GUILayout.EndHorizontal (); /** This displays the values of the serialization bitmask (what to save). Any values which has not got a name will be set to zero */ EditorGUI.indentLevel++; for (int i=0;i<32;i++) { string bitName = AstarSerializer.SMask.BitName (i); //Bit is not used if (bitName == null) { serializationMask &= ~(1 << i); continue; } serializationMask = (serializationMask & ~(1 << i)) | (EditorGUILayout.Toggle (bitName,(serializationMask >> i & 1) != 0) ? 1 : 0) << i; } EditorGUI.indentLevel--; GUILayout.Space (5); bool preEnabled = GUI.enabled; script.astarData.cacheStartup = EditorGUILayout.Toggle (new GUIContent ("Cache startup","If enabled, will cache the graphs so they don't have to be scanned at startup"),script.astarData.cacheStartup); EditorGUILayout.LabelField ("Cache size",(script.astarData.data_cachedStartup != null ? EditorUtility.FormatBytes (script.astarData.data_cachedStartup.Length) : "null")); GUILayout.BeginHorizontal (); if (GUILayout.Button ("Generate cache")) { if (EditorUtility.DisplayDialog ("Scan before generating cache?","Do you want to scan the graphs before saving the cache","Scan","Don't scan")) { #if UNITY_EDITOR AstarPath.MenuScan (); #endif } script.astarData.SaveCacheData (serializationMask); } GUI.enabled = script.astarData.data_cachedStartup != null; if (GUILayout.Button ("Load from cache")) { if (EditorUtility.DisplayDialog ("Are you sure you want to load from cache?","Are you sure you want to load graphs from the cache, this will replace your current graphs?","Yes","Cancel")) { script.astarData.LoadFromCache (); } } GUILayout.EndHorizontal (); if (GUILayout.Button ("Clear Cache", GUILayout.MaxWidth (120))) { script.astarData.data_cachedStartup = null; } GUI.enabled = preEnabled; GUILayout.Label ("When using 'cache startup', the 'Nodes' toggle should always be enabled otherwise the graphs' nodes won't be saved and the caching is quite useless",helpBox); /*GUI.enabled = false; script.astarData.compress = EditorGUILayout.Toggle ("Compress",false);//script.astarData.compress); GUI.enabled = preEnabled;*/ GUILayout.Space (5); GUILayout.BeginHorizontal (); if (GUILayout.Button ("Save to file")) { string path = EditorUtility.SaveFilePanel ("Save Graphs","","myGraph.graph","graph"); if (path != "") { AstarSerializer serializer = new AstarSerializer (script); serializer.mask = serializationMask; byte[] bytes = SerializeGraphs (serializer); serializer.SaveToFile (path,bytes); } } if (GUILayout.Button ("Load from file")) { string path = EditorUtility.OpenFilePanel ("Load Graphs","","graph"); if (path != "") { AstarSerializer serializer = new AstarSerializer (script); byte[] bytes = serializer.LoadFromFile (path); if (bytes != null) { DeserializeGraphs (serializer,bytes); CheckGraphEditors (); } else { Debug.Log ("Error deserializing graph : "+serializer.error); } } } GUILayout.EndHorizontal (); GUILayoutx.EndFadeArea (); }