Created
October 28, 2018 15:09
-
-
Save dyguests/aac4b562abd0aa1a4cfcdd896423739c to your computer and use it in GitHub Desktop.
Unity get self instance in scene.
This file contains 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 static PlayerController FindWithTag() | |
{ | |
var playerController = GameObject.FindWithTag(Tags.Player).GetComponent<PlayerController>(); | |
if (playerController == null) | |
{ | |
throw new Exception("playerController not found."); | |
} | |
return playerController; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment