當前位置: 首頁>>代碼示例>>C#>>正文


C# MonoBehaviour.StartCoroutine方法代碼示例

本文整理匯總了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);
    }
開發者ID:Killer40008,項目名稱:TSFSTAKBLCKS,代碼行數:15,代碼來源:MenuBase.cs

示例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);
        }
開發者ID:vpfrimmer,項目名稱:Eco-Duo,代碼行數:50,代碼來源:CustomMeshInterlinked.cs

示例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));
        }
開發者ID:deltaDNA,項目名稱:unity-sdk,代碼行數:35,代碼來源:Engage.cs

示例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;
	}
開發者ID:mrunderhill89,項目名稱:guardian_of_the_fields_the_strawberry_jam,代碼行數:7,代碼來源:CoroutineUtils.cs

示例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;
 }
開發者ID:hybrid1969,項目名稱:UnityTwine,代碼行數:7,代碼來源:ImageFade.cs

示例6: Callback

 public void Callback(bool success,string response, List<RandomEvent> log, MonoBehaviour mb, string playId)
 {
     if(success)
     {
         mb.StartCoroutine(RegisterLog(log, playId));
     }
 }
開發者ID:neuromat,項目名稱:game,代碼行數:7,代碼來源:ServerOperations.cs

示例7: StepControl

        public StepControl(MasterPlayer player, MonoBehaviour context)
        {
            m_player	= player;
            m_context	= context;

            m_context.StartCoroutine(UpdateCo());
        }
開發者ID:rebuilder17,項目名稱:fsnengine,代碼行數:7,代碼來源:StepControl.cs

示例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;
 }
開發者ID:SaladLab,項目名稱:TicTacToe,代碼行數:7,代碼來源:LoginProcessor.cs

示例9: Init

        public static void Init(MonoBehaviour behaviour)
        {
            if (inited)
                return;

            inited = true;
            behaviour.StartCoroutine(DistanceCheck());
        }
開發者ID:L4w3s,項目名稱:DOOM-Inspired-Dungon-Crawler,代碼行數:8,代碼來源:ObjectTriggererChecker.cs

示例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;
    }
開發者ID:Mykaelos,項目名稱:MykaelosUnityLibrary,代碼行數:8,代碼來源:AudioSourceExtension.cs

示例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;
 }
開發者ID:nobnak,項目名稱:ParallelCoroutineForUnity,代碼行數:8,代碼來源:ParallelCoroutine.cs

示例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;
     }
 }
開發者ID:cn00,項目名稱:U3D5_CSharp_AngryBots,代碼行數:9,代碼來源:SignalSender.cs

示例13: Send

 ///////////////////////////////////////////////////////////////////////////////
 // functions
 ///////////////////////////////////////////////////////////////////////////////
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 public void Send( MonoBehaviour _sender )
 {
     if ( delay <= Mathf.Epsilon ) {
         SendMessage (_sender);
     }
     else {
         _sender.StartCoroutine ( SendMessageDelay(_sender) );
     }
 }
開發者ID:exdev,項目名稱:ex-unity-old-deprecated,代碼行數:15,代碼來源:exSingalSender.cs

示例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));
        }
開發者ID:npnf-seta,項目名稱:Fox-Poker,代碼行數:10,代碼來源:HttpAPI.cs

示例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();
 }
開發者ID:bslupik,項目名稱:globalgamejam16,代碼行數:23,代碼來源:Callback.cs


注:本文中的UnityEngine.MonoBehaviour.StartCoroutine方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。