Exemplo n.º 1
0
        internal static WindowBase CreateWithIgnore_INTERNAL(WindowBase source, System.Action <WindowBase> onParametersPassCall, out bool ignoreActions, params object[] parameters)
        {
            ignoreActions = false;

            WindowBase instance = null;

            if (source.preferences.forceSingleInstance == true)
            {
                instance = WindowSystem.instance.currentWindows.FirstOrDefault(w => w.windowId == source.windowId);
                if (instance != null)
                {
                    ignoreActions = source.preferences.singleInstanceIgnoreActions;
                }
            }

            if (instance == null)
            {
                instance = source.Spawn();
                instance.transform.SetParent(null);
                instance.transform.localPosition = Vector3.zero;
                instance.transform.localRotation = Quaternion.identity;
                instance.transform.localScale    = Vector3.one;

                                #if UNITY_EDITOR
                instance.gameObject.name = string.Format("[Screen] {0}", source.GetType().Name);
                                #endif
            }

            if (ignoreActions == false)
            {
                instance.SetParameters(onParametersPassCall, parameters);
                instance.Init(source,
                              WindowSystem.instance.GetNextDepth(instance.preferences, instance.workCamera.depth),
                              WindowSystem.instance.GetNextZDepth(instance.preferences),
                              WindowSystem.instance.GetNextRaycastPriority(),
                              WindowSystem.instance.GetNextOrderInLayer()
                              );
            }

            if (WindowSystem.instance.currentWindows.Contains(instance) == false)
            {
                WindowSystem.instance.currentWindows.Add(instance);
            }

            return(instance);
        }
Exemplo n.º 2
0
        public static void CollectCallVariations(WindowBase screen, System.Action <System.Type[], string[]> onEveryVariation)
        {
            if (screen != null)
            {
                var methods = screen.GetType().GetMethods().Where((info) => info.IsVirtual == false && info.Name == "OnParametersPass").ToList();
                for (int i = 0; i < methods.Count; ++i)
                {
                    var notValid = false;
                    var attrs    = methods[i].GetCustomAttributes(true);
                    foreach (var attr in attrs)
                    {
                        if (attr is CompilerIgnore)
                        {
                            notValid = true;
                            break;
                        }
                    }

                    if (notValid == true)
                    {
                        continue;
                    }

                    var method     = methods[i];
                    var parameters = method.GetParameters();

                    var listTypes = new List <System.Type>();
                    var listNames = new List <string>();
                    foreach (var p in parameters)
                    {
                        listTypes.Add(p.ParameterType);
                        listNames.Add(p.Name);
                    }

                    onEveryVariation(listTypes.ToArray(), listNames.ToArray());
                }
            }
        }
Exemplo n.º 3
0
        internal WindowBase Create_INTERNAL(WindowBase source, params object[] parameters)
        {
            var instance = source.Spawn();

            instance.transform.SetParent(null);
            instance.transform.localPosition = Vector3.zero;
            instance.transform.localRotation = Quaternion.identity;
            instance.transform.localScale    = Vector3.one;

                        #if UNITY_EDITOR
            instance.gameObject.name = "Screen-" + source.GetType().Name;
                        #endif

            instance.SetParameters(parameters);
            instance.Init(WindowSystem.instance.GetNextDepth(instance.preferences, instance.workCamera.depth), WindowSystem.instance.GetNextZDepth(), WindowSystem.instance.GetNextRaycastPriority(), WindowSystem.instance.GetNextOrderInLayer());

            if (WindowSystem.instance.currentWindows.Contains(instance) == false)
            {
                WindowSystem.instance.currentWindows.Add(instance);
            }

            return(instance);
        }
Exemplo n.º 4
0
        internal static bool InvokeMethodWithParameters(out MethodInfo methodInfo, WindowBase window, string methodName, params object[] inputParameters)
        {
            var instance = WindowSystem.instance;

            const string comma = ",";
            var          key   = new StringBuilder();

            foreach (var input in inputParameters)
            {
                key.Append(input.GetType().Name);
                key.Append(comma);
            }

            key.Append(methodName);
            key.Append(comma);
            key.Append(window.GetType().Name);

            var keyStr = key.ToString();

            if (instance.methodsCache.TryGetValue(keyStr, out methodInfo) == false)
            {
                instance.methodsCache.Clear();

                var methods = window.GetType().GetMethods(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
                foreach (var method in methods)
                {
                    if (method.Name == methodName)
                    {
                        var count      = 0;
                        var parameters = method.GetParameters();

                        if (inputParameters.Length != parameters.Length)
                        {
                            continue;
                        }

                        for (int i = 0; i < parameters.Length; ++i)
                        {
                            var parameter = parameters[i];
                            var par       = inputParameters[i];

                            var equal = (parameter.ParameterType == par.GetType());
                            if (equal == true)
                            {
                                ++count;
                            }
                        }

                        if (count == parameters.Length)
                        {
                            // Invoke and break
                            methodInfo = method;

                            instance.methodsCache.Add(keyStr, methodInfo);

                            return(true);
                        }
                    }
                }
            }
            else
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 5
0
        public static bool CanMoveBack(WindowBase window)
        {
            var hasElement = (WindowSystemInput.waitForClickOnElement != null);

            if (window != null && WindowSystemInput.waitForClickOnElementWindows != null)
            {
                var isTargetWindow = WindowSystemInput.waitForClickOnElementWindows.Contains(window.GetType());
                if (isTargetWindow == false)
                {
                    return(true);
                }
            }

            if (hasElement == true && window != null)
            {
                return(WindowSystemInput.waitForClickOnElement.GetWindow() != window);
            }

            return(hasElement == false);
        }