• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# UISnapshotPoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UISnapshotPoint的典型用法代码示例。如果您正苦于以下问题:C# UISnapshotPoint类的具体用法?C# UISnapshotPoint怎么用?C# UISnapshotPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UISnapshotPoint类属于命名空间,在下文中一共展示了UISnapshotPoint类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SetupSnapshotCamera

	/// <summary>
	/// Set up the camera using the provided snapshot point's values.
	/// </summary>

	static void SetupSnapshotCamera (GameObject go, Camera cam, UISnapshotPoint point)
	{
		Vector3 pos = point.transform.localPosition;
		Quaternion rot = point.transform.localRotation;
		Transform t = go.transform;

		if (t.parent != null)
		{
			pos = t.parent.TransformPoint(pos);
			rot = t.parent.rotation * rot;
		}

		cam.transform.position = pos;
		cam.transform.rotation = rot;
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
		cam.isOrthoGraphic = point.isOrthographic;
#else
		cam.orthographic = point.isOrthographic;
#endif
		cam.nearClipPlane = point.nearClip;
		cam.farClipPlane = point.farClip;
		cam.orthographicSize = point.orthoSize;
		cam.fieldOfView = point.fieldOfView;
	}
开发者ID:ivanchan2,项目名称:SRW_Project,代码行数:28,代码来源:UIPrefabTool.cs


示例2: SetupPreviewFor3D

	/// <summary>
	/// Set up everything necessary to preview a UI object.
	/// </summary>

	static bool SetupPreviewFor3D (Camera cam, GameObject root, GameObject child, UISnapshotPoint point)
	{
		Renderer[] rens = child.GetComponentsInChildren<Renderer>();
		if (rens.Length == 0) return false;

		Vector3 camDir = new Vector3(-0.25f, -0.35f, -0.5f);
		Vector3 lightDir = new Vector3(-0.25f, -0.5f, -0.25f);

		camDir.Normalize();
		lightDir.Normalize();

		// Determine the bounds of the model
		Renderer ren = rens[0];
		Bounds bounds = ren.bounds;
		int mask = (1 << ren.gameObject.layer);

		for (int i = 1; i < rens.Length; ++i)
		{
			ren = rens[i];
			mask |= (1 << ren.gameObject.layer);
			bounds.Encapsulate(ren.bounds);
		}

		// Set the camera's properties
		cam.cullingMask = mask;
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
		cam.isOrthoGraphic = true;
#else
		cam.orthographic = true;
#endif
		cam.transform.position = bounds.center;
		cam.transform.rotation = Quaternion.LookRotation(camDir);

		float objSize = bounds.size.magnitude;
		if (point != null) SetupSnapshotCamera(child, cam, point);
		else SetupSnapshotCamera(child, cam, objSize, objSize * 0.4f, -objSize, objSize);

		// Deactivate all scene lights
		DeactivateLights();

		// Create our own light
		GameObject lightGO = NGUITools.AddChild(root);
		Light light = lightGO.AddComponent<Light>();
		light.type = LightType.Directional;
		light.shadows = LightShadows.None;
		light.color = Color.white;
		light.intensity = 0.65f;
		light.transform.rotation = Quaternion.LookRotation(lightDir);
		light.cullingMask = mask;
		return true;
	}
开发者ID:ivanchan2,项目名称:SRW_Project,代码行数:55,代码来源:UIPrefabTool.cs


示例3: GeneratePreview

	/// <summary>
	/// Generate an item preview for the specified item.
	/// </summary>

	void GeneratePreview (Item item, UISnapshotPoint point)
	{
		if (item == null || item.prefab == null) return;

		if (point == null) point = GetSnapshotPoint(item.prefab.transform);

		if (point != null && point.thumbnail != null)
		{
			Debug.Log(2);
			// Explicitly chosen thumbnail
			item.tex = point.thumbnail;
			item.dynamicTex = false;
			return;
		}
		else if (!UnityEditorInternal.InternalEditorUtility.HasPro())
		{
			// Render textures only work in Unity Pro
			string path = "Assets/NGUI/Editor/Preview/" + item.prefab.name + ".png";
			item.tex = File.Exists(path) ? (Texture2D)AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D)) : null;
			item.dynamicTex = false;
			return;
		}

		int dim = (cellSize - 4) * 2;

		// Asset Preview-based approach is unreliable, and most of the time fails to provide a texture.
		// Sometimes it even throws null exceptions.
		//item.tex = AssetPreview.GetAssetPreview(item.prefab);
		//item.dynamicTex = false;
		//if (item.tex != null) return;

		// Let's create a basic scene
		GameObject root = EditorUtility.CreateGameObjectWithHideFlags(
				"Preview Root", HideFlags.HideAndDontSave);

		GameObject camGO = EditorUtility.CreateGameObjectWithHideFlags(
			"Preview Camera", HideFlags.HideAndDontSave, typeof(Camera));

		// Position it far away so that it doesn't interfere with existing objects
		root.transform.position = new Vector3(0f, 0f, 10000f);
		root.layer = item.prefab.layer;

		// Set up the camera
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
		Camera cam = camGO.camera;
		cam.isOrthoGraphic = true;
#else
		Camera cam = camGO.GetComponent<Camera>();
		cam.orthographic = true;
#endif
		cam.renderingPath = RenderingPath.Forward;
		cam.clearFlags = CameraClearFlags.Skybox;
		cam.backgroundColor = new Color(0f, 0f, 0f, 0f);
		cam.targetTexture = (item.tex as RenderTexture);
		cam.enabled = false;

		// Finally instantiate the prefab as a child of the root
		GameObject child = NGUITools.AddChild(root, item.prefab);

		// Try to find the snapshot point script
		if (point == null) point = child.GetComponentInChildren<UISnapshotPoint>();

		// If there is a UIRect present (widgets or panels) then it's an NGUI object
		RenderTexture rt = (SetupPreviewForUI(cam, root, child, point) || SetupPreviewFor3D(cam, root, child, point)) ?
			cam.RenderToTexture(dim, dim) : null;

		// Did we have a different render texture? Get rid of it.
		if (item.tex != rt && item.tex != null && item.dynamicTex)
		{
			NGUITools.DestroyImmediate(item.tex);
			item.tex = null;
			item.dynamicTex = false;
		}

		// Do we have a new render texture? Assign it.
		if (rt != null)
		{
			item.tex = rt;
			item.dynamicTex = true;
		}

		// Clean up everything
		DestroyImmediate(camGO);
		DestroyImmediate(root);
	}
开发者ID:ivanchan2,项目名称:SRW_Project,代码行数:89,代码来源:UIPrefabTool.cs


示例4: SetupPreviewForUI

	/// <summary>
	/// Set up everything necessary to preview a UI object.
	/// </summary>

	static bool SetupPreviewForUI (Camera cam, GameObject root, GameObject child, UISnapshotPoint point)
	{
		if (child.GetComponentInChildren<UIRect>() == null) return false;

		if (child.GetComponent<UIPanel>() == null)
			root.AddComponent<UIPanel>();

		Bounds bounds = NGUIMath.CalculateAbsoluteWidgetBounds(child.transform);
		Vector3 size = bounds.extents;
		float objSize = size.magnitude;

		cam.transform.position = bounds.center;
		cam.cullingMask = (1 << root.layer);

		if (point != null) SetupSnapshotCamera(child, cam, point);
		else SetupSnapshotCamera(child, cam, objSize, Mathf.RoundToInt(Mathf.Max(size.x, size.y)), -100f, 100f);
		NGUITools.ImmediatelyCreateDrawCalls(root);
		return true;
	}
开发者ID:ivanchan2,项目名称:SRW_Project,代码行数:23,代码来源:UIPrefabTool.cs


示例5: RegenerateTexture

	/// <summary>
	/// Re-generate the specified prefab's snapshot texture using the provided snapshot point's values.
	/// </summary>

	public void RegenerateTexture (GameObject prefab, UISnapshotPoint point)
	{
		for (int i = 0; i < mItems.size; ++i)
		{
			Item item = mItems[i];

			if (item.prefab == prefab)
			{
				GeneratePreview(item, point);
				RectivateLights();
				break;
			}
		}
	}
开发者ID:ivanchan2,项目名称:SRW_Project,代码行数:18,代码来源:UIPrefabTool.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UISplitViewController类代码示例发布时间:2022-05-24
下一篇:
C# UISlider类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap