本文整理汇总了C#中UnityEngine.MonoBehaviour.StartCoroutine方法的典型用法代码示例。如果您正苦于以下问题:C# MonoBehaviour.StartCoroutine方法的具体用法?C# MonoBehaviour.StartCoroutine怎么用?C# MonoBehaviour.StartCoroutine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.MonoBehaviour
的用法示例。
在下文中一共展示了MonoBehaviour.StartCoroutine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HideAndShow
//
public static void HideAndShow(MonoBehaviour sender ,string panelHide, string panelShow)
{
//hide menu
GameObject.Find(panelHide).GetComponent<CanvasGroup>().interactable = false;
sender.StartCoroutine(MenuBase.FadeHide(GameObject.Find(panelHide).GetComponent<CanvasGroup>()));
//show
GameObject diffObj = GameObject.Find(panelShow);
diffObj.GetComponent<CanvasGroup>().interactable = true;
sender.StartCoroutine(MenuBase.FadeShow(diffObj.GetComponent<CanvasGroup>()));
MenuBase.BringToFront(diffObj);
}
示例2: CoroutinePunchOutAndInitialize
public IEnumerator CoroutinePunchOutAndInitialize(MonoBehaviour caller, XZPolygon polygon, bool bKeepInterior, GameObject zeObject, string strName, string strLayer, CustomMesh customMesh, Material material, bool bCollider)
{
float T = Time.time;
yield return null;
yield return caller.StartCoroutine(PunchOutStep1(polygon));
Debug.Log("(1)");
yield return null;
Debug.Log("(2) Dt=" + (Time.time - T));
T = Time.time;
yield return caller.StartCoroutine(PunchOutStep2(polygon));
yield return null;
Debug.Log("(3) Dt=" + (Time.time - T));
T = Time.time;
yield return caller.StartCoroutine(PunchOutStep3(polygon, bKeepInterior));
yield return null;
Debug.Log("(4) Dt=" + (Time.time - T));
T = Time.time;
if (zeObject == null)
{
zeObject = new GameObject(strName);
zeObject.transform.parent = caller.transform;
zeObject.transform.localPosition = Vector3.zero;
zeObject.transform.localScale = Vector3.one;
zeObject.layer = LayerMask.NameToLayer(strLayer);
}
customMesh.AttachMeshTo(zeObject, material);
if (bCollider)
{
customMesh.AddMeshCollider(zeObject);
}
yield return null;
Debug.Log("(5) Dt=" + (Time.time - T));
T = Time.time;
caller.gameObject.SendMessage("OnPunchOutDone", zeObject);
}
示例3: Request
internal static IEnumerator Request(MonoBehaviour caller, EngageRequest request, EngageResponse response)
{
string requestJSON = request.ToJSON();
string url = DDNA.Instance.ResolveEngageURL(requestJSON);
HttpRequest httpRequest = new HttpRequest(url);
httpRequest.HTTPMethod = HttpRequest.HTTPMethodType.POST;
httpRequest.HTTPBody = requestJSON;
httpRequest.TimeoutSeconds = DDNA.Instance.Settings.HttpRequestEngageTimeoutSeconds;
httpRequest.setHeader("Content-Type", "application/json");
System.Action<int, string, string> httpHandler = (statusCode, data, error) => {
string engagementKey = "DDSDK_ENGAGEMENT_" + request.DecisionPoint + "_" + request.Flavour;
if (error == null && statusCode >= 200 && statusCode < 300) {
try {
PlayerPrefs.SetString(engagementKey, data);
} catch (Exception exception) {
Logger.LogWarning("Unable to cache engagement: "+exception.Message);
}
} else {
Logger.LogDebug("Engagement failed with "+statusCode+" "+error);
if (PlayerPrefs.HasKey(engagementKey)) {
Logger.LogDebug("Using cached response");
data = "{\"isCachedResponse\":true," + PlayerPrefs.GetString(engagementKey).Substring(1);
} else {
data = "{}";
}
}
response(data, statusCode, error);
};
yield return caller.StartCoroutine(Network.SendRequest(httpRequest, httpHandler));
}
示例4: run_list
public static IEnumerator run_list(MonoBehaviour runner, IEnumerable<ActionWrapper> actions){
foreach (ActionWrapper aw in actions) {
Debug.Log("Running Coroutine");
yield return runner.StartCoroutine(aw.run());
}
yield return null;
}
示例5: Start
public static YieldInstruction Start(CanvasGroup group, MonoBehaviour script, float from, float to, float time)
{
Stop(group, script);
var coroutine = script.StartCoroutine(AnimateGroup(group, from, to, time));
_fades.Add(group, coroutine);
return coroutine;
}
示例6: Callback
public void Callback(bool success,string response, List<RandomEvent> log, MonoBehaviour mb, string playId)
{
if(success)
{
mb.StartCoroutine(RegisterLog(log, playId));
}
}
示例7: StepControl
public StepControl(MasterPlayer player, MonoBehaviour context)
{
m_player = player;
m_context = context;
m_context.StartCoroutine(UpdateCo());
}
示例8: Login
public static Task Login(MonoBehaviour owner, IPEndPoint endPoint, string id, string password, Action<string> progressReport)
{
var task = new UnitySlimTaskCompletionSource<bool>();
task.Owner = owner;
owner.StartCoroutine(LoginCoroutine(endPoint, id, password, task, progressReport));
return task;
}
示例9: Init
public static void Init(MonoBehaviour behaviour)
{
if (inited)
return;
inited = true;
behaviour.StartCoroutine(DistanceCheck());
}
示例10: FadeOut
public static AudioSourceFadeState FadeOut(this AudioSource source, MonoBehaviour behaviour = null, float waitDuration = 0f, float fadeDuration = 3f, bool stopOnFinished = true, Action finishedCallback = null)
{
behaviour = behaviour ?? AutoMonoBehaviour.Instantiate(source.gameObject);
AudioSourceFadeState fadeState = new AudioSourceFadeState(source);
behaviour.StartCoroutine(StartFadeOut(source, waitDuration, fadeDuration, stopOnFinished, finishedCallback, fadeState));
return fadeState;
}
示例11: Build
public static IEnumerator Build(MonoBehaviour target, params IEnumerator[] coroutines)
{
var monitors = new Monitor[coroutines.Length];
for (var i = 0; i < coroutines.Length; i++)
target.StartCoroutine(monitors[i] = new Monitor(coroutines[i]));
while (!AllDone(monitors))
yield return null;
}
示例12: SendSignals
public void SendSignals( MonoBehaviour sender )
{
if (hasFired == false || onlyOnce == false) {
for (int i = 0; i < receivers.Length; i++) {
sender.StartCoroutine(receivers[i].SendWithDelay(sender));
}
hasFired = true;
}
}
示例13: Send
///////////////////////////////////////////////////////////////////////////////
// functions
///////////////////////////////////////////////////////////////////////////////
// ------------------------------------------------------------------
// Desc:
// ------------------------------------------------------------------
public void Send( MonoBehaviour _sender )
{
if ( delay <= Mathf.Epsilon ) {
SendMessage (_sender);
}
else {
_sender.StartCoroutine ( SendMessageDelay(_sender) );
}
}
示例14: ChangeUseAvatar
public static void ChangeUseAvatar(MonoBehaviour behaviour, byte[] avatar, DelegateAPICallback callback)
{
if (avatar == null)
{
if (callback != null) callback(false, "ERROR: Không có dữ liệu về avatar mới.");
return;
}
behaviour.StartCoroutine(UploadFile(avatar, callback));
}
示例15: FireAndForgetRoutine
//basically Invoke
/// <summary>
/// Calls the specified code after the specified time has passed.
/// </summary>
/// <param name="code">The function to call.</param>
/// <param name="time">The amount of time to wait before calling the code.</param>
/// <param name="callingScript">The <see cref="MonoBehaviour"/> to run the Coroutine on.</param>
/// <param name="mode">The time mode to run the Coroutine with.</param>
/// <returns></returns>
public static IEnumerator FireAndForgetRoutine(CallbackMethod code, float time, MonoBehaviour callingScript, Mode mode = Mode.UPDATE)
{
switch(mode)
{
case Mode.UPDATE:
case Mode.FIXEDUPDATE:
yield return new WaitForSeconds(time);
break;
case Mode.REALTIME:
yield return callingScript.StartCoroutine(WaitForRealSecondsRoutine(time));
break;
}
code();
}