Ejemplo n.º 1
0
        public void RemoveComponent <T> ()
        {
            Runtime.ValidateRefCounted(this);
            var stringHash = Runtime.LookupStringHash(typeof(T));

            RemoveComponent(stringHash);
        }
Ejemplo n.º 2
0
        public Node[] GetChildrenWithComponent <T> (bool recursive = false) where T : Component
        {
            Runtime.ValidateRefCounted(this);
            var stringhash = Runtime.LookupStringHash(typeof(T));
            int count;
            var ptr = NodeHelper.urho_node_get_components(handle, stringhash.Code, recursive ? 1 : 0, out count);

            if (ptr == IntPtr.Zero)
            {
                return(ZeroArray);
            }

            var res = new Node[count];

            for (int i = 0; i < count; i++)
            {
                var node = Marshal.ReadIntPtr(ptr, i * IntPtr.Size);
                res [i] = Runtime.LookupObject <Node> (node);
            }
            if (Component.IsDefinedInManagedCode <T>())
            {
                //is not really efficient, but underlying Urho3D knows nothing about components defined in C#
                return(res.Where(c => c.GetComponent <T>() != null).ToArray());
            }
            return(res);
        }
Ejemplo n.º 3
0
Archivo: Node.cs Proyecto: corefan/urho
        public Node[] GetChildrenWithComponent <T> (bool recursive = false) where T : Component
        {
            var stringhash = Runtime.LookupStringHash(typeof(T));
            int count;
            var ptr = NodeHelper.urho_node_get_components(handle, stringhash.Code, recursive ? 1 : 0, out count);

            if (ptr == IntPtr.Zero)
            {
                return(ZeroArray);
            }

            var res = new Node[count];

            for (int i = 0; i < count; i++)
            {
                var node = Marshal.ReadIntPtr(ptr, i * IntPtr.Size);
                res [i] = Runtime.LookupObject <Node> (node);
            }
            return(res);
        }
Ejemplo n.º 4
0
Archivo: Node.cs Proyecto: corefan/urho
        public void RemoveComponent <T> ()
        {
            var stringHash = Runtime.LookupStringHash(typeof(T));

            RemoveComponent(stringHash);
        }