public static string GenerateTransitionMethod(FlowSystemEditorWindow flowEditor, FD.FlowWindow windowFrom, FD.FlowWindow windowTo)
        {
            var file = UnityEngine.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.GetClassNameWithNamespace(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 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);
        }
        public static string GenerateTransitionMethod(FlowSystemEditorWindow flowEditor, FD.FlowWindow windowFrom, FD.FlowWindow windowTo)
        {
            var file = UnityEngine.Resources.Load("UI.Windows/ABTesting/Templates/TemplateTransitionMethod") as TextAsset;

            if (file == null)
            {
                if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true)
                {
                    UnityEngine.Debug.LogError("ABTesting Template Loading Error: Could not load template 'TemplateTransitionMethod'");
                }

                return(string.Empty);
            }

            var data = FlowSystem.GetData();

            if (data == null)
            {
                return(string.Empty);
            }

            if (windowTo.IsABTest() == false)
            {
                return(string.Empty);
            }

            var result = string.Empty;
            var part   = file.text;

            var methodPatternDefault = "(item, h, wh) => WindowSystemFlow.DoFlow<{0}>(this, item, h, wh, false, null)";
            var methods    = string.Empty;
            var methodList = new List <string>();

            foreach (var item in windowTo.abTests.items)
            {
                var window = FlowSystem.GetWindow(item.attachItem.targetId);

                if (window.IsFunction() == true)
                {
                    var winFunc = FlowSystem.GetWindow(window.functionId);
                    if (winFunc != null)
                    {
                        window = FlowSystem.GetWindow(winFunc.functionRootId);
                    }
                    else
                    {
                        window = null;
                    }
                }

                if (window == null)
                {
                    methodList.Add("null");
                }
                else
                {
                    var classNameWithNamespace = Tpl.GetClassNameWithNamespace(window);
                    methodList.Add(string.Format(methodPatternDefault, classNameWithNamespace));
                }
            }

            methods = string.Join(", ", methodList.ToArray());

            result +=
                part.Replace("{METHOD_NAMES}", methods)
                .Replace("{FLOW_FROM_ID}", windowFrom.id.ToString())
                .Replace("{FLOW_TO_ID}", windowTo.id.ToString());

            return(result);
        }