123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- [ExecuteInEditMode]
- public class UIScratchable : MonoBehaviour
- {
- // Start is called before the first frame update
- private float Wide_X;
- private float Lenth_z;
- private float high_y;
- public Vector3 ScalPos=new Vector3(1f,1f,1f);
- private float Pos_X;
- private float Pos_z;
- float Multiple_X;
- float Multiple_Z;
- private float Scaleline = 0.1f;
- private float UDline = 0.1f;
- private void Awake()
- {
- ScalPos = new Vector3(this.transform.localScale.x*10, this.transform.localScale.y*10,this.transform.localScale.z*10);
-
- Wide_X = ScalPos.x / 10;
- Lenth_z = ScalPos.y / 10;
- high_y = ScalPos.z / 10;
- Pos_X = this.gameObject.transform.localScale.x;
- Pos_z = this.gameObject.transform.localScale.z;
- this.gameObject.transform.localScale = new Vector3(Wide_X, Lenth_z, this.gameObject.transform.localScale.y);
- AngleManaage();
- }
-
-
- void Update()
- {
- Wide_X = ScalPos.x / 10;
- Lenth_z = ScalPos.y / 10;
- high_y = ScalPos.z / 10;
- this.gameObject.transform.localScale = new Vector3(Wide_X, Lenth_z, high_y);
- if (Wide_X > 0 && Lenth_z > 0)
- {
- AngleManaage();
- }
- }
- public void AngleManaage()
- {
- //Debug.Log(Wide_X + "哈哈" + Pos_X);
- //Debug.Log(Lenth_z + "z轴" + Pos_z);
- Multiple_X = Wide_X / 0.1f;
-
- Multiple_Z = Lenth_z / 0.1f;
-
- float Angle_x = 1f / Multiple_X;
-
- float Angle_z = 1f / Multiple_Z;
- //Debug.Log(Angle_x + "XXXXXXXXXXXXXX" + Multiple_X);
- //Debug.Log(Angle_z + "@@@@@@@@@@@" + Multiple_Z);
- this.transform.GetChild(0).GetChild(4).transform.localScale = new Vector3(Angle_x, 1, Angle_z);
- this.transform.GetChild(0).GetChild(5).transform.localScale = new Vector3(Angle_x, 1, Angle_z);
- this.transform.GetChild(0).GetChild(6).transform.localScale = new Vector3(Angle_x, 1, Angle_z);
- this.transform.GetChild(0).GetChild(7).transform.localScale = new Vector3(Angle_x, 1, Angle_z);
- Scaleline = Angle_z;
- UDline = Angle_x;
-
- LeftRightManage(Angle_z);
- UPdownManage(UDline);
- }
- public void LeftRightManage(float bb)
- {
-
- float a = 1 - Scaleline;
- // Debug.Log("&&&&&&&&&&&&&&&&&&&&&&&&& " + a);
- this.transform.GetChild(0).GetChild(0).transform.localScale = new Vector3(1, 1, 7 + a);
- this.transform.GetChild(0).GetChild(1).transform.localScale = new Vector3(1, 1, 7 + a);
- }
- public void UPdownManage(float cc)
- {
- float a = 1 - UDline;
- // Debug.Log("&&&&&&&&&&&&&&&&&&&&&&&&& " + a);
- this.transform.GetChild(0).GetChild(2).transform.localScale = new Vector3(7 + a, 1, 1);
- this.transform.GetChild(0).GetChild(3).transform.localScale = new Vector3(7 + a, 1, 1);
- }
- }
|