本文整理汇总了C#中UnityEngine.RectTransform.GetSiblingIndex方法的典型用法代码示例。如果您正苦于以下问题:C# RectTransform.GetSiblingIndex方法的具体用法?C# RectTransform.GetSiblingIndex怎么用?C# RectTransform.GetSiblingIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.RectTransform
的用法示例。
在下文中一共展示了RectTransform.GetSiblingIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRectTransform
public static RectTransform CreateRectTransform(RectTransform prefab,Vector2 size)
{
var rect = Instantiate(prefab);
rect.SetParent(prefab.parent);
rect.localPosition = prefab.localPosition;
rect.localScale = Vector3.one;
rect.SetSiblingIndex(prefab.GetSiblingIndex() + 1);
rect.sizeDelta = size;
return rect;
}
示例2: CreateDetector
public static PaintingDetector2D CreateDetector(RectTransform prefab)
{
var detectRect = Instantiate(prefab);
detectRect.name = "detect";
detectRect.SetParent(prefab.parent);
detectRect.localPosition = prefab.localPosition;
detectRect.localScale = Vector3.one;
detectRect.SetSiblingIndex(prefab.GetSiblingIndex() + 1);
//detectRect.localPosition = new Vector3(indicator.rect.width, indicator.rect.height,0);
detectRect.sizeDelta = new Vector2(Screen.width, Screen.height);
detectRect.GetComponent<RawImage>().color = Color.clear;
var detector = detectRect.gameObject.AddComponent<PaintingDetector2D>();
return detector;
}
示例3: Setup
public void Setup(RippleData data, Vector2 positon, IRippleCreator creator, bool oscillate = false)
{
m_RippleData = data;
m_RippleParent = (RectTransform)data.RippleParent;
rectTransform.SetParent(m_RippleParent);
rectTransform.SetSiblingIndex(0);
m_Oscillate = oscillate;
rectTransform.sizeDelta = Vector2.zero;
switch (GetComponentInParent<Canvas>().renderMode)
{
case RenderMode.ScreenSpaceOverlay:
rectTransform.position = new Vector3(positon.x, positon.y, m_RippleParent.position.z);
break;
case RenderMode.ScreenSpaceCamera:
rectTransform.position = new Ray(Camera.main.transform.position, Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, m_RippleParent.position.z))).GetPoint(Vector3.Distance(Camera.main.transform.position, m_RippleParent.position));
break;
case RenderMode.WorldSpace:
rectTransform.position = new Ray(Camera.main.transform.position, Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, m_RippleParent.position.z))).GetPoint(Vector3.Distance(Camera.main.transform.position, m_RippleParent.position));
break;
}
rectTransform.localEulerAngles = Vector3.zero;
image.color = data.Color;
canvasGroup.alpha = data.StartAlpha;
m_AnimationDuration = 4f / data.Speed;
m_RippleCreator = creator;
if (data.PlaceRippleBehind)
{
int index = m_RippleParent.GetSiblingIndex();
rectTransform.SetParent(m_RippleParent.parent);
rectTransform.SetSiblingIndex(index);
}
}
示例4: RefreshCPURectangleType
private void RefreshCPURectangleType(List<RectTransform> existingTransforms, RectTransform prototype, int numOfCores)
{
for (int i = 0; i < numOfCores + existingTransforms.Count; i++)
{
bool cpuStateIsOn = i < numOfCores;
bool transformExists = i < existingTransforms.Count;
if (transformExists)
{
existingTransforms[i].gameObject.SetActive(cpuStateIsOn);
}
else if (cpuStateIsOn)
{
existingTransforms.Add(GameObject.Instantiate<RectTransform>(prototype));
existingTransforms[i].SetParent(this.transform);
existingTransforms[i].localScale = Vector3.one;
existingTransforms[i].localRotation = Quaternion.identity;
existingTransforms[i].localPosition = Vector3.zero;
existingTransforms[i].gameObject.SetActive(true);
existingTransforms[i].SetSiblingIndex(prototype.GetSiblingIndex() + 1);
}
}
}