public override string OnCompilerTransitionGeneration(FD.FlowWindow window) { var functionContainer = window.GetFunctionContainer(); if (functionContainer != null) { var exit = FlowSystem.GetWindow(functionContainer.functionExitId); if (exit != null && exit.id == window.id) { return(FlowFunctionsTemplateGenerator.GenerateReturnMethod(this.flowEditor, exit)); } } return(base.OnCompilerTransitionGeneration(window)); }
public static string GenerateReturnMethod(FlowSystemEditorWindow flowEditor, FD.FlowWindow exitWindow) { var file = UnityEngine.Resources.Load("UI.Windows/Functions/Templates/TemplateReturnMethod") as TextAsset; if (file == null) { if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) { UnityEngine.Debug.LogError("Functions Template Loading Error: Could not load template 'TemplateReturnMethod'"); } return(string.Empty); } var data = FlowSystem.GetData(); if (data == null) { return(string.Empty); } var result = string.Empty; var part = file.text; var functionContainer = exitWindow.GetFunctionContainer(); if (functionContainer == null) { // Function not found return(string.Empty); } var exit = data.GetWindow(functionContainer.functionExitId); var functionName = functionContainer.title; var functionCallName = functionContainer.directory; var classNameWithNamespace = Tpl.GetClassNameWithNamespace(exit); result += part.Replace("{FUNCTION_NAME}", functionName) .Replace("{FUNCTION_CALL_NAME}", functionCallName) .Replace("{CLASS_NAME_WITH_NAMESPACE}", classNameWithNamespace); return(result); }