前提・実現したいこと
オブジェクトRight1
を1秒間クリックされなかった場合プログラムから自動的に破壊する。
(クリックした場合オブジェクトはその瞬間破壊される)
発生している問題・エラーメッセージ
Destroying assets is not permitted to avoid data loss. If you really want to remove an asset use DestroyImmediate (theObject, true); UnityEngine.Object:Destroy(Object) Instantiate1:DelayMethod() (at Assets/Sample/Script/Instantiate1.cs:46)
該当のソースコード
C#
1using UnityEngine; 2using UnityEngine.UI; 3 4public class Instantiate1 : MonoBehaviour 5{ 6 bool twice; 7 public GameObject Right1; 8 void Start() 9 { 10 twice = true; 11 } 12 13 void Update() 14 { 15 if (twice == true) 16 { 17 Instantiate(original: Right1, position: new Vector3(0.0f, 0.0f, 0.0f), rotation: Quaternion.identity); 18 Invoke("DelayMethod", 1.0f); 19 twice = false; 20 } 21 } 22 23 void DelayMethod() 24 { 25 Destroy(Right1.gameObject); 26 } 27} 28 29
###補足
オブジェクトRight1
をクリックすると破壊されるプログラムは別のスクリプトにすでに記載済み
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。