void UpdateExistingScroller() { if (AutomationRecorder.RecordedActions != null && AutomationRecorder.RecordedActions.Any() && AutomationRecorder.RecordedActions.Last().Action == ActableTypes.Scroll) { ScrollRect rect = GetComponent <ScrollRect>(); RecordedGameObjectData data = AutomationRecorder.RecordedActions.Last(); float scrollVal = 0f; if (rect.verticalScrollbar == null && rect.horizontalScrollbar == null) { scrollVal = rect.vertical ? rect.content.position.x : rect.content.position.y; } scrollVal = rect.vertical ? rect.horizontalScrollbar.value : rect.verticalScrollbar.value; if (scrollVal == data.InitialScrollPosition) { scrollVal = scrollVal == 0 ? 1 : 0; } data.ScrollDistance = (float)Math.Round(Math.Abs(scrollVal - data.InitialScrollPosition), 1) * 100; //Percent 0-100. data.ScrollDirection = scrollVal - data.InitialScrollPosition < 0 ? ScrollDirection.RightOrDownToLeftOrUp : ScrollDirection.LeftOrUpToRightOrDown; 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. GetComponent <ScrollRect>().onValueChanged.RemoveListener(delegate { UpdateExistingScroller(); }); } }
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. } } }