現在、プロジェクトに2つのクラスがあります。
クラス 1 でメソッド クラス 2 を使用したい。
そして、このコード c#
クラス1
public class controlBuilding : MonoBehaviour
{
ScaleModel cScale = new ScaleModel();
public void Start()
{
}
public void Update()
{
cScale.touchScaleB1();
}
public void OnGUI()
{
}
}
クラス2
public class ScaleModel : MonoBehaviour
{
public void touchScaleB1()
{
if (Input.touchCount >= 2)
{
Touch touch1 = Input.touches[0];
Touch touch2 = Input.touches[1];
if (touch1.phase == TouchPhase.Moved || touch2.phase == TouchPhase.Moved)
{
float pinchDistance = Vector2.Distance(touch1.position, touch2.position);
float prevDistance = Vector2.Distance(touch1.position - touch1.deltaPosition,
touch2.position - touch2.deltaPosition);
float pinchDistanceDelta = pinchDistance - prevDistance;
if (pinchDistanceDelta > 0)
{
float mScaleFactor;
mScaleFactor = b1_floor1dae.transform.localScale.x;
mScaleFactor += 0.0004f;
b1_floor1dae.transform.localScale = new Vector3(mScaleFactor, mScaleFactor, mScaleFactor);
b1_floor2dae.transform.localScale = new Vector3(mScaleFactor, mScaleFactor, mScaleFactor);
b1_floor3dae.transform.localScale = new Vector3(mScaleFactor, mScaleFactor, mScaleFactor);
b1_floor4dae.transform.localScale = new Vector3(mScaleFactor, mScaleFactor, mScaleFactor);
b1_floorTop.transform.localScale = new Vector3(mScaleFactor, mScaleFactor, mScaleFactor);
b1_other.transform.localScale = new Vector3(mScaleFactor, mScaleFactor, mScaleFactor);
}
else if (pinchDistanceDelta < 0)
{
float mScaleFactor;
mScaleFactor = b1_floor1dae.transform.localScale.x;
mScaleFactor -= 0.0004f;
b1_floor1dae.transform.localScale = new Vector3(mScaleFactor, mScaleFactor, mScaleFactor);
b1_floor2dae.transform.localScale = new Vector3(mScaleFactor, mScaleFactor, mScaleFactor);
b1_floor3dae.transform.localScale = new Vector3(mScaleFactor, mScaleFactor, mScaleFactor);
b1_floor4dae.transform.localScale = new Vector3(mScaleFactor, mScaleFactor, mScaleFactor);
b1_floorTop.transform.localScale = new Vector3(mScaleFactor, mScaleFactor, mScaleFactor);
b1_other.transform.localScale = new Vector3(mScaleFactor, mScaleFactor, mScaleFactor);
}
}
}
}
}
画面のタッチがイベントではないのはなぜですか? 間違ったコードはどこですか?
すみません、私は英語が苦手です。
回答ありがとうございました。