本文整理汇总了C#中Pathfinding.AstarSerializer.SaveToFile方法的典型用法代码示例。如果您正苦于以下问题:C# AstarSerializer.SaveToFile方法的具体用法?C# AstarSerializer.SaveToFile怎么用?C# AstarSerializer.SaveToFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pathfinding.AstarSerializer
的用法示例。
在下文中一共展示了AstarSerializer.SaveToFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawSerializationSettings
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");
//.........这里部分代码省略.........