场景视图的操作:
飞行模式: 按住鼠标右键 w s a d 前后左右浏览当前视图 q e 上下浏览, 正交模式下无效 需透视图
移动吸附:移动状态(w) ctrl+shif 移动吸附在其他物体上移动
顶点吸附:移动状态(w)v 键 移动吸附在其他物体上移动
特定的增量移动: 移动状态(w) ctrl ,按特定的增量移动, 可以设置增量 Edit-snapSettings.
Unity脚本的使用
void Start () {
ScriptB sb = GetComponent();
sb.Say();
}
void Update () {
this.transform.Rotate(new Vector3(0,speed * Time.deltaTime,0));
rigidbody.mass = Mathf.Sin(Time.deltaTime)+1;
}
void Update () {
target.renderer.material.color = Color.red;
}
/////
public GameObject target;
void Start () {
target = GameObject.Find("Main Camera/sphere");
}
arget = GameObject.FindWithTag("fuck");
GameObject.FindGameObjectWithTag("fuck"
GameObject.FindGameObjectsWithTag("fuck"); 多个
void OnGUI()
{
GUILayout.Label("当前时间:" + Time.time);
GUILayout.Label("自上一帧时间:" + Time.deltaTime);
GUILayout.Label("固定增量时间:" + Time.fixedTime);
GUILayout.Label("固定增量时间间隔:" + Time.fixedDeltaTime);
GUILayout.Label("平滑delata时间:" + Time.smoothDeltaTime);
//增量时间可以在edit-projectSetting-time中设置
}
void Start () {
StartCoroutine("Example"); //用StartCoroutine进行触发
print("Hello");
print ("world");
}
//所有使用yield的函数必须将返回值类型设置为IEnumerator类型
IEnumerator Example() {
print(Time.time);
yield return new WaitForSeconds(2);
print(Time.time);
}
void Start () {
print(Random.seed);
print(Random.value);
print(Random.Range(0,1));
print(Random.Range(0.0f,1.0f));
}
public class SendMessageUpward : MonoBehaviour {
void OnMouseOver()
{
SendMessageUpwards("someoneSay","fuck u");
}
}
public class RecieveMessage : MonoBehaviour {
void someoneSay(string str)
{
print("someoneSaied" +str);
}
}
public class EventDispatcher : MonoBehaviour {
public delegate void EventHandler();
public event EventHandler MouseOver;
void OnMouseOver()
{
if(MouseOver != null)
{
MouseOver();
}
}
}
public class EventListener : MonoBehaviour {
public GameObject dispatcher;
// Use this for initialization
void Start () {
EventDispatcher ds = dispatcher.GetComponent();
ds.MouseOver +=Listen;
}
void Listen()
{
transform.Rotate(new Vector3(0,10*Time.deltaTime,0));
transform.renderer.material.color = Color.cyan;
}
}