Created
July 6, 2016 09:05
-
-
Save zhenlinyang/516104bd2945d35b6f2384b66daea0d9 to your computer and use it in GitHub Desktop.
Unity5.3 CustomYieldInstruction Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomYieldInstructionSample : MonoBehaviour | |
{ | |
IEnumerator TheCoroutine() | |
{ | |
TheLock theLock = new TheLock(); | |
yield return new WaitTheFinish(theLock.GetLockState); | |
} | |
} | |
public class WaitTheFinish : CustomYieldInstruction | |
{ | |
private Func<bool> m_theLockState; | |
public override bool keepWaiting | |
{ | |
get { return m_theLockState.Invoke(); } | |
} | |
public WaitTheFinish(Func<bool> theLockState) | |
{ | |
m_theLockState = theLockState; | |
} | |
} | |
public class TheLock | |
{ | |
private bool m_isLock = true; | |
public bool GetLockState() | |
{ | |
return m_isLock; | |
} | |
public void RemoveTheLock() | |
{ | |
m_isLock = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment