我是编程和Unity
的新手,所以也许我有一个简单的问题,但我陷入其中。
我有一个导入到. FBX
的Unity
文件。我必须通过脚本仅在editor
中完成所有工作。我正在尝试从中制作一个prefab
,并制作一个GameObject
。我正在尝试的所有方法都给出了错误-就像对象是null
(当我将其放在文件夹中时)还是无法将persistent object
保存为Prefab
asset
。任何想法,我怎么能弄错点?这是我尝试的方法。
GameObject objToPrefab = AssetDatabase.LoadAssetAtPath("Assets/Resources/" + "/wolf.fbx",
typeof(GameObject)) as GameObject;
PrefabUtility.CreatePrefab("Assets/Resource/" + "/" + ".prefab", objToPrefab);
或这一个
var obj = GameObject.Instantiate(Resources.Load(string.Format("fbx/{0}/{0}_model", name))) as GameObject;
GameObject obj = GameObject.Instantiate(AssetDatabase.LoadAssetAtPath("Assets/Models/121212", GetAsset("Assets/Models/121212").GetType() )) as GameObject;
或
var MyObj = Resources.Load("wolf") as GameObject; GameObject.Instantiate(MyObj);
好的,我怎么想
var myVector = new Vector3(0.0f, 1.0f, 0.0f);
var obj = GameObject.Instantiate(Resources.Load("Wolf"), myVector, Quaternion.identity) as GameObject;