タグ付けされたオブジェクトに衝突時、大きくなった後、元のサイズに戻る。という演出の処理を考えました。
実行した際に、反転してしまう。小さくなってしまうという問題が発生し、判定処理を挟む事で解決できるのではないかと思い、置いてみたのですが思った形になりませんでした。
iTweenの使い方を把握しきれてなく、このような実装の仕方をしてしまっています。。
C#
1using System.Collections.Generic; 2using UnityEngine; 3using UnityEngine.UI; 4 5public class LeafUI : MonoBehaviour { 6 7 8 public Text LeafCountText;//Leaf取得時増減用 9 public GameObject LeafObj; 10 public float LeafMagnetPower;//マグネットパワー用変数 11 public bool UIscale_check;//UI拡縮判定用変数 12 13 14 public static LeafUI leaf_instance; 15 16 // Use this for initialization 17 void Start () { 18 leaf_instance = this; 19 UIscale_check = false; 20 } 21 22 // Update is called once per frame 23 void Update () { 24 25 } 26 void OnTriggerEnter2D(Collider2D collision) 27 { 28 var UI_transform = transform.localScale; 29 30 if (collision.gameObject.tag =="Leaf") 31 { 32 UI_transform = new Vector3(2f, 2f, 0);//衝突時拡大 33 Debug.Log("大きくなったよ"); 34 UIscale_check = true; 35 } 36 if(UIscale_check) 37 { 38 UI_transform = new Vector3(-2f, -2f, 0);//判定後縮小 39 Debug.Log("小さくなったよ"); 40 } 41 } 42} 43
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。