当前位置: 首页>>代码示例>>C#>>正文


C# View.SetFocus方法代码示例

本文整理汇总了C#中View.SetFocus方法的典型用法代码示例。如果您正苦于以下问题:C# View.SetFocus方法的具体用法?C# View.SetFocus怎么用?C# View.SetFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在View的用法示例。


在下文中一共展示了View.SetFocus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnViewCreatedHandler

		public void OnViewCreatedHandler(View view)
		{
			m_View = view;
			#if UNITY_EDITOR || COHERENT_UNITY_STANDALONE
	        m_View.SetFocus();
			
			var cameraComponent = m_ViewComponent.gameObject.camera;
			
			var id = m_View.GetId();
			if(cameraComponent)
			{
				ViewRenderer = cameraComponent.gameObject.AddComponent("CoherentUIViewRenderer") as CoherentUIViewRenderer;
				// this is only supported for Views directly attached to cameras
				ViewRenderer.DrawAfterPostEffects = m_ViewComponent.DrawAfterPostEffects;
				
				// make sure added components are destroyed too
				m_ObjectsToDestroy.Add(ViewRenderer);
			}
			else
			{
				var renderingCamera = new GameObject("CoherentRenderingCamera" + id);
				var newCameraComponent = renderingCamera.AddComponent("Camera") as Camera;
				newCameraComponent.clearFlags = CameraClearFlags.SolidColor;
				newCameraComponent.backgroundColor = new Color(0, 0, 0, 0);
				ViewRenderer = renderingCamera.AddComponent("CoherentUIViewRenderer") as CoherentUIViewRenderer;
				
				m_ObjectsToDestroy.Add(renderingCamera);
				
				RTTexture = new RenderTexture(m_Width, m_Height, 1, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
				m_ObjectsToDestroy.Add(RTTexture);
				RTTexture.name = "CoherentRenderingRTT" + id;
				newCameraComponent.targetTexture = RTTexture;
				newCameraComponent.cullingMask = 0;
				
				var shader = Shader.Find(m_ViewComponent.IsTransparent ? "Transparent/Diffuse" : "Diffuse");
				if (shader == null)
				{
					throw new System.ApplicationException("Unable to find shader for generated material!");
				}
				var RTMaterial = new Material(shader);
				m_ObjectsToDestroy.Add(RTMaterial);
				RTMaterial.mainTexture = RTTexture;
				RTMaterial.name = "CoherentMaterialRTT" + id;
				m_ViewComponent.gameObject.renderer.material = RTMaterial;
										
				renderingCamera.transform.parent = m_ViewComponent.gameObject.transform;
			}
			
			ViewRenderer.ViewId = (short)id;
			var flipY =  m_ViewComponent.FlipY;
			ViewRenderer.FlipY = m_ViewComponent.ForceInvertY() ? !flipY : flipY;
			#endif
		}
开发者ID:Charkova,项目名称:MetaEden.a14,代码行数:53,代码来源:ViewListener.cs


注:本文中的View.SetFocus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。