/// <summary> /// Save the specified info and fileName. /// </summary> /// <param name='info'> /// Info. /// </param> /// <param name='fileName'> /// File name. auto stub ".xml". /// If UNITY_EDITOR => Application.dataPath + fileName + ".xml". /// else => Application.persistentDataPath + fileName + ".xml". /// </param> static public void SaveToExternalFile(string fileName, ViNoSaveInfo info, FlagTable flagTable) { Save(info); /* * ViNoSaveData data = new ViNoSaveData(); * data.m_BgmName = info.m_BgmName; * data.m_CurrentScenarioName = info.m_CurrentScenarioName; * data.m_LoadedLevelIndex = info.m_LoadedLevelIndex; * data.m_LoadedLevelName = info.m_LoadedLevelName; * data.m_NodeName = info.m_NodeName; * data.m_SceneXmlData = info.m_SceneXmlData; * data.m_Date = info.m_Date; * data.m_ScenarioDescription = info.m_ScenarioDescription; * // data.m_ScenarioResourceFilePath = ScenarioNode.Instance.scenarioResourceFilePath; * //*/ string xmlStr = ViNoGameSaveLoad.SerializeObject <ViNoSaveData>(info.data); #if UNITY_WEBPLAYER PlayerPrefs.SetString(fileName + ".xml", xmlStr); #else ViNoGameSaveLoad.CreateXML(fileName + ".xml", xmlStr); #endif SaveFlagTable(fileName, flagTable); }
static public void SaveFlagTable(string fileName, FlagTable flagTable) { if (flagTable != null) { FlagTableData flagData = new FlagTableData(); flagData.flags = flagTable.flags; flagData.stringValues = flagTable.stringValues; string flagXmlStr = ViNoGameSaveLoad.SerializeObject <FlagTableData>(flagData); #if UNITY_WEBPLAYER PlayerPrefs.SetString(fileName + "Flag.xml", flagXmlStr); #else ViNoGameSaveLoad.CreateXML(fileName + "Flag.xml", flagXmlStr); #endif } }
static public void CreateANewScenario( ) { ScenarioNode[] scenariosInScene = GameObject.FindObjectsOfType(typeof(ScenarioNode)) as ScenarioNode[]; if (scenariosInScene.Length > 0) { } for (int i = 0; i < scenariosInScene.Length; i++) { scenariosInScene[i].gameObject.SetActive(false); } if (!System.IO.Directory.Exists("Assets/" + ViNoToolbar.m_ScenarioName)) { AssetDatabase.CreateFolder("Assets", ViNoToolbar.m_ScenarioName); } GameObject scenarioObj = ViNoToolUtil.CreateANewScenario(ViNoToolbar.m_ScenarioName, ViNoToolbar.m_StartAndPlay); GameObject startObj = scenarioObj.transform.Find("START").gameObject; EditorGUIUtility.PingObject(startObj); Selection.activeObject = startObj; ViNoToolbar.m_AddedObject = startObj; ViNoToolbar.m_Selected = 1; // Jump to Nodes Tab. ViNoToolbar.m_CurrScenarioNode = scenarioObj.GetComponent <ScenarioNode>(); if (ViNoToolbar.m_CurrScenarioNode == null) { Debug.Log("CurrScenario NULL"); } string scenarioFlagDataPath = "Assets/" + ViNoToolbar.m_ScenarioName + "/" + ViNoToolbar.m_ScenarioName + "Flags.asset"; string scenarioSaveDataPath = "Assets/" + ViNoToolbar.m_ScenarioName + "/" + ViNoToolbar.m_ScenarioName + "SaveData.asset"; FlagTable flagTable = ScriptableObjectUtility.CreateScriptableObject("FlagTable", scenarioFlagDataPath) as FlagTable; ScriptableObjectUtility.CreateScriptableObject("ViNoSaveInfo", scenarioSaveDataPath); ViNoToolbar.m_CurrScenarioNode.flagTable = flagTable; ViNoToolbar.m_CurrScenarioNode.startNode = startObj.GetComponent <ViNode>(); ViNoToolbar.m_CurrScenarioNode.m_PlayAtStart = true; //ViNoToolbar.m_StartAndPlay; ViNoToolbar.m_CurrScenarioNode = scenarioObj.GetComponent <ScenarioNode>(); // DrawViNodesTab.CreateDialogNodeOfMenu(); }
static public void CreateConvScene(string templScenePath) { GameObject sceneRoot = CreateTemplScene(templScenePath); sceneRoot.name = "A Conversation Scene"; string scenarioName = "A_Conversation"; if (!System.IO.Directory.Exists("Assets/" + scenarioName)) { AssetDatabase.CreateFolder("Assets", scenarioName); } GameObject scenarioObj = ViNoToolUtil.CreateANewScenario(scenarioName, true); GameObject startObj = scenarioObj.transform.FindChild("START").gameObject; // scenarioObj.transform.parent.transform.parent = sceneRoot.transform; GameObject node0 = new GameObject("0_Scene"); LoadSceneNode loadSceneNode = node0.AddComponent <LoadSceneNode>(); loadSceneNode.sceneName = "Scene1"; loadSceneNode.method = LoadSceneNode.Methods.DESTROY_AND_LOAD; loadSceneNode.withFadeIn = true; loadSceneNode.transform.parent = startObj.transform; DialogPartNode dlgNode = ViNoToolUtil.AddDialogPartNode(startObj.transform); dlgNode.name = "1_Dialog"; DialogPartData data0 = dlgNode.AddData("", ""); DialogPartData data1 = dlgNode.AddData("Sachi", "Hello. I am Sachi."); DialogPartData data2 = dlgNode.AddData("", ""); DialogPartData data3 = dlgNode.AddData("Maiko", "Hi. Sachi."); DialogPartData data4 = dlgNode.AddData("Sachi", "Bye Bye !"); DialogPartData data5 = dlgNode.AddData("Maiko", "Bye Bye !"); DialogPartData data6 = dlgNode.AddData("", ""); data0.enterActorEntries = new DialogPartData.ActorEntry[1]; data0.enterActorEntries[0] = new DialogPartData.ActorEntry(); data0.enterActorEntries[0].actorName = "Sachi"; data0.actionID = DialogPartNodeActionType.EnterActor; data0.enterActorEntries[0].position = ViNoToolkit.SceneEvent.ActorPosition.middle_left; data1.isName = true; data2.enterActorEntries = new DialogPartData.ActorEntry[1]; data2.enterActorEntries[0] = new DialogPartData.ActorEntry(); data2.enterActorEntries[0].actorName = "Maiko"; data2.actionID = DialogPartNodeActionType.EnterActor; data2.enterActorEntries[0].position = ViNoToolkit.SceneEvent.ActorPosition.middle_right; data3.isName = true; data4.isName = true; data5.isName = true; data6.actionID = DialogPartNodeActionType.ExitActor; data6.exitActorEntries = new DialogPartData.ActorEntry[2]; data6.exitActorEntries[0] = new DialogPartData.ActorEntry(); data6.exitActorEntries[1] = new DialogPartData.ActorEntry(); data6.exitActorEntries[0].actorName = "Sachi"; data6.exitActorEntries[1].actorName = "Maiko"; #if false GameObject parentObj = GameObject.Find("Panels"); DrawObjectsTab.CreateBG("BG", parentObj); GameObject ch1 = DrawObjectsTab.Create2Layer("Ch1", parentObj); GameObject ch2 = DrawObjectsTab.Create2Layer("Ch2", parentObj); ch1.transform.localPosition = new Vector3(-120f, 0f, 0f); ch2.transform.localPosition = new Vector3(120f, 0f, 0f); AssetDatabase.MoveAsset("Assets/BG", "Assets/" + scenarioName + "/BG"); AssetDatabase.MoveAsset("Assets/Ch1", "Assets/" + scenarioName + "/Ch1"); AssetDatabase.MoveAsset("Assets/Ch2", "Assets/" + scenarioName + "/Ch2"); #endif string scenarioFlagDataPath = "Assets/" + scenarioName + "/" + scenarioName + "Flags.asset"; string scenarioSaveDataPath = "Assets/" + scenarioName + "/" + scenarioName + "SaveData.asset"; FlagTable flagTable = ScriptableObjectUtility.CreateScriptableObject("FlagTable", scenarioFlagDataPath) as FlagTable; ViNoSaveInfo saveInfo = ScriptableObjectUtility.CreateScriptableObject("ViNoSaveInfo", scenarioSaveDataPath) as ViNoSaveInfo; ScenarioNode scenarioNode = scenarioObj.GetComponent <ScenarioNode>(); scenarioNode.m_PlayAtStart = true; scenarioNode.flagTable = flagTable; // scenarioNode.saveInfo = saveInfo; ScenarioCtrl scenarioCtrl = GameObject.FindObjectOfType(typeof(ScenarioCtrl)) as ScenarioCtrl; scenarioCtrl.quickSaveSlot = saveInfo; scenarioCtrl.saveInfo = saveInfo; // Create an ActorLibrary and a SceneLibrary. string actorLibPrefabPath = "Assets/" + scenarioName + "/ActorLibrary.prefab"; string sceneLibPrefabPath = "Assets/" + scenarioName + "/SceneLibrary.prefab"; ViNoScenarioDataUtil.CreateActorLibrary(actorLibPrefabPath); ViNoScenarioDataUtil.CreateSceneLibrary(sceneLibPrefabPath); GameObject.DestroyImmediate(GameObject.Find("ActorLibrary")); GameObject.DestroyImmediate(GameObject.Find("SceneLibrary")); // ViNoToolkit.ActorInfo actor1 = ViNoScenarioDataUtil.CreateActorInfo() as ViNoToolkit.ActorInfo; ViNoToolkit.SceneEvent sceneEvt = GameObject.FindObjectOfType(typeof(ViNoToolkit.SceneEvent)) as ViNoToolkit.SceneEvent; ViNoToolkit.ActorLibrary actorLib = AssetDatabase.LoadAssetAtPath(actorLibPrefabPath, typeof(ViNoToolkit.ActorLibrary)) as ViNoToolkit.ActorLibrary; ViNoToolkit.SceneLibrary sceneLib = AssetDatabase.LoadAssetAtPath(sceneLibPrefabPath, typeof(ViNoToolkit.SceneLibrary)) as ViNoToolkit.SceneLibrary; /* actorLib.actorEntries = new ViNoToolkit.ActorInfo[ 1 ]; * actorLib.actorEntries[ 0 ] = actor1; * //*/ sceneEvt.actorLib = actorLib; sceneEvt.sceneLib = sceneLib; }
public override void OnInspectorGUI() { FlagTable flagTable = target as FlagTable; // m_ShowBoolean = EditorGUILayout.BeginToggleGroup( "Edit" , m_ShowBoolean ); if (EditorGUIUtility.isProSkin) { GUICommon.DrawLineSpace(5f, 15f); } else { GUICommon.DrawLineSpace(5f, 5f); } m_ShowBoolean = EditorGUILayout.Foldout(m_ShowBoolean, "Passed Labels"); if (m_ShowBoolean) { if (flagTable.flags == null || flagTable.flags.Length == 0) { flagTable.flags = new FlagTable.FlagUnit[1]; flagTable.flags[0] = new FlagTable.FlagUnit(); } if (flagTable.stringValues == null || flagTable.stringValues.Length == 0) { flagTable.stringValues = new FlagTable.VarUnit <string> [1]; flagTable.stringValues[0] = new FlagTable.VarUnit <string>(); } if (flagTable.floatValues == null || flagTable.floatValues.Length == 0) { flagTable.floatValues = new FlagTable.VarUnit <float> [1]; flagTable.floatValues[0] = new FlagTable.VarUnit <float>(); } EditorGUILayout.BeginHorizontal(); GUILayout.Space(15f); EditorGUILayout.LabelField("FlagName"); EditorGUILayout.LabelField("State", GUILayout.Width(34f)); EditorGUILayout.EndHorizontal(); for (int i = 0; i < flagTable.flags.Length; i++) { EditorGUILayout.BeginHorizontal(); GUILayout.Space(15f); // EditorGUILayout.LabelField( "FlagState" , GUILayout.Width( 80f ) ); flagTable.flags[i].m_FlagName = EditorGUILayout.TextField(flagTable.flags[i].m_FlagName); flagTable.flags[i].m_IsFlagOn = EditorGUILayout.Toggle(flagTable.flags[i].m_IsFlagOn, GUILayout.Width(34f)); // EditorGUILayout.EndHorizontal(); // EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { ArrayUtility.Insert <FlagTable.FlagUnit>(ref flagTable.flags, i + 1, new FlagTable.FlagUnit()); } if (GUILayout.Button("-")) { ArrayUtility.RemoveAt <FlagTable.FlagUnit>(ref flagTable.flags, i); } EditorGUILayout.EndHorizontal(); } /* EditorGUILayout.BeginHorizontal(); * * if( flagTable.flags != null && flagTable.flags.Length > 0 ) { * if( GUILayout.Button( "+" ) ){ * ArrayUtility.Add<FlagTable.FlagUnit>( ref flagTable.flags , new FlagTable.FlagUnit() ); * } * * if( GUILayout.Button( "-" ) ){ * int lastIndex = flagTable.flags.Length - 1; * FlagTable.FlagUnit lastOne = flagTable.flags[ lastIndex ]; * ArrayUtility.Remove<FlagTable.FlagUnit>( ref flagTable.flags , lastOne ); * } * } * * EditorGUILayout.EndHorizontal(); */ } #if false if (EditorGUIUtility.isProSkin) { GUICommon.DrawLineSpace(5f, 15f); } else { GUICommon.DrawLineSpace(5f, 5f); } m_ShowString = EditorGUILayout.Foldout(m_ShowString, "Strings"); if (m_ShowString) { EditorGUILayout.BeginHorizontal(); GUILayout.Space(15f); EditorGUILayout.LabelField("VariableName", GUILayout.Width(100f)); EditorGUILayout.LabelField("StringValues"); EditorGUILayout.EndHorizontal(); for (int i = 0; i < flagTable.stringValues.Length; i++) { EditorGUILayout.BeginHorizontal(); GUILayout.Space(15f); flagTable.stringValues[i].m_FlagName = EditorGUILayout.TextField(flagTable.stringValues[i].m_FlagName, GUILayout.Width(100f)); flagTable.stringValues[i].theValue = EditorGUILayout.TextField(flagTable.stringValues[i].theValue); if (GUILayout.Button("+")) { ArrayUtility.Insert <FlagTable.VarUnit <string> >(ref flagTable.stringValues, i + 1, new FlagTable.VarUnit <string>()); } if (GUILayout.Button("-")) { ArrayUtility.RemoveAt <FlagTable.VarUnit <string> >(ref flagTable.stringValues, i); } EditorGUILayout.EndHorizontal(); } } #endif // This is Test. #if false GUICommon.DrawLineSpace(10f, 5f); m_ShowFloat = EditorGUILayout.Foldout(m_ShowFloat, "Floats"); if (m_ShowFloat) { EditorGUILayout.BeginHorizontal(); GUILayout.Space(15f); EditorGUILayout.LabelField("FloatValues", GUILayout.Width(100f)); EditorGUILayout.LabelField("VariableName"); EditorGUILayout.EndHorizontal(); for (int i = 0; i < flagTable.floatValues.Length; i++) { EditorGUILayout.BeginHorizontal(); GUILayout.Space(15f); flagTable.floatValues[i].floatValue = EditorGUILayout.FloatField(flagTable.floatValues[i].floatValue, GUILayout.Width(65f)); flagTable.floatValues[i].m_FlagName = EditorGUILayout.TextField(flagTable.floatValues[i].m_FlagName); if (GUILayout.Button("+")) { ArrayUtility.Insert <FlagTable.VarFloatUnit>(ref flagTable.floatValues, i + 1, new FlagTable.VarFloatUnit()); } if (GUILayout.Button("-")) { ArrayUtility.RemoveAt <FlagTable.VarFloatUnit>(ref flagTable.floatValues, i); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); /* if( flagTable.floatValues != null && flagTable.floatValues.Length > 0 ) { * if( GUILayout.Button( "+" ) ){ * ArrayUtility.Add<FlagTable.VarFloatUnit>( ref flagTable.floatValues , new FlagTable.VarFloatUnit() ); * } * * if( GUILayout.Button( "-" ) ){ * int lastIndex = flagTable.floatValues.Length - 1; * FlagTable.VarFloatUnit lastOne = flagTable.floatValues[ lastIndex ]; * ArrayUtility.Remove<FlagTable.VarFloatUnit>( ref flagTable.floatValues , lastOne ); * } * } * //*/ EditorGUILayout.EndHorizontal(); } #endif if (GUILayout.Button("Clear Flags")) { bool yes = EditorUtility.DisplayDialog(" ! ", "Are you sure you want to ClearFlags?", "yes", "no"); if (yes) { flagTable.ClearFlags(); } } // EditorGUILayout.EndToggleGroup(); if (GUI.changed) { EditorUtility.SetDirty(target); } }