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


C# IUIListObject.UpdateCollider方法代码示例

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


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

示例1: InsertItem

	/// <summary>
	/// Inserts a list item at the specified position in the list.
	/// </summary>
	/// <param name="item">Reference to the item to be inserted into the list.</param>
	/// <param name="position">0-based index of the position in the list where the item will be placed.</param>
	/// <param name="text">Text to display in the item (requires that the item has a TextMesh associated with it, preferably in a child GameObject).</param>
	public void InsertItem(IUIListObject item, int position, string text)
	{
		IUIListObject lastItem;
		float contentDelta;

		// Make sure Awake() has already run:
		if (!m_awake)
			Awake();

		// Make sure Start() has already run:
		if (!m_started)
			Start();

		// See if the item needs to be enabled:
		if (activateWhenAdding)
		{
			if (!((Component)item).gameObject.active)
				((Component)item).gameObject.SetActiveRecursively(true);
		}

		// Now deactivate again if the list itself is deactivated:
		if(!gameObject.active)
			((Component)item).gameObject.SetActiveRecursively(false);

		// Put the item in the correct layer:
		item.gameObject.layer = gameObject.layer;

		// Add the item to our container:
		if (container != null)
			container.AddChild(item.gameObject);


		//-------------------------------------
		// Position our item:
		//-------------------------------------
		item.transform.parent = mover.transform;
#if AUTO_ORIENT_ITEMS
		item.transform.localRotation = Quaternion.identity;
#endif
#if AUTO_SCALE_ITEMS
		item.transform.localScale = Vector3.one;
#endif
		// Go ahead and get the item in the mover's plane
		// on the local Z-axis.  This must be done here
		// before anything that follows because if we are
		// using a perspective camera and these are newly
		// created items, their Start() will be called for
		// the first time when FindOuterEdges() is called
		// either by us, or by the Text property, and if
		// the item isn't already positioned relative to
		// the camera, then its size will be calculated
		// wrong.
		item.transform.localPosition = Vector3.zero;

		item.SetList(this);

		if (text != null)
			item.Text = text;

		// Compute the edges of the item:
		item.FindOuterEdges();
		item.UpdateCollider();
		

		// Clamp our position:
		position = Mathf.Clamp(position, 0, items.Count);

		// Hide the item by default:
		if(clipContents)
		{
			item.Hide(true);
			if (!item.Managed)
				item.gameObject.SetActiveRecursively(false);
		}

		// See if we can just add it to the end:
		if(position == items.Count)
		{
			float x=0, y=0;
			bool addItemSpacing = false;

			if (orientation == ORIENTATION.HORIZONTAL)
			{
				// Find the X-coordinate:
				if (items.Count > 0)
				{
					addItemSpacing = true; // We will be adding itemSpacing

					lastItem = items[items.Count - 1];

					if (direction == DIRECTION.TtoB_LtoR)
						x = lastItem.transform.localPosition.x + lastItem.BottomRightEdge.x + itemSpacing - item.TopLeftEdge.x;
					else
						x = lastItem.transform.localPosition.x - lastItem.BottomRightEdge.x - itemSpacing + item.TopLeftEdge.x;
//.........这里部分代码省略.........
开发者ID:AlexanderUrbano,项目名称:shapewars,代码行数:101,代码来源:UIScrollList.cs

示例2: InsertItem

	/// <summary>
	/// Inserts a list item at the specified position in the list.
	/// </summary>
	/// <param name="item">Reference to the item to be inserted into the list.</param>
	/// <param name="position">0-based index of the position in the list where the item will be placed.</param>
	/// <param name="text">Text to display in the item (requires that the item has a TextMesh associated with it, preferably in a child GameObject).</param>
	public void InsertItem(IUIListObject item, int position, string text)
	{
		IUIListObject lastItem;
		float contentDelta;

		// Make sure Start() has already run:
		if (!m_started)
			Start();

		// See if the item needs to be enabled:
		if(activateWhenAdding)
			if (!((Component)item).gameObject.active)
				((Component)item).gameObject.SetActiveRecursively(true);

		// Put the item in the correct layer:
		item.gameObject.layer = gameObject.layer;

		// Add the item to our container:
		if (container != null)
			container.AddChild(item.gameObject);


		//-------------------------------------
		// Position our item:
		//-------------------------------------
		item.transform.parent = mover.transform;
#if AUTO_ORIENT_ITEMS
		item.transform.localRotation = Quaternion.identity;
#endif
#if AUTO_SCALE_ITEMS
		item.transform.localScale = Vector3.one;
#endif
		// Go ahead and get the item in the mover's plane
		// on the local Z-axis.  This must be done here
		// before anything that follows because if we are
		// using a perspective camera and these are newly
		// created items, their Start() will be called for
		// the first time when FindOuterEdges() is called
		// either by us, or by the Text property, and if
		// the item isn't already positioned relative to
		// the camera, then its size will be calculated
		// wrong.
		item.transform.localPosition = Vector3.zero;


		if(text != null)
			item.Text = text;

		item.SetList(this);

		// Compute the edges of the item:
		item.FindOuterEdges();
		item.UpdateCollider();
		

		// Clamp our position:
		position = Mathf.Clamp(position, 0, items.Count);

		// Hide the item by default:
		item.Hide(true);
		if (!item.Managed)
			item.gameObject.SetActiveRecursively(false);

		// See if we can just add it to the end:
		if(position == items.Count)
		{
			if (orientation == ORIENTATION.HORIZONTAL)
			{

				if (items.Count > 0)
				{
					lastItem = items[items.Count - 1];
					item.transform.localPosition = new Vector3(lastItem.transform.localPosition.x + lastItem.BottomRightEdge.x + itemSpacing - item.TopLeftEdge.x, 0);
				}
				else
				{
					item.transform.localPosition = new Vector3((viewableArea.x * -0.5f) - item.TopLeftEdge.x + itemSpacing, 0);
				}

				contentDelta = item.BottomRightEdge.x - item.TopLeftEdge.x + itemSpacing;
			}
			else
			{
				if (items.Count > 0)
				{
					lastItem = items[items.Count - 1];
					item.transform.localPosition = new Vector3(0, lastItem.transform.localPosition.y + lastItem.BottomRightEdge.y - itemSpacing - item.TopLeftEdge.y);
				}
				else
				{
					item.transform.localPosition = new Vector3(0, (viewableArea.y * 0.5f) - item.TopLeftEdge.y - itemSpacing);
				}
				contentDelta = item.TopLeftEdge.y - item.BottomRightEdge.y + itemSpacing;
			}
//.........这里部分代码省略.........
开发者ID:robert-irribarren,项目名称:TraumaOR,代码行数:101,代码来源:UIScrollList.cs


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