mirror of
https://github.com/m-lamonaca/dev-notes.git
synced 2025-05-14 23:24:46 +00:00
Upload of pre-existing files
This commit is contained in:
commit
4c21152830
150 changed files with 730703 additions and 0 deletions
14
.NET/Unity/Prefabs Instantiation.md
Normal file
14
.NET/Unity/Prefabs Instantiation.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Prefabs
|
||||
|
||||
Prefabs are a blueprint for GameObcets and any change made to the prefab is inherited by all it's instances.
|
||||
|
||||
## Script Instantation
|
||||
|
||||
```cs
|
||||
|
||||
public GameObject prefab; // reference to the prefab
|
||||
|
||||
// instantiate a game GameObject from the prefab with specified position and rotation (rotation must be a quaternion)
|
||||
GameObject newInstance = (GameObject) Instantiate(prefab, positionVector3, Quaternion.Euler(rotationVector3)); // instantiate prefab and get reference to instance
|
||||
// Instance returns a object and since a GameObject was passed to Instantiate() the returned object can be casted to a GameObject
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue