我從我的服務器下載一些精靈並將它們存儲在Application.persistentDataPath
中。從永久數據路徑加載精靈
但是,我無法使用Resources.Load (controllerPath)
加載控制器,因爲路徑在Resources文件夾之外。
此外,當我嘗試將動畫控制器添加到GameObject
時,我得到一個MissingComponentException
。
這裏是我的代碼:
private GameObject SideSprite;
// ...
string controllerPath = Application.persistentDataPath+"/"+aux+"/"+aux+"Controller";
controller = (RuntimeAnimatorController)Resources.Load (controllerPath); // Returns null
// Below I get:
// MissingComponentException: There is no 'Animator' attached to the
// "Missing Prefab (Dummy)" game object, but a script is trying to access it.
SideSprite.GetComponent<Animator>().runtimeAnimatorController = controller;
我應如何從持久性數據路徑加載的資源?