示例#1
0
 /// <summary>
 /// Clone the item and syncs it over the network. This only works if toClone has a PoolPrefabTracker
 /// attached or its name matches a prefab name, otherwise we don't know what prefab to create.
 /// </summary>
 /// <param name="toClone">GameObject to clone. This only works if toClone has a PoolPrefabTracker
 /// attached or its name matches a prefab name, otherwise we don't know what prefab to create.. Intended to work for any object, but don't
 /// be surprised if it doesn't as there are LOTS of prefabs in the game which might need unique behavior for how they should spawn. If you are trying
 /// to clone something and it isn't properly setting itself up, check to make sure each component that needs to set something up has
 /// properly implemented IOnStageServer or IOnStageClient when IsCloned = true</param>
 /// <param name="worldPosition">world position to appear at. Defaults to HiddenPos (hidden / invisible)</param>
 /// <param name="localRotation">local rotation to spawn with, defaults to Quaternion.identity</param>
 /// <param name="parent">Parent to spawn under, defaults to no parent. Most things
 /// should always be spawned under the Objects transform in their matrix. Many objects (due to RegisterTile)
 /// usually take care of properly parenting themselves when spawned so in many cases you can leave it null.</param>
 /// <returns>the newly created GameObject</returns>
 public static SpawnResult ServerClone(GameObject toClone, Vector3?worldPosition = null, Transform parent = null,
                                       Quaternion?localRotation = null)
 {
     return(Server(
                SpawnInfo.Clone(toClone, SpawnDestination.At(worldPosition, parent, localRotation))));
 }