using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class TestSprite : MonoBehaviour { // Use this for initialization void Start() { WaitSeconds(2f, TestMethod); WaitSeconds(4f, TestMethod, "string", 1); } // Update is called once per frame void Update() { } void TestMethod() { print("run TestMethod()"); } void TestMethod(string name, int a) { print("run TestMethod()"+" name = " +name + " int = " + a); } void WaitSeconds(float time, Action method) { StartCoroutine(IEWaitSeconds(time, method)); } void WaitSeconds(float time, Action<string, int> method, string name, int a) { StartCoroutine(IEWaitSeconds(time, method,name,a)); } IEnumerator IEWaitSeconds(float time,Action method) { yield return new WaitForSeconds(time); method(); } IEnumerator IEWaitSeconds(float time, Action<string,int> method,string name,int a) { yield return new WaitForSeconds(time); method(name,a); } }