1.Unity的几种事件用法
①event
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEngine.UI;
using UnityEngine.Events;
public class CollisinEvent : UnityEvent<GameObject, GameObject> { }
public class HelloWorld:MonoBehaviour
{
CollisinEvent collisinEvent = new CollisinEvent();
private void OnCollisionEnter(Collision collision)
{
collisinEvent.Invoke(gameObject, collision.gameObject);
}
public void AddEvent(UnityAction<GameObject, GameObject> action)
{
collisinEvent.AddListener(action);
}
}
这种用法可以用在rpg游戏的主角上,在主角上挂一个event,在将要碰撞的object上调用主角Addevent方法添加事件
②UnityAction
public UnityAction<int, string> action = ((int a, string b) =>
{
Debug.Log("1111111");
});
③Action
Action<int> action2;
action2 += (int a) => { };
关于UnityAction和Action的区别
把物体模型放进了场景里之后, 引擎会计算光线,光线照到你的物体的表面形成反光和阴影。 如果不烘焙, 游戏运行的时候,这些反光和阴影都是由显卡和CPU计算出来的。你烘焙之后,这些反光和阴影都记录到了你的模型里,变成了新的贴图了,运行的时候,显卡和CPU不需要进行对环境光效果的运算了。
3.Render Texture