Question by
agiro · Jul 11, 2017 at 12:14 PM ·
performancecopyinstantiate-game-object
Instantiating game objects - shallow or full copy?
Let's say I have this short script here, found on a Unity official site:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public Rigidbody projectile;
void Update() {
if (Input.GetButtonDown("Fire1")) {
Rigidbody clone;
clone = Instantiate(projectile, transform.position, transform.rotation) as Rigidbody;
clone.velocity = transform.TransformDirection(Vector3.forward * 10);
}
}
}
I would like to know if Instantiate
creates a full or a shallow copy? AFAIK a shallow copy doesn't eat up as much memory as a full one and that is what I'll need. If this creates a full copy, how to create just a shallow one? Thanks in advance.
Comment