-4
我有从另一个脚本引用功能的问题。我真的不知道该怎么做。我寻找解决方案,但我不明白这一点。 有人可以说我做错了什么吗?从另一个脚本引用功能
第一个脚本[dotykxd.cs]:
using UnityEngine;
using System.Collections;
public class dotykxd : MonoBehaviour {
void Start()
{
}
// Use this for initialization
// Update is called once per frame
void Update() {
if(Input.touches.Length <=0)
{
}
else{
for(int i=0; i< Input.touchCount;i++)
{
if(this.guiTexture.HitTest(Input.GetTouch(i).position))
{/*
if(Input.GetTouch(i).phase == TouchPhase.Began)
{
Camera.main.backgroundColor=Color.black;
}*/
if(Input.GetTouch(i).phase == TouchPhase.Ended)
{
obrot obrotek= GetComponents<obrot>();
obrot.obr();
}
}
}
}
}
}
另一个脚本[obrot.cs]
using UnityEngine;
using System.Collections;
public class obrot : MonoBehaviour {
public float speed = 5f;
// Update is called once per frame
void Update() {
obr();
}
void obr()
{
transform.Translate(new Vector3(1,0,0) * speed * Time.deltaTime);
}
}