SHOECASE.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SHOWCASE : MonoBehaviour {
public int a = 1, b = 2;
public float c = 3.1415926f;
private float d = 1.41421f;
public bool showme = true;
// Use this for initialization
void Start () {
Debug.Log (a + b);
Debug.Log ("a+b is equal to:" + (a + b).ToString ());
}
// Update is called once per frame
void Update () {
if (showme)
Debug.Log ("Here I am");
}
}
empty 界面变量赋值
Interface variable assignment
MoveShere.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveSphere : MonoBehaviour {
public Transform startMarker;//Interface variable assignment
public Transform endMarker;
public float speed = 0.05f;
private float startTime;
private float journeyLength;//the distance between the sphere and the cube.
// Use this for initialization
void Start () {
startTime = Time.time;
journeyLength = Vector3.Distance (startMarker.position, endMarker.position);
}
// Update is called once per frame
void Update () {
//sphere's transform.position球的位置
float distCovered=(Time.time-startTime)+speed;
float fracJourney=distCovered/journeyLength;
//float fracJourney=0.9f;
Debug.Log(fracJourney);
this.transform.position = Vector3.Lerp(startMarker.position, endMarker.position, fracJourney);
}
}
public a,b,c都是界面变量
inspector面板这个界面中显示出来
当你的程序运行以后,通过改变界面变量的值
利用界面变量进行交互式控制
Transform组件component
Transform类:帮助我们进行对象的位置,大小,角度控制
界面变量赋值Interface variable assignment