Camera
变量
公共函数
静态函数
静态函数 | 作用 |
FindObjectsOfType | 返回所有类型为 type 的已加载的激活对象的列表。 |
代码演示:
publicclassExample : MonoBehaviour{ //枚举enumRenderModeStates { camera, overlay, world }; RenderModeStatesm_RenderModeStates; //相机组件Canvasm_Canvas; voidStart() { m_Canvas=GetComponent<Canvas>(); } voidUpdate() { //Pressthespacekeytoswitchbetweenrendermodestatesif (Input.GetKeyDown(KeyCode.Space)) { ChangeState(); } } 使用switch判断voidChangeState() { switch (m_RenderModeStates) { caseRenderModeStates.camera: m_Canvas.renderMode=RenderMode.ScreenSpaceCamera; m_RenderModeStates=RenderModeStates.overlay; break; caseRenderModeStates.overlay: m_Canvas.renderMode=RenderMode.ScreenSpaceOverlay; m_RenderModeStates=RenderModeStates.world; break; caseRenderModeStates.world: m_Canvas.renderMode=RenderMode.WorldSpace; m_RenderModeStates=RenderModeStates.camera; break; } } }