how to create instance in Unity

#1 Create Class Car.

using UnityEngine;
using System.Collections;
 
public class Car : ScriptableObject {
	public string color;
 
	void Awake(){
		color = "red";
	}
}

#2 Create instance.

using UnityEngine;
using System.Collections;
 
public class main : MonoBehaviour {
	void Start(){
		Car polo = (Car) ScriptableObject.CreateInstance(typeof(Car));
	}
}
发表评论?

0 条评论。

发表评论