当前位置: 首页>>代码示例>>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;未经允许,请勿转载。