public static string GenerateTransitionMethod(FlowSystemEditorWindow flowEditor, FlowWindow windowFrom, FlowWindow windowTo) { var file = Resources.Load("UI.Windows/Functions/Templates/TemplateTransitionMethod") as TextAsset; if (file == null) { Debug.LogError("Functions Template Loading Error: Could not load template 'TemplateTransitionMethod'"); return(string.Empty); } var data = FlowSystem.GetData(); if (data == null) { return(string.Empty); } var result = string.Empty; var part = file.text; // Function link var functionId = windowTo.GetFunctionId(); // Find function container var functionContainer = data.GetWindow(functionId); if (functionContainer == null) { // Function not found return(string.Empty); } // Get function root window var root = data.GetWindow(functionContainer.functionRootId); //var exit = data.GetWindow(functionContainer.functionExitId); var functionName = functionContainer.title; var functionCallName = functionContainer.directory; var classNameWithNamespace = Tpl.GetNamespace(root) + "." + Tpl.GetDerivedClassName(root); var transitionMethods = Tpl.GenerateTransitionMethods(windowTo); transitionMethods = transitionMethods.Replace("\r\n", "\r\n\t") .Replace("\n", "\n\t"); result += part.Replace("{TRANSITION_METHODS}", transitionMethods) .Replace("{FUNCTION_NAME}", functionName) .Replace("{FUNCTION_CALL_NAME}", functionCallName) .Replace("{FLOW_FROM_ID}", windowFrom.id.ToString()) .Replace("{FLOW_TO_ID}", windowTo.id.ToString()) .Replace("{CLASS_NAME_WITH_NAMESPACE}", classNameWithNamespace); return(result); }
public static string GenerateTransitionTypedMethod(FlowSystemEditorWindow flowEditor, FD.FlowWindow windowFrom, FD.FlowWindow windowTo, System.Type[] parameters, string[] parameterNames) { var file = UnityEngine.Resources.Load("UI.Windows/Functions/Templates/TemplateTransitionTypedMethod") as TextAsset; if (file == null) { Debug.LogError("Functions Template Loading Error: Could not load template 'TemplateTransitionTypedMethod'"); return(string.Empty); } var data = FlowSystem.GetData(); if (data == null) { return(string.Empty); } var result = string.Empty; var part = file.text; // Function link var functionId = windowTo.GetFunctionId(); // Find function container var functionContainer = data.GetWindow(functionId); if (functionContainer == null) { // Function not found return(string.Empty); } // Get function root window var root = data.GetWindow(functionContainer.functionRootId); //var exit = data.GetWindow(functionContainer.functionExitId); var functionName = functionContainer.title; var functionCallName = functionContainer.directory; var classNameWithNamespace = Tpl.GetNamespace(root) + "." + Tpl.GetDerivedClassName(root); var transitionMethods = Tpl.GenerateTransitionMethods(windowTo); transitionMethods = transitionMethods.Replace("\r\n", "\r\n\t") .Replace("\n", "\n\t"); var definition = parameters.Select((x, i) => ME.Utilities.FormatParameter(x) + " " + parameterNames[i]).ToArray(); var call = parameterNames; var description = parameters.Select((x, i) => "/// <param name=\"" + parameterNames[i] + "\">" + parameterNames[i] + " to OnParametersPass</param>").ToArray(); result += part.Replace("{TRANSITION_METHODS}", transitionMethods) .Replace("{FUNCTION_NAME}", functionName) .Replace("{FUNCTION_CALL_NAME}", functionCallName) .Replace("{FLOW_FROM_ID}", windowFrom.id.ToString()) .Replace("{FLOW_TO_ID}", windowTo.id.ToString()) .Replace("{CLASS_NAME_WITH_NAMESPACE}", classNameWithNamespace) .Replace("{PARAMETERS_DEFINITION}", string.Join(", ", definition)) .Replace("{PARAMETERS_CALL}", string.Join(", ", call)) .Replace("{PARAMETERS_DESCRIPTION}", string.Join(System.Environment.NewLine, description)); return(result); }