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


C# Transform.EnumerateChildren方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:Cratesmith,项目名称:CratesmithUnityLibrary,代码行数:9,代码来源:OnOffTestingWindow.cs

示例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();
    }
开发者ID:Cratesmith,项目名称:CratesmithUnityLibrary,代码行数:61,代码来源:OnOffTestingWindow.cs


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