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
using System; | |
public struct Vector2 { | |
public float x; | |
public float y; | |
public Vector2(float x, float y) { | |
this.x = x; | |
this.y = y; | |
} | |
} |
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
float x, y; | |
public ValueTuple<float, float> GetPosition() { | |
return ValueTuple.Create(_x, _y); | |
} | |
// Is exactly the same as GetPosition above | |
public (float, float) GetPositionAlternateSyntax() { | |
return (_x, _y); | |
} |
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
// declare and assign | |
(float x, float y) = GetPosition(); | |
// just assign | |
float x, y; // declare variables elsewhere | |
(x, y) = GetPosition(); | |
// tuple usage (explicit) | |
ValueTuple<float, float> ret = GetPosition(); | |
float x = ret.Item1, y = ret.Item2; |
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
// mix and match | |
float y; | |
(float x, y) = GetPosition(); | |
// throw away some returned values | |
(float x, _) = GetPosition(); |
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
void Awake() | |
{ | |
if (!Debug.isDebugBuild) | |
{ | |
Debug.Log("prod build"); | |
enabled = false; | |
} | |
} |
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
void Awake() { | |
if (!Debug.isDebugBuild) { | |
Debug.Log("prod build"); | |
enabled = false; | |
} | |
} |
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
{ | |
"FormattingOptions": { | |
"NewLinesForBracesInLambdaExpressionBody": false, | |
"NewLinesForBracesInAnonymousMethods": false, | |
"NewLinesForBracesInAnonymousTypes": false, | |
"NewLinesForBracesInControlBlocks": false, | |
"NewLinesForBracesInTypes": false, | |
"NewLinesForBracesInMethods": false, | |
"NewLinesForBracesInProperties": false, | |
"NewLinesForBracesInObjectCollectionArrayInitializers": false, |
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 void OnBuff() | |
{ | |
Debug.Log("buffed!"); | |
RunDelayed(2f, () => { | |
Debug.Log("debuffed!"); | |
}); | |
} |
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 Buff : MonoBehaviour | |
{ | |
public void OnBuff() | |
{ | |
Debug.Log("buffed!"); | |
RunDelayed(2f, () => { | |
Debug.Log("debuffed!"); | |
}); | |
} |
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 MyMonoBehaviour : MonoBehaviour { | |
protected IEnumerator DelayedCoroutine(float delay, System.Action a) | |
{ | |
yield return new WaitForSecondsRealtime(delay); | |
a(); | |
} | |
protected Coroutine RunDelayed(float delay, System.Action a) | |
{ | |
return StartCoroutine(DelayedCoroutine(delay, a)); |
OlderNewer