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


C# Transform.SetSiblingIndex方法代码示例

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


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

示例1: Update

	private void Update()
	{
		if (UpdateTimer.UpdateAutoReset())
		{
			int count = transform.childCount;
			if (count == 0)
				return;
			if (startedChildCount != count)
			{
				//Child count changed
				Reset(count);
			}

			if (lastIndex == -1)
			{
				trans = transform.GetChild(currentIndex);
				pos = trans.position.z;
				if (!trans.gameObject.activeSelf)
					pos += 10000f;
				for (int i = 0; i < 100; i++)
				{
					if (!sortedChilds.ContainsKey(pos))
						break;
					pos += 0.01f;
				}

				sortedChilds.Add(pos, trans);
				currentIndex++;

				if (currentIndex >= startedChildCount)
				{
					if (ReverseWorkingDirection)
						lastIndex = 0;
					else
						lastIndex = sortedChilds.Count - 1;
				}
			}
			else
			{
				for (int i = 0; i < sortedChilds.Count; i++)
				{
					trans = sortedChilds[sortedChilds.Keys[lastIndex]];
					trans.SetSiblingIndex(ReverseOrder ? (sortedChilds.Count - lastIndex) : lastIndex);

					if (ReverseWorkingDirection)
						lastIndex++;
					else
						lastIndex--;

					if (lastIndex < 0 || lastIndex >= sortedChilds.Count)
					{
						break;
					}
				}

				Reset();
			}
		}
	}
开发者ID:ADoby,项目名称:Summoneer,代码行数:59,代码来源:OrderChildrenByZ.cs

示例2: Rebase

		static public void Rebase(Transform transform, Transform to)
		{
			var transformSO = new SerializedObject(transform);
			var toSO = new SerializedObject(to);

			var transformPrefabLink = transformSO.FindProperty("m_PrefabInternal").objectReferenceValue;
			var toPrefabLink = toSO.FindProperty("m_PrefabInternal").objectReferenceValue;

			toSO.FindProperty("m_PrefabInternal").objectReferenceValue = null;
			transformSO.FindProperty("m_PrefabInternal").objectReferenceValue = null;

			transformSO.ApplyModifiedProperties();
			toSO.ApplyModifiedProperties();

			var index = transform.GetSiblingIndex();
			var lp = transform.localPosition;
			var lr = transform.localRotation;
			var ls = transform.localScale;
			transform.parent = to;
			transform.localPosition = lp;
			transform.localRotation = lr;
			transform.localScale = ls;
			transform.SetSiblingIndex(index);

			transformSO.Update();
			toSO.Update();

			transformSO.FindProperty("m_PrefabInternal").objectReferenceValue = transformPrefabLink;
			toSO.FindProperty("m_PrefabInternal").objectReferenceValue = toPrefabLink;

			transformSO.ApplyModifiedProperties();
			toSO.ApplyModifiedProperties();
		}
开发者ID:Zammy,项目名称:ProjectSpaceship,代码行数:33,代码来源:PEPropertyHelper.cs


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