本文整理汇总了C#中Transform.EnumerateChildren方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.EnumerateChildren方法的具体用法?C# Transform.EnumerateChildren怎么用?C# Transform.EnumerateChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform.EnumerateChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExpandAll
void ExpandAll(Transform transform)
{
var transformsWithStates = transform.EnumerateChildren().Where((arg) => arg.GetComponentsInChildren<OnOff>(true).Length > 0);
foreach(var i in transformsWithStates)
{
foldouts.Add(i);
ExpandAll(i);
}
}
示例2: ProcessTransform
void ProcessTransform(Transform transform)
{
GUILayout.BeginVertical();
var transformsWithStates = transform.EnumerateChildren().Where((arg) => arg.GetComponentsInChildren<OnOff>(true).Length > 0);
foreach(var i in transformsWithStates)
{
GUILayout.BeginHorizontal();
bool foldout = foldouts.Contains(i);
bool newFoldout = EditorGUILayout.Toggle(foldout, "foldout", GUILayout.Width(10));
if(newFoldout!=foldout)
{
foldout = newFoldout;
if(!foldout)
foldouts.Remove(i);
else
foldouts.Add(i);
}
//GUILayout.BeginHorizontal("box",GUILayout.ExpandWidth(false));
i.gameObject.SetActive(GUILayout.Toggle (i.gameObject.activeSelf, "", GUILayout.ExpandWidth (false)));
GUI.enabled = i.gameObject.activeInHierarchy;
GUILayout.Label(i.name, GUILayout.ExpandWidth(false), GUILayout.Height(20));
//GUILayout.EndHorizontal();
var onOff = i.GetComponent<OnOff>();
if(onOff)
{
try
{
onOff.On = GUILayout.Toggle(onOff ? onOff.On:false, onOff.On ? "on":"off", "button", GUILayout.ExpandWidth(false));
}
catch(System.Exception e)
{
Debug.LogError(e);
}
}
var statemachine = i.GetComponent<OnOffStateMachine>();
if(statemachine)
{
OnOffStateMachineInspector.StateMachinePopup(statemachine);
}
var inherited = i.GetComponent<OnOffInherited>();
if(inherited)
{
GUILayout.Label("(inherited: "+inherited.inheritanceType.ToString()+" )", GUILayout.ExpandWidth(false));
}
GUI.enabled = true;
GUILayout.EndHorizontal();
if(foldout)
{
GUILayout.BeginHorizontal();
GUILayout.Space(10);
ProcessTransform(i);
GUILayout.EndHorizontal();
}
}
GUILayout.EndVertical();
}