Instantiateで生成したオブジェクトAを他スクリプトから破壊しようとしています
すると以下のようなエラーが出てしまいました
Destroying assets is not permitted to avoid data loss.
If you really want to remove an asset use DestroyImmediate (theObject, true);
リンク内容
そこで調べ↑のように変えてみたのが以下のコードです
●オブジェクトA生成&破壊メソッド呼び出し
using UnityEngine; using System.Collections; using System.Collections.Generic; public class aaa : MonoBehaviour { public GameObject A1; public void Create() { GameObject A= Instantiate(A1, new Vector3(transform.position.x, 0.01f, transform.position.z + 1), Quaternion.identity) as GameObject; } } void Update() { if (Input.GetMouseButtonDown(0)) { A1.GetComponent<B>().destroy(); } }
●破壊するオブジェクトにアタッチ
using System.Collections; using System.Collections.Generic; using UnityEngine; public class B: MonoBehaviour { public void destroy() { Destroy(gameObject); }
しかしこれでもvisualstudio側のエラーはないのですが、Unityでの上記のエラーがまだ出ています
この時どのような間違いが考えられますか?
またどのようにすれば解決できますか?

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/05/05 12:48
2018/05/05 13:13 編集
2018/05/05 13:21
2018/05/05 13:27