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


C# tk2dCamera.GetComponent方法代码示例

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


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

示例1: DrawCameraGUI

	void DrawCameraGUI(tk2dCamera target, bool complete) {
		bool allowProjectionParameters = target.SettingsRoot == target;
		bool oldGuiEnabled = GUI.enabled;

		SerializedObject so = this.serializedObject;
		SerializedObject cam = new SerializedObject( target.GetComponent<Camera>() );

		SerializedProperty m_ClearFlags = cam.FindProperty("m_ClearFlags");
		SerializedProperty m_BackGroundColor = cam.FindProperty("m_BackGroundColor");
		SerializedProperty m_CullingMask = cam.FindProperty("m_CullingMask");
		SerializedProperty m_TargetTexture = cam.FindProperty("m_TargetTexture");
		SerializedProperty m_Near = cam.FindProperty("near clip plane");
		SerializedProperty m_Far = cam.FindProperty("far clip plane");
		SerializedProperty m_Depth = cam.FindProperty("m_Depth");
		SerializedProperty m_RenderingPath = cam.FindProperty("m_RenderingPath");
		SerializedProperty m_HDR = cam.FindProperty("m_HDR");

		if (complete) {
			EditorGUILayout.PropertyField( m_ClearFlags );
			EditorGUILayout.PropertyField( m_BackGroundColor );
			EditorGUILayout.PropertyField( m_CullingMask );
			EditorGUILayout.Space();
		}

		tk2dCameraSettings cameraSettings = target.CameraSettings;
		tk2dCameraSettings inheritedSettings = target.SettingsRoot.CameraSettings;
		TransparencySortMode transparencySortMode = inheritedSettings.transparencySortMode;

		GUI.enabled &= allowProjectionParameters;
		inheritedSettings.projection = (tk2dCameraSettings.ProjectionType)EditorGUILayout.EnumPopup("Projection", inheritedSettings.projection);
		EditorGUI.indentLevel++;
		if (inheritedSettings.projection == tk2dCameraSettings.ProjectionType.Orthographic) {
			inheritedSettings.orthographicType = (tk2dCameraSettings.OrthographicType)EditorGUILayout.EnumPopup("Type", inheritedSettings.orthographicType);
			switch (inheritedSettings.orthographicType) {
				case tk2dCameraSettings.OrthographicType.OrthographicSize:
					inheritedSettings.orthographicSize = Mathf.Max( 0.001f, EditorGUILayout.FloatField("Orthographic Size", inheritedSettings.orthographicSize) );
					break;
				case tk2dCameraSettings.OrthographicType.PixelsPerMeter:
					inheritedSettings.orthographicPixelsPerMeter = Mathf.Max( 0.001f, EditorGUILayout.FloatField("Pixels per Meter", inheritedSettings.orthographicPixelsPerMeter) );
					break;
			}
			inheritedSettings.orthographicOrigin = (tk2dCameraSettings.OrthographicOrigin)EditorGUILayout.EnumPopup("Origin", inheritedSettings.orthographicOrigin);
		}
		else if (inheritedSettings.projection == tk2dCameraSettings.ProjectionType.Perspective) {
			inheritedSettings.fieldOfView = EditorGUILayout.Slider("Field of View", inheritedSettings.fieldOfView, 1, 179);
			transparencySortMode = (TransparencySortMode)EditorGUILayout.EnumPopup("Sort mode", transparencySortMode);
		}
		EditorGUI.indentLevel--;
		GUI.enabled = oldGuiEnabled;

		if (complete) {
			EditorGUILayout.Space();
			GUILayout.Label("Clipping Planes");
			GUILayout.BeginHorizontal();
			GUILayout.Space(14);
			GUILayout.Label("Near");
			if (m_Near != null) EditorGUILayout.PropertyField(m_Near, GUIContent.none, GUILayout.Width(60) );
			GUILayout.Label("Far");
			if (m_Far != null) EditorGUILayout.PropertyField(m_Far, GUIContent.none, GUILayout.Width(60) );
			GUILayout.EndHorizontal();
			cameraSettings.rect = EditorGUILayout.RectField("Normalized View Port Rect", cameraSettings.rect);

			EditorGUILayout.Space();
			if (m_Depth != null) EditorGUILayout.PropertyField(m_Depth);
			if (m_RenderingPath != null) EditorGUILayout.PropertyField(m_RenderingPath);
			if (m_TargetTexture != null) EditorGUILayout.PropertyField(m_TargetTexture);
			if (m_HDR != null) EditorGUILayout.PropertyField(m_HDR);
		}

		cam.ApplyModifiedProperties();
		so.ApplyModifiedProperties();

		if (transparencySortMode != inheritedSettings.transparencySortMode) {
			inheritedSettings.transparencySortMode = transparencySortMode;
			target.GetComponent<Camera>().transparencySortMode = transparencySortMode; // Change immediately in the editor
			EditorUtility.SetDirty(target);
			EditorUtility.SetDirty(target.GetComponent<Camera>());
		}
	}
开发者ID:berenkusmenoglu,项目名称:Core,代码行数:79,代码来源:tk2dCameraEditor.cs


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