コード例 #1
0
ファイル: PlayerPrefab.cs プロジェクト: Keraunic-Tonic/GJ2021
        /**
         * <summary>Gets the runtime scene instance of the Player</summary>
         * <param name = "spawnIfNotPresent">If True, the Player will be spawned if no scene instance was found.</param>
         * <returns>The scene instance of the Player</returns>
         */
        public Player GetSceneInstance(bool spawnIfNotPresent = false)
        {
            Player[] scenePlayers = Object.FindObjectsOfType <Player> ();
            foreach (Player scenePlayer in scenePlayers)
            {
                if (scenePlayer.ID == ID)
                {
                    return(scenePlayer);
                }
            }

            if (spawnIfNotPresent && playerOb)
            {
                return(playerOb.SpawnFromPrefab(ID));
            }

            return(null);
        }