// 准备当前脚本信息 void PrepareCurrentScript() { if (m_FileList.Count > 0) { string json = File.ReadAllText(m_FileList[m_SelectScriptIndex].FullName); JsonData data = JsonMapper.ToObject(json); m_CurrentAction = AutoActionJsonParser.Parse(data) as AutoActionContainer; } }
public void StartAutoTestScript(string scriptName) { m_ScriptName = scriptName; string json = ResourceLoadUtils.Load <TextAsset>("AutoText/" + scriptName).text; JsonData data = JsonMapper.ToObject(json); m_AutoAction = AutoActionJsonParser.Parse(data); if (m_AutoAction != null) { m_AutoAction.SetFinishCallback(TestSuccess); Application.logMessageReceived += GetLog; m_Start = true; } else { TestFailed("script parse error!! " + scriptName); } }
private void OnGUI() { if (GUI.Button(new Rect(50, 50, 50, 50), "test")) { AutoActionContainer container = new AutoActionContainer(); AutoLoadScene loadScene = new AutoLoadScene("test"); AutoClick click = new AutoClick(new Vector3(10, 20, 30)); AutoTimer timer = new AutoTimer(5); AutoPressUI pressUI = new AutoPressUI("bg"); container.AddAction(loadScene); container.AddAction(click); container.AddAction(timer); container.AddAction(pressUI); AutoActionContainer container2 = new AutoActionContainer(); AutoWaitObjectAppear objectAppear = new AutoWaitObjectAppear("page"); AutoWaitObjectAppear objectDisappear = new AutoWaitObjectAppear("pageDis"); AutoWaitComponentAppear componentAppear = new AutoWaitComponentAppear(typeof(Image)); AutoWaitComponentDisappear componentDisappear = new AutoWaitComponentDisappear(typeof(Button)); AutoLabelTextAppear labelText = new AutoLabelTextAppear("label", "hello world"); container2.AddAction(container); container2.AddAction(objectAppear); container2.AddAction(labelText); container2.AddAction(objectDisappear); container2.AddAction(componentAppear); container2.AddAction(componentDisappear); string json = AutoActionJsonWriter.Write(container2); Debug.Log("json is:" + json); JsonData data = JsonMapper.ToObject(json); AutoActionContainer newContainer = AutoActionJsonParser.Parse(data) as AutoActionContainer; foreach (AutoAction action in newContainer.ActionList) { Debug.Log(action.GetType().Name); if (action.GetType().Name == "AutoActionContainer") { foreach (AutoAction childAction in (action as AutoActionContainer).ActionList) { Debug.Log(childAction.GetType().Name); } } } } }