// Use this for initialization private void Start() { //Start a once timer this.Delayer(1, () => Debug.Log(1)); this.Sequence().Interval(1).Action(() => Debug.Log(1));//Same //Allso use transform as a ID to start a sequence transform.Delayer(1, () => Debug.Log(1)); //Start a loop timer this.Looper(0.5f, 3, false, () => Debug.Log(-1)); this.Sequence().Loop(3).Interval(0.5f).Action(() => Debug.Log(-1));//Same //Start a long sequence this.Sequence() .Interval(2) .Action(() => Debug.Log("Test1")) .Interval(3) .Action(() => Debug.Log("Test2")) .Interval(1) .Action(() => Debug.Log("Test3 end")) ; //Check Q key per 0.2 seconds this.Sequence() .Loop() .Interval(0.2f) .Condition(() => Input.GetKeyDown(KeyCode.Q)) .Action(n => Debug.Log("Q键 按下次数" + n)); ActionSequenceSystem.Delayer(5, () => Debug.Log("No id delayer")); ActionSequenceSystem.Looper(0.2f, 10, false, () => Debug.Log("No id looper")); }
//直接延迟动作 public static ActionSequence Delayer(this Component id, float delay, Action action) { ActionSequence seq = ActionSequenceSystem.GetSequence(id); seq.Interval(delay).Action(action); return(seq); }
//The timing function, callback function and judgment function are realized through the node. public override void OnInspectorGUI() { base.OnInspectorGUI(); int countAll, countActive; GUILayout.Label("ObjectPool State: Active/All", EditorStyles.boldLabel); ActionNodeAction.GetObjectPoolInfo(out countActive, out countAll); GUILayout.Label(string.Format("ActionNode: {0}/{1}", countActive, countAll)); ActionNodeInterval.GetObjectPoolInfo(out countActive, out countAll); GUILayout.Label(string.Format("IntervalNode: {0}/{1}", countActive, countAll)); ActionNodeCondition.GetObjectPoolInfo(out countActive, out countAll); GUILayout.Label(string.Format("ConditionNode: {0}/{1}", countActive, countAll)); ActionSequence.GetObjectPoolInfo(out countActive, out countAll); GUILayout.Label(string.Format("Sequence: {0}/{1}", countActive, countAll)); //Showing ActionSequences in progress ActionSequenceSystem actionSequenceSystem = target as ActionSequenceSystem; GUILayout.Label(string.Format("Sequence Count: {0}", actionSequenceSystem.ListSequence.Count), EditorStyles.boldLabel); for (int i = 0; i < actionSequenceSystem.ListSequence.Count; i++) { if (!actionSequenceSystem.ListSequence[i].isFinshed) { GUILayout.Box(string.Format("{0} id: {1}\n Loop:{2}/{3}", i, actionSequenceSystem.ListSequence[i].id, actionSequenceSystem.ListSequence[i].cycles, actionSequenceSystem.ListSequence[i].loopTime), "TextArea"); } } Repaint(); }
private void Update() { //Stop all sequences is ActionSequenceSystem if (Input.GetKeyDown(KeyCode.End)) { ActionSequenceSystem.StopAll(); } }
//直接循环动作 public static Component Looper(this Component id, float interval, int loopTime, bool isActionAtStart, Action <int> action) { ActionSequence seq = ActionSequenceSystem.GetSequence(id); if (isActionAtStart) { seq.Action(action).Interval(interval); } else { seq.Interval(interval).Action(action); } seq.Loop(loopTime); return(id); }
// Update is called once per frame private void Update() { //Start a loop in Update, using transform as ID if (Input.GetKeyDown(KeyCode.A)) { transform.Looper(1, -1, true, count => Debug.Log("A" + count)); } //Start a loop in Update if (Input.GetKeyDown(KeyCode.S)) { this.Looper(1, -1, true, count => Debug.Log("S" + count)); } if (Input.GetKeyDown(KeyCode.C)) { this.Sequence().Interval(1).Action(() => this.Sequence().Interval(1).Action(() => Debug.Log("C"))) .Interval(2) .Action(i => Debug.Log(i)); } //Stop all sequences start by this ID if (Input.GetKeyDown(KeyCode.D)) { transform.StopSequence(); } //Stop all sequences start by transform if (Input.GetKeyDown(KeyCode.F)) { this.StopSequence(); } //Stop all sequences is ActionSequenceSystem if (Input.GetKeyDown(KeyCode.End)) { Debug.Log("手动停止所有序列"); ActionSequenceSystem.StopSequenceAll(); } //If this Component is destroyed, the associated Sequence will automatically stop and recycle to the pool. }
// Use this for initialization private void Start() { //Start a once timer this.Delayer(1, () => Debug.Log(1)); this.Sequence().Interval(1).Action(() => Debug.Log(1)); //Same //Allso use transform as a ID to start a sequence transform.Delayer(1, () => Debug.Log(1)); //Start a loop timer this.Looper(0.5f, 3, false, () => Debug.Log(-1)); this.Sequence().Loop(3).Interval(0.5f).Action(() => Debug.Log(-1)); //Same //Start a infinite loop timer this.Looper(1, i => Debug.Log("Infiniter" + i)); //Start a long sequence this.Sequence() .Interval(2) .Action(() => Debug.Log("Test1")) .Interval(3) .Action(() => Debug.Log("Test2")) .Interval(1) .Action(() => Debug.Log("Test3 end")) ; //Check Q key per 0.2 seconds this.Sequence() .Loop() .Interval(1f) .WaitFor(() => Input.GetKeyDown(KeyCode.Q)) .Action(n => Debug.Log("Q键 按下次数" + n)); //Start a sequence without id. ActionSequenceSystem.Delayer(5, () => Debug.Log("No id delayer")); ActionSequenceSystem.Looper(0.2f, 10, false, () => Debug.Log("No id looper")); //Start a toggle GameObject active sequence tfShowHideExample.Hider(0.5f); tfShowHideExample.Sequence().Interval(0.5f).ToggleActive().Loop(); }
private void Start() { //Notes:An instance must be preserved to manually stop an infinite loop sequence. ActionSequenceSystem.Looper(infiniteSequenceHandle, 0.2f, -1, false, () => Debug.Log("No id infinite looper")); }
//用Component作为ID停止序列 public static void StopSequence(this Component id) { ActionSequenceSystem.SetStopSequenceID(id); }
//用Component作为ID开序列 public static ActionSequence Sequence(this Component id) { ActionSequence seq = ActionSequenceSystem.GetSequence(id); return(seq); }