Ejemplo n.º 1
0
        public void OnPointerDown(PointerEventData eventData)
        {
            List <MonoBehaviour> components = this.GetComponents <MonoBehaviour>().ToList();

            for (int x = 0; x < components.Count; x++)
            {
                Type         componentType = typeof(InputField);
                ActableTypes found         = ActableTypes.Wait;
                for (int a = 0; a < GameMaster.AdditionalAssetsAll.Count; a++)
                {
                    if (components[x].GetType().IsAssignableFrom(GameMaster.AdditionalAssetsAll[a].Key))
                    {
                        found         = GameMaster.AdditionalAssetsAll[a].Value;
                        componentType = GameMaster.AdditionalAssetsAll[a].Key;
                        break;
                    }
                }

                if (components[x].GetType().IsAssignableFrom(typeof(InputField)) || found == ActableTypes.Input)
                {
                    if (PointerDownHandled && AutomationRecorder.RecordedActions.Last().Action == ActableTypes.Input && AutomationRecorder.RecordedActions.Last().Name == name)
                    {
                        return;
                    }

                    PointerDownHandled = true;
                    if (componentType == typeof(InputField))
                    {
                        GetComponent <InputField>().onValueChanged.AddListener(delegate {
                            UpdateExistingInputStep();
                        });
                    }
                    else
                    {
                        //TODO: Add your custom types here.
                    }
                    break;
                }

                if (components[x].GetType().IsAssignableFrom(typeof(ScrollRect)))
                {
                    if (PointerDownHandled && AutomationRecorder.RecordedActions.Last().Action == ActableTypes.Scroll && AutomationRecorder.RecordedActions.Last().Name == name)
                    {
                        return;
                    }

                    PointerDownHandled = true;
                    GetComponent <ScrollRect>().onValueChanged.AddListener(delegate {
                        UpdateExistingScroller();
                    });

                    break;
                }
            }

            Selected();
        }
Ejemplo n.º 2
0
 public void AddListener(GameObject obj, ActableTypes type)
 {
     if (obj.GetComponent <AutomationListener>() == null)
     {
         AutomationListener listener = obj.AddComponent <AutomationListener> ();
         listener.type = type;
         ActiveListeners.Add(listener);
     }
 }
Ejemplo n.º 3
0
        void UpdateExistingInputStep()
        {
            List <MonoBehaviour> components = this.GetComponents <MonoBehaviour>().ToList();
            Type         componentType      = typeof(InputField);
            ActableTypes found = ActableTypes.Wait;

            for (int x = 0; x < components.Count; x++)
            {
                for (int a = 0; a < GameMaster.AdditionalAssetsAll.Count; a++)
                {
                    if (components[x].GetType().IsAssignableFrom(GameMaster.AdditionalAssetsAll[a].Key))
                    {
                        found         = GameMaster.AdditionalAssetsAll[a].Value;
                        componentType = GameMaster.AdditionalAssetsAll[a].Key;
                        break;
                    }
                }
            }

            if (AutomationRecorder.RecordedActions != null && AutomationRecorder.RecordedActions.Last().Action == ActableTypes.Input)
            {
                RecordedGameObjectData data = AutomationRecorder.RecordedActions.Last();
                if (componentType == typeof(InputField))
                {
                    data.TextValue = GetComponent <InputField>().text;
                }
                else
                {
                    //TODO: Add your custom types here.
                }

                AutomationRecorder.RemoveActionAt(AutomationRecorder.RecordedActions.Count - 1);
                AutomationRecorder.AddAction(data);
            }
            else
            {
                //The last action should be for this input field. If it isn't, something unexpected has happened, so clear this listener.
                if (componentType == typeof(InputField))
                {
                    GetComponent <InputField>().onValueChanged.RemoveListener(delegate { UpdateExistingInputStep(); });
                }
                else
                {
                    //TODO: Add your custom types here.
                }
            }
        }