Пример #1
0
        public void Dismantle()
        {
            StopCoroutine("Runner");

            List <GameObject> all = SceneMaster.GetObjectPool();

            for (int x = 0; x < all.Count; x++)
            {
                AutomationListener al = all[x].GetComponent <AutomationListener>();
                if (al != null)
                {
                    Destroy(al);
                }
            }
        }
Пример #2
0
        IEnumerator Runner()
        {
            while (true)
            {
                if (forceRefresh || Time.time - lastRunTime > UPDATE_COOLDOWN)
                {
                    forceRefresh = false;
                    all          = all.GetUniqueObjectsBetween(SceneMaster.GetObjectPool().GetActiveAndVisibleObjectsInList());

                    for (int x = 0; x < all.Count; x++)
                    {
                        if (all[x] == null)
                        {
                            continue;
                        }

                        AutomationListener al = all[x].GetComponent <AutomationListener>();
                        if (al == null)
                        {
                            List <MonoBehaviour> components = all[x].GetComponents <MonoBehaviour>().ToList();

                            for (int co = 0; co < components.Count; co++)
                            {
                                string scriptName = components[co].GetType().Name;

                                #region Clickables
                                if (scriptName == "Button" || scriptName == "Toggle" || components[co].GetType().IsAssignableFrom(typeof(Button)) || components[co].GetType().IsAssignableFrom(typeof(Toggle)))
                                {
                                    AddListener(all[x], ActableTypes.Clickable);
                                    continue;
                                }

                                if (scriptName == "Collider" || components[co].GetType().IsAssignableFrom(typeof(Collider)))
                                {
                                    if (all[x].GetComponent <Collider>().isTrigger)
                                    {
                                        AddListener(all[x], ActableTypes.Clickable);
                                        continue;
                                    }
                                }
                                #endregion

                                #region Inputs
                                if (scriptName == "InputField" || components[co].GetType().IsAssignableFrom(typeof(InputField)))
                                {
                                    AddListener(all[x], ActableTypes.Input);
                                    continue;
                                }
                                #endregion

                                #region Movables
                                if (scriptName == "ScrollRect" || components[co].GetType().IsAssignableFrom(typeof(ScrollRect)))
                                {
                                    AddListener(all[x], ActableTypes.Scroll);
                                    continue;
                                }
                                #endregion

                                #region Fall Backs
                                for (int t = 0; t < GameSpecificActableTypes.Count; t++)
                                {
                                    if (scriptName == GameSpecificActableTypes[t].Key.Name)
                                    {
                                        AddListener(all[x], GameSpecificActableTypes[t].Value);
                                        continue;
                                    }
                                }

                                for (int a = 0; a < GameMaster.AdditionalAssetsAll.Count; a++)
                                {
                                    if (scriptName == GameMaster.AdditionalAssetsAll[a].Key.Name || components[co].GetType().IsAssignableFrom(GameMaster.AdditionalAssetsAll[a].Key))
                                    {
                                        AddListener(all[x], GameMaster.AdditionalAssetsAll[a].Value);
                                        continue;
                                    }
                                }

                                //Fallback on Selectable as many interactive objects and extensions of them inheret from Selectable.
                                if (scriptName == "Selectable" || components[co].GetType().IsAssignableFrom(typeof(Selectable)))
                                {
                                    AddListener(all[x], ActableTypes.Clickable);
                                    continue;
                                }
                                #endregion

                                /*
                                 * for(int t = 0; t < GameMaster.AdditionalTextAssets.Count; t++) {
                                 *
                                 * if(all[x].GetComponent(GameMaster.AdditionalTextAssets[t]) != <span class='value'>null</span>) {
                                 *
                                 * al = all[x].AddComponent<AutomationListener>();
                                 * al.type =  ActableTypes.TextForAssert;
                                 * ActiveListeners.Add(al);
                                 * continue;
                                 *
                                 * }
                                 *
                                 * }
                                 */
                            }
                        }
                    }

                    lastRunTime = Time.time;
                }

                yield return(StartCoroutine(Q.driver.WaitRealTime(0.05f)));
            }
        }