After









How do I use After
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: PhotonViewHandler.cs Copy
25     internal static void HierarchyChange()
26     {
27         if (Application.isPlaying)
28         {
29             //Debug.Log("HierarchyChange ignored, while running.");
30             CheckSceneForStuckHandlers = true; // done once AFTER play mode.
31             return;
32         }
33
34         if (CheckSceneForStuckHandlers)
35         {
36             CheckSceneForStuckHandlers = false;
37             PhotonNetwork.InternalCleanPhotonMonoFromSceneIfStuck();
38         }
39
40         HashSet pvInstances = new HashSet();
41         HashSet usedInstanceViewNumbers = new HashSet();
42         bool fixedSomeId = false;
43
44         //// the following code would be an option if we only checked scene objects (but we can check all PVs)
45         //PhotonView[] pvObjects = GameObject.FindSceneObjectsOfType(typeof(PhotonView)) as PhotonView[];
46         //Debug.Log("HierarchyChange. PV Count: " + pvObjects.Length);
47
48         string levelName = Application.loadedLevelName;
49         #if UNITY_EDITOR
50         levelName = System.IO.Path.GetFileNameWithoutExtension(EditorApplication.currentScene);
51         #endif
52         int minViewIdInThisScene = PunSceneSettings.MinViewIdForScene(levelName);
53         //Debug.Log("Level '" + Application.loadedLevelName + "' has a minimum ViewId of: " + minViewIdInThisScene);
54
55         PhotonView[] pvObjects = Resources.FindObjectsOfTypeAll(typeof(PhotonView)) as PhotonView[];
56
57         foreach (PhotonView view in pvObjects)
58         {
59             // first pass: fix prefabs to viewID 0 if they got a view number assigned (cause they should not have one!)
60             if (EditorUtility.IsPersistent(view.gameObject))
61             {
62                 if (view.viewID != 0 || view.prefixBackup != -1 || view.instantiationId != -1)
63                 {
64                     Debug.LogWarning("PhotonView on persistent object being fixed (id and prefix must be 0). Was: " + view);
65                     view.viewID = 0;
66                     view.prefixBackup = -1;
67                     view.instantiationId = -1;
68                     EditorUtility.SetDirty(view);
69                     fixedSomeId = true;
70                 }
71             }
72             else
73             {
74                 // keep all scene-instanced PVs for later re-check
75                 pvInstances.Add(view);
76             }
77         }
78
79         Dictionary idPerObject = new Dictionary();
80
81         // second pass: check all used-in-scene viewIDs for duplicate viewIDs (only checking anything non-prefab)
82         // scene-PVs must have user == 0 (scene/room) and a subId != 0
83         foreach (PhotonView view in pvInstances)
84         {
85             if (view.ownerId > 0)
86             {
87                 Debug.Log("Re-Setting Owner ID of: " + view);
88             }
89             view.ownerId = 0; // simply make sure no owner is set (cause room always uses 0)
90             view.prefix = -1; // TODO: prefix could be settable via inspector per scene?!
91
92             if (view.viewID != 0)
93             {
94                 if (view.viewID < minViewIdInThisScene || usedInstanceViewNumbers.Contains(view.viewID))
95                 {
96                     view.viewID = 0; // avoid duplicates and negative values by assigning 0 as (temporary) number to be fixed in next pass
97                 }
98                 else
99                 {
100                     usedInstanceViewNumbers.Add(view.viewID); // builds a list of currently used viewIDs
101
102                     int instId = 0;
103                     if (idPerObject.TryGetValue(view.gameObject, out instId))
104                     {
105                         view.instantiationId = instId;
106                     }
107                     else
108                     {
109                         view.instantiationId = view.viewID;
110                         idPerObject[view.gameObject] = view.instantiationId;
111                     }
112                 }
113             }
114
115         }
116
117         // third pass: anything that's now 0 must get a new (not yet used) ID (starting at 0)
118         int lastUsedId = (minViewIdInThisScene > 0) ? minViewIdInThisScene - 1 : 0;
119
120         foreach (PhotonView view in pvInstances)
121         {
122             if (view.viewID == 0)
123             {
124                 // Debug.LogWarning("setting scene ID: " + view.gameObject.name + " ID: " + view.subId.ID + " scene ID: " + view.GetSceneID() + " IsPersistent: " + EditorUtility.IsPersistent(view.gameObject) + " IsSceneViewIDFree: " + IsSceneViewIDFree(view.subId.ID, view));
125                 int nextViewId = PhotonViewHandler.GetID(lastUsedId, usedInstanceViewNumbers);
126
127                 view.viewID = nextViewId;
128
129                 int instId = 0;
130                 if (idPerObject.TryGetValue(view.gameObject, out instId))
131                 {
132                     Debug.Log("Set inst ID");
133                     view.instantiationId = instId;
134                 }
135                 else
136                 {
137                     view.instantiationId = view.viewID;
138                     idPerObject[view.gameObject] = nextViewId;
139                 }
140
141                 //// when using the Editor's serialization (view.subId in this case), this is not needed, it seems
142                 //PrefabUtility.RecordPrefabInstancePropertyModifications(view);
143
144                 lastUsedId = nextViewId;
145                 EditorUtility.SetDirty(view);
146                 fixedSomeId = true;
147             }
148         }
149
150
151         if (fixedSomeId)
152         {
153             //Debug.LogWarning("Some subId was adjusted."); // this log is only interesting for Exit Games
154         }
155     }
File name: PhotonTransformViewPositionControl.cs Copy
54     public Vector3 UpdatePosition( Vector3 currentPosition )
55     {
56         Vector3 targetPosition = GetNetworkPosition() + GetExtrapolatedPositionOffset();
57
58         switch( m_Model.InterpolateOption )
59         {
60         case PhotonTransformViewPositionModel.InterpolateOptions.Disabled:
61             if( m_UpdatedPositionAfterOnSerialize == false )
62             {
63                 currentPosition = targetPosition;
64                 m_UpdatedPositionAfterOnSerialize = true;
65             }
66             break;
67         case PhotonTransformViewPositionModel.InterpolateOptions.FixedSpeed:
68             currentPosition = Vector3.MoveTowards( currentPosition, targetPosition, Time.deltaTime * m_Model.InterpolateMoveTowardsSpeed );
69             break;
70         case PhotonTransformViewPositionModel.InterpolateOptions.EstimatedSpeed:
71             int positionsCount = Mathf.Min( 1, m_OldNetworkPositions.Count );
72             float estimatedSpeed = Vector3.Distance( m_NetworkPosition, GetOldestStoredNetworkPosition() ) / positionsCount;
73             currentPosition = Vector3.MoveTowards( currentPosition, targetPosition, Time.deltaTime * estimatedSpeed );
74             break;
75         case PhotonTransformViewPositionModel.InterpolateOptions.SynchronizeValues:
76             if( m_SynchronizedSpeed.magnitude == 0 )
77             {
78                 currentPosition = targetPosition;
79             }
80             else
81             {
82                 currentPosition = Vector3.MoveTowards( currentPosition, targetPosition, Time.deltaTime * m_SynchronizedSpeed.magnitude );
83             }
84             break;
85         case PhotonTransformViewPositionModel.InterpolateOptions.Lerp:
86             currentPosition = Vector3.Lerp( currentPosition, targetPosition, Time.deltaTime * m_Model.InterpolateLerpSpeed );
87             break;
88         /*case PhotonTransformViewPositionModel.InterpolateOptions.MoveTowardsComplex:
89             float distanceToTarget = Vector3.Distance( currentPosition, targetPosition );
90             float targetSpeed = m_Model.InterpolateSpeedCurve.Evaluate( distanceToTarget ) * m_Model.InterpolateMoveTowardsSpeed;
91
92             if( targetSpeed > m_CurrentSpeed )
93             {
94                 m_CurrentSpeed = Mathf.MoveTowards( m_CurrentSpeed, targetSpeed, Time.deltaTime * m_Model.InterpolateMoveTowardsAcceleration );
95             }
96             else
97             {
98                 m_CurrentSpeed = Mathf.MoveTowards( m_CurrentSpeed, targetSpeed, Time.deltaTime * m_Model.InterpolateMoveTowardsDeceleration );
99             }
100
101             //Debug.Log( m_CurrentSpeed + " - " + targetSpeed + " - " + transform.localPosition + " - " + targetPosition );
102
103             currentPosition = Vector3.MoveTowards( currentPosition, targetPosition, Time.deltaTime * m_CurrentSpeed );
104             break;*/
105         }
106
107         if( m_Model.TeleportEnabled == true )
108         {
109             if( Vector3.Distance( currentPosition, GetNetworkPosition() ) > m_Model.TeleportIfDistanceGreaterThan )
110             {
111                 currentPosition = GetNetworkPosition();
112             }
113         }
114
115         return currentPosition;
116     }
File name: PhotonTransformViewPositionControl.cs Copy
163     public void OnPhotonSerializeView( Vector3 currentPosition, PhotonStream stream, PhotonMessageInfo info )
164     {
165         if( m_Model.SynchronizeEnabled == false )
166         {
167             return;
168         }
169
170         if( stream.isWriting == true )
171         {
172             SerializeData( currentPosition, stream, info );
173         }
174         else
175         {
176             DeserializeData( stream, info );
177         }
178
179         m_LastSerializeTime = PhotonNetwork.time;
180         m_UpdatedPositionAfterOnSerialize = false;
181     }
File name: NetworkingPeer.cs Copy
1411     public void OnStatusChanged(StatusCode statusCode)
1412     {
1413         if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
1414             Debug.Log(string.Format("OnStatusChanged: {0}", statusCode.ToString()));
1415
1416         switch (statusCode)
1417         {
1418             case StatusCode.Connect:
1419                 if (this.State == global::PeerState.ConnectingToNameServer)
1420                 {
1421                     if (PhotonNetwork.logLevel >= PhotonLogLevel.Full)
1422                         Debug.Log("Connected to NameServer.");
1423
1424                     this.server = ServerConnection.NameServer;
1425                     if (this.CustomAuthenticationValues != null)
1426                     {
1427                         this.CustomAuthenticationValues.Secret = null; // when connecting to NameServer, invalidate any auth values
1428                     }
1429                 }
1430
1431                 if (this.State == global::PeerState.ConnectingToGameserver)
1432                 {
1433                     if (PhotonNetwork.logLevel >= PhotonLogLevel.Full)
1434                         Debug.Log("Connected to gameserver.");
1435
1436                     this.server = ServerConnection.GameServer;
1437                     this.State = global::PeerState.ConnectedToGameserver;
1438                 }
1439
1440                 if (this.State == global::PeerState.ConnectingToMasterserver)
1441                 {
1442                     if (PhotonNetwork.logLevel >= PhotonLogLevel.Full)
1443                         Debug.Log("Connected to masterserver.");
1444
1445                     this.server = ServerConnection.MasterServer;
1446                     this.State = global::PeerState.ConnectedToMaster;
1447
1448                     if (this.IsInitialConnect)
1449                     {
1450                         this.IsInitialConnect = false; // after handling potential initial-connect issues with special messages, we are now sure we can reach a server
1451                         SendMonoMessage(PhotonNetworkingMessage.OnConnectedToPhoton);
1452                     }
1453                 }
1454
1455                 this.EstablishEncryption(); // always enable encryption
1456
1457                 if (this.IsAuthorizeSecretAvailable)
1458                 {
1459                     // if we have a token we don't have to wait for encryption (it is encrypted anyways, so encryption is just optional later on)
1460                     this.didAuthenticate = this.OpAuthenticate(this.mAppId, this.mAppVersionPun, this.PlayerName, this.CustomAuthenticationValues, this.CloudRegion.ToString());
1461                     if (this.didAuthenticate)
1462                     {
1463                         this.State = global::PeerState.Authenticating;
1464                     }
1465                 }
1466                 break;
1467
1468             case StatusCode.EncryptionEstablished:
1469                 // on nameserver, the "process" is stopped here, so the developer/game can either get regions or authenticate with a specific region
1470                 if (this.server == ServerConnection.NameServer)
1471                 {
1472                     this.State = global::PeerState.ConnectedToNameServer;
1473
1474                     if (!this.didAuthenticate && this.CloudRegion == CloudRegionCode.none)
1475                     {
1476                         // this client is not setup to connect to a default region. find out which regions there are!
1477                         this.OpGetRegions(this.mAppId);
1478                     }
1479                 }
1480
1481                 // we might need to authenticate automatically now, so the client can do anything at all
1482                 if (!this.didAuthenticate && (!this.IsUsingNameServer || this.CloudRegion != CloudRegionCode.none))
1483                 {
1484                     // once encryption is availble, the client should send one (secure) authenticate. it includes the AppId (which identifies your app on the Photon Cloud)
1485                     this.didAuthenticate = this.OpAuthenticate(this.mAppId, this.mAppVersionPun, this.PlayerName, this.CustomAuthenticationValues, this.CloudRegion.ToString());
1486                     if (this.didAuthenticate)
1487                     {
1488                         this.State = global::PeerState.Authenticating;
1489                     }
1490                 }
1491                 break;
1492
1493             case StatusCode.EncryptionFailedToEstablish:
1494                 Debug.LogError("Encryption wasn't established: " + statusCode + ". Going to authenticate anyways.");
1495                 this.OpAuthenticate(this.mAppId, this.mAppVersionPun, this.PlayerName, this.CustomAuthenticationValues, this.CloudRegion.ToString()); // TODO: check if there are alternatives
1496                 break;
1497
1498             case StatusCode.Disconnect:
1499                 this.didAuthenticate = false;
1500                 this.isFetchingFriends = false;
1501                 if (server == ServerConnection.GameServer) this.LeftRoomCleanup();
1502                 if (server == ServerConnection.MasterServer) this.LeftLobbyCleanup();
1503
1504                 if (this.State == global::PeerState.DisconnectingFromMasterserver)
1505                 {
1506                     if (this.Connect(this.mGameserver, ServerConnection.GameServer))
1507                     {
1508                         this.State = global::PeerState.ConnectingToGameserver;
1509                     }
1510                 }
1511                 else if (this.State == global::PeerState.DisconnectingFromGameserver || this.State == global::PeerState.DisconnectingFromNameServer)
1512                 {
1513                     if (this.Connect(this.MasterServerAddress, ServerConnection.MasterServer))
1514                     {
1515                         this.State = global::PeerState.ConnectingToMasterserver;
1516                     }
1517                 }
1518                 else
1519                 {
1520                     if (this.CustomAuthenticationValues != null)
1521                     {
1522                         this.CustomAuthenticationValues.Secret = null; // invalidate any custom auth secrets
1523                     }
1524
1525                     this.State = global::PeerState.PeerCreated; // if we set another state here, we could keep clients from connecting in OnDisconnectedFromPhoton right here.
1526                     SendMonoMessage(PhotonNetworkingMessage.OnDisconnectedFromPhoton);
1527                 }
1528                 break;
1529
1530             case StatusCode.SecurityExceptionOnConnect:
1531             case StatusCode.ExceptionOnConnect:
1532                 this.State = global::PeerState.PeerCreated;
1533                 if (this.CustomAuthenticationValues != null)
1534                 {
1535                     this.CustomAuthenticationValues.Secret = null; // invalidate any custom auth secrets
1536                 }
1537
1538                 DisconnectCause cause = (DisconnectCause)statusCode;
1539                 SendMonoMessage(PhotonNetworkingMessage.OnFailedToConnectToPhoton, cause);
1540                 break;
1541
1542             case StatusCode.Exception:
1543                 if (this.IsInitialConnect)
1544                 {
1545                     Debug.LogError("Exception while connecting to: " + this.ServerAddress + ". Check if the server is available.");
1546                     if (this.ServerAddress == null || this.ServerAddress.StartsWith("127.0.0.1"))
1547                     {
1548                         Debug.LogWarning("The server address is 127.0.0.1 (localhost): Make sure the server is running on this machine. Android and iOS emulators have their own localhost.");
1549                         if (this.ServerAddress == this.mGameserver)
1550                         {
1551                             Debug.LogWarning("This might be a misconfiguration in the game server config. You need to edit it to a (public) address.");
1552                         }
1553                     }
1554
1555                     this.State = global::PeerState.PeerCreated;
1556                     cause = (DisconnectCause)statusCode;
1557                     SendMonoMessage(PhotonNetworkingMessage.OnFailedToConnectToPhoton, cause);
1558                 }
1559                 else
1560                 {
1561                     this.State = global::PeerState.PeerCreated;
1562
1563                     cause = (DisconnectCause)statusCode;
1564                     SendMonoMessage(PhotonNetworkingMessage.OnConnectionFail, cause);
1565                 }
1566
1567                 this.Disconnect();
1568                 break;
1569
1570             case StatusCode.TimeoutDisconnect:
1571             case StatusCode.ExceptionOnReceive:
1572             case StatusCode.DisconnectByServer:
1573             case StatusCode.DisconnectByServerLogic:
1574             case StatusCode.DisconnectByServerUserLimit:
1575                 if (this.IsInitialConnect)
1576                 {
1577                     Debug.LogWarning(statusCode + " while connecting to: " + this.ServerAddress + ". Check if the server is available.");
1578
1579                     cause = (DisconnectCause)statusCode;
1580                     SendMonoMessage(PhotonNetworkingMessage.OnFailedToConnectToPhoton, cause);
1581                 }
1582                 else
1583                 {
1584                     cause = (DisconnectCause)statusCode;
1585                     SendMonoMessage(PhotonNetworkingMessage.OnConnectionFail, cause);
1586                 }
1587                 if (this.CustomAuthenticationValues != null)
1588                 {
1589                     this.CustomAuthenticationValues.Secret = null; // invalidate any custom auth secrets
1590                 }
1591
1592                 this.Disconnect();
1593                 break;
1594
1595             case StatusCode.SendError:
1596                 // this.mListener.clientErrorReturn(statusCode);
1597                 break;
1598
1599             case StatusCode.QueueOutgoingReliableWarning:
1600             case StatusCode.QueueOutgoingUnreliableWarning:
1601             case StatusCode.QueueOutgoingAcksWarning:
1602             case StatusCode.QueueSentWarning:
1603                 // this.mListener.warningReturn(statusCode);
1604                 break;
1605
1606             case StatusCode.QueueIncomingReliableWarning:
1607             case StatusCode.QueueIncomingUnreliableWarning:
1608                 Debug.Log(statusCode + ". This client buffers many incoming messages. This is OK temporarily. With lots of these warnings, check if you send too much or execute messages too slow. " + (PhotonNetwork.isMessageQueueRunning? "":"Your isMessageQueueRunning is false. This can cause the issue temporarily.") );
1609                 break;
1610
1611             // // TCP "routing" is an option of Photon that's not currently needed (or supported) by PUN
1612             //case StatusCode.TcpRouterResponseOk:
1613             // break;
1614             //case StatusCode.TcpRouterResponseEndpointUnknown:
1615             //case StatusCode.TcpRouterResponseNodeIdUnknown:
1616             //case StatusCode.TcpRouterResponseNodeNotReady:
1617
1618             // this.DebugReturn(DebugLevel.ERROR, "Unexpected router response: " + statusCode);
1619             // break;
1620
1621             default:
1622
1623                 // this.mListener.serverErrorReturn(statusCode.value());
1624                 Debug.LogError("Received unknown status code: " + statusCode);
1625                 break;
1626         }
1627
1628         this.externalListener.OnStatusChanged(statusCode);
1629     }
File name: NetworkingPeer.cs Copy
3339     private void OnSerializeRead(Hashtable data, PhotonPlayer sender, int networkTime, short correctPrefix)
3340     {
3341         // read view ID from key (byte)0: a int-array (PUN 1.17++)
3342         int viewID = (int)data[(byte)0];
3343
3344
3345         PhotonView view = this.GetPhotonView(viewID);
3346         if (view == null)
3347         {
3348             Debug.LogWarning("Received OnSerialization for view ID " + viewID + ". We have no such PhotonView! Ignored this if you're leaving a room. State: " + this.State);
3349             return;
3350         }
3351
3352         if (view.prefix > 0 && correctPrefix != view.prefix)
3353         {
3354             Debug.LogError("Received OnSerialization for view ID " + viewID + " with prefix " + correctPrefix + ". Our prefix is " + view.prefix);
3355             return;
3356         }
3357
3358         // SetReceiving filtering
3359         if (view.group != 0 && !this.allowedReceivingGroups.Contains(view.group))
3360         {
3361             return; // Ignore group
3362         }
3363
3364
3365         if (view.synchronization == ViewSynchronization.ReliableDeltaCompressed)
3366         {
3367             if (!this.DeltaCompressionRead(view, data))
3368             {
3369                 // Skip this packet as we haven't got received complete-copy of this view yet.
3370                 if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
3371                     Debug.Log("Skipping packet for " + view.name + " [" + view.viewID + "] as we haven't received a full packet for delta compression yet. This is OK if it happens for the first few frames after joining a game.");
3372                 return;
3373             }
3374
3375             // store last received for delta-compression usage
3376             view.lastOnSerializeDataReceived = data[(byte)1] as object[];
3377         }
3378
3379         if (sender.ID != view.ownerId)
3380         {
3381             if (!view.isSceneView || !sender.isMasterClient)
3382             {
3383                 // obviously the owner changed and we didn't yet notice.
3384                 Debug.Log("Adjusting owner to sender of updates. From: " + view.ownerId + " to: " + sender.ID);
3385                 view.ownerId = sender.ID;
3386             }
3387         }
3388
3389         object[] contents = data[(byte)1] as object[];
3390         PhotonStream pStream = new PhotonStream(false, contents);
3391         PhotonMessageInfo info = new PhotonMessageInfo(sender, networkTime, view);
3392
3393         view.DeserializeView( pStream, info );
3394     }
File name: PhotonNetwork.cs Copy
1988     public static void UnAllocateViewID(int viewID)
1989     {
1990         manuallyAllocatedViewIds.Remove(viewID);
1991
1992         if (networkingPeer.photonViewList.ContainsKey(viewID))
1993         {
1994             Debug.LogWarning(string.Format("UnAllocateViewID() should be called after the PhotonView was destroyed (GameObject.Destroy()). ViewID: {0} still found in: {1}", viewID, networkingPeer.photonViewList[viewID]));
1995         }
1996     }
File name: PhotonView.cs Copy
295     protected internal void OnDestroy()
296     {
297         if (!this.destroyedByPhotonNetworkOrQuit)
298         {
299             PhotonNetwork.networkingPeer.LocalCleanPhotonView(this);
300         }
301
302         if (!this.destroyedByPhotonNetworkOrQuit && !Application.isLoadingLevel)
303         {
304             if (this.instantiationId > 0)
305             {
306                 // if this viewID was not manually assigned (and we're not shutting down or loading a level), you should use PhotonNetwork.Destroy() to get rid of GOs with PhotonViews
307                 Debug.LogError("OnDestroy() seems to be called without PhotonNetwork.Destroy()?! GameObject: " + this.gameObject + " Application.isLoadingLevel: " + Application.isLoadingLevel);
308             }
309             else
310             {
311                 // this seems to be a manually instantiated PV. if it's local, we could warn if the ID is not in the allocated-list
312                 if (this.viewID <= 0)
313                 {
314                     Debug.LogWarning(string.Format("OnDestroy manually allocated PhotonView {0}. The viewID is 0. Was it ever (manually) set?", this));
315                 }
316                 else if (this.isMine && !PhotonNetwork.manuallyAllocatedViewIds.Contains(this.viewID))
317                 {
318                     Debug.LogWarning(string.Format("OnDestroy manually allocated PhotonView {0}. The viewID is local (isMine) but not in manuallyAllocatedViewIds list. Use UnAllocateViewID() after you destroyed the PV.", this));
319                 }
320             }
321         }
322     }
File name: PickupItemSimple.cs Copy
40     public void PunPickupSimple(PhotonMessageInfo msgInfo)
41     {
42         // one of the messages might be ours
43         // note: you could check "active" first, if you're not interested in your own, failed pickup-attempts.
44         if (this.SentPickup && msgInfo.sender.isLocal)
45         {
46             if (this.gameObject.GetActive())
47             {
48                 // picked up! yay.
49             }
50             else
51             {
52                 // pickup failed. too late (compared to others)
53             }
54         }
55
56         this.SentPickup = false;
57
58         if (!this.gameObject.GetActive())
59         {
60             Debug.Log("Ignored PU RPC, cause item is inactive. " + this.gameObject);
61             return;
62         }
63
64
65         // how long it is until this item respanws, depends on the pickup time and the respawn time
66         double timeSinceRpcCall = (PhotonNetwork.time - msgInfo.timestamp);
67         float timeUntilRespawn = SecondsBeforeRespawn - (float)timeSinceRpcCall;
68         //Debug.Log("msg timestamp: " + msgInfo.timestamp + " time until respawn: " + timeUntilRespawn);
69
70         if (timeUntilRespawn > 0)
71         {
72             // this script simply disables the GO for a while until it respawns.
73             this.gameObject.SetActive(false);
74             Invoke("RespawnAfter", timeUntilRespawn);
75         }
76     }
File name: PickupItemSimple.cs Copy
78     public void RespawnAfter()
79     {
80         if (this.gameObject != null)
81         {
82             this.gameObject.SetActive(true);
83         }
84     }
File name: Scalable.cs Copy
57  public void ScaleIn(float startAfter, float speed, float endScale) {
58   StartCoroutine(IEScaleIn(startAfter,speed,endScale));
59  }

After 212 lượt xem

Gõ tìm kiếm nhanh...