public static AdvPrefabUpdateResult OpenWindow(Fungus.FlowchartExtend flowchart, List <AdvCSVLine> result) { var window = GetWindow <AdvPrefabUpdateResult>(); window.sourceObject = flowchart; window.willRemove = result; return(window); }
public static void RebuildCSVLine(Fungus.FlowchartExtend sourceObject) { AdvUtility.RebuildCSVLine(sourceObject); AdvUtility.AutoLinkCSVLine(sourceObject); UnityEditor.EditorUtility.SetDirty(sourceObject.gameObject); Debug.Log("Rebuild CSVLine & Link Block Success"); }
public static void AutoLinkCSVLine(Fungus.FlowchartExtend sourceObject) { if (sourceObject == null) { return; } List <AdvCSVLine> csvLineData = sourceObject.csvLines; List <AdvCSVLine> csvLineBlocks = new List <AdvCSVLine>(); //Get base CSV info foreach (var item in csvLineData) { if (item.Command.StartsWith("*")) { csvLineBlocks.Add(item); } } //Start auto link List <Fungus.Command> comps = new List <Fungus.Command>(sourceObject.GetComponents <Fungus.Command>()); for (int i = 0; i < csvLineData.Count; i++) { for (int j = comps.Count - 1; j >= 0; j--) { ICommand icmd = comps[j] as ICommand; if (icmd != null && csvLineData[i].keys == icmd.CSVCommandKey) { //if(csvLineData[i].generatedCommand == null) Debug.Log($"Find unlink CSVLine ,will be linked :{csvLineData[i].keys}"); csvLineData[i].generatedCommand = comps[j]; comps.RemoveAt(j); break; } } } foreach (var item in csvLineBlocks) { if (item.generateBlock == null) { Fungus.Block _block = sourceObject.FindBlock(item.Command); if (_block != null) { item.generateBlock = _block; } } } }
void UpdateData(string Result) { string sourceCSV = Result; Fungus.FlowchartExtend sourceObject = pageRef.prefab; sourceObject.GoogleSheetID = spreadsheetId; sourceObject.GooglePageID = sheet_gid; List <AdvCSVLine> outdate = AdvUtility.UpdateBlockByCSV(sourceObject, sourceCSV, option, true); List <AdvCSVLine> willRemove = outdate; UnityEditor.EditorUtility.SetDirty(sourceObject.gameObject); PrefabUtility.SavePrefabAsset(sourceObject.gameObject); if (willRemove == null) { return; } if (popupDetal) { AdvPrefabUpdateResult.OpenWindow(sourceObject, willRemove); return; } if (!autoRemove) { return; } foreach (var item in willRemove) { sourceObject.csvLines.Remove(item); Fungus.Command cmd = item.generatedCommand; if (cmd != null) { string msg = string.Format("Auto remove update lost cmd ... {0} -> {1} -> {2}&cmd{3}", cmd.gameObject.name, AdvUtility.FindParentBlock(cmd).BlockName, cmd.ItemId, item.keys); Debug.Log(msg); AdvUtility.FindParentBlock(cmd).CommandList.Remove(cmd); Object.DestroyImmediate(cmd); } } willRemove.Clear(); }
void CreateData(string Result) { string sourceCSV = Result; Fungus.FlowchartExtend sourceObject = pageRef.prefab; if (sourceObject == null) { string path = string.Format("{0}/{1}.prefab", AdvScenarioManager.Instance.DefaultPrefabFolder, string.IsNullOrEmpty(pageRef.description) ? pageRef.Page_gid : pageRef.description); Fungus.FlowchartExtend tempObj = new GameObject().AddComponent <Fungus.FlowchartExtend>(); sourceObject = PrefabUtility.SaveAsPrefabAsset(tempObj.gameObject, path).GetComponent <Fungus.FlowchartExtend>(); pageRef.prefab = sourceObject; MonoBehaviour.DestroyImmediate(tempObj.gameObject); } sourceObject.GoogleSheetID = spreadsheetId; sourceObject.GooglePageID = sheet_gid; AdvUtility.CreateBlockByCSV(sourceObject, sourceCSV, true); }
public static void RebuildCSVLine(Fungus.FlowchartExtend sourceObject) { List <AdvCSVLine> lines = new List <AdvCSVLine>(); //Commands List <Fungus.Command> comps = new List <Fungus.Command>(sourceObject.GetComponents <Fungus.Command>()); for (int i = comps.Count - 1; i >= 0; i--) { ICommand icmd = comps[i] as ICommand; if (icmd != null && !string.IsNullOrEmpty(icmd.CSVCommandKey)) { AdvCSVLine newLine = new AdvCSVLine() { keys = icmd.CSVCommandKey, Command = ParseClassToCSVCMD(comps[i]) }; lines.Add(newLine); } } sourceObject.csvLines.RemoveAll((x) => !x.Command.StartsWith("*")); sourceObject.csvLines.AddRange(lines); }
/// <summary> /// 增加對話項目, 擴充了 "條件選擇項目" /// </summary> public virtual bool AddOption(string displayTerm, bool interactable, bool hideOption, Block targetBlock, FlowchartExtend srcFlowChart, bool hasCondition, int requireValue) { if (localizeIndex < _onScreenTextTerms.Length) { _onScreenTextTerms[localizeIndex] = displayTerm; localizeIndex++; } _onScreenFlowchart = srcFlowChart; string localText = LocalizeManager.GetLocalizeText(displayTerm); string displayText = string.IsNullOrEmpty(localText)? $"no key:{displayTerm}" : srcFlowChart.SubstituteVariables(localText); if (hasCondition) { if (OnRequireValue != null) { //OnRequireValue 自行添加判斷式, Menu將帶入 requireValue 來跑判斷式 interactable = OnRequireValue(requireValue); } } return(AddOption(displayText, interactable, hideOption, targetBlock)); }
void PlayAdvContent(Fungus.FlowchartExtend content, string blockName) { AdvManager.Instance.LoadContent(content, blockName, null); }