/// <summary> /// 返回直接或间接的对象,根据名字查询 /// </summary> /// <example> Get all QuadTileSets defined in this world: /// <code> /// RenderableObjectList allQTS = CurrentWorld.RenderableObjects.GetObjects(null, typeof(QuadTileSet)); /// </code></example> /// <param name="name">The name of the <c>RenderableObject</c> to search for, or <c>null</c> if any name should match.</param> /// <param name="objectType">The object type to search for, or <c>null</c> if any type should match.</param> /// <returns>A list of all <c>RenderableObject</c>s that match the given search criteria (may be empty), or <c>null</c> if an error occurred.</returns> public virtual RenderableObjectList GetObjects(string name, Type objectType) { RenderableObjectList result = new RenderableObjectList("results"); m_childrenRWLock.AcquireReaderLock(Timeout.Infinite); try { foreach (RenderableObject ro in this.m_children) { if (ro.GetType() == typeof(RenderableObjectList)) { RenderableObjectList sub = ro as RenderableObjectList; RenderableObjectList subres = sub.GetObjects(name, objectType); foreach (RenderableObject hit in subres.ChildObjects) { result.Add(hit); } } if (ro.Name.Equals(name) && ((objectType == null) || (ro.GetType() == objectType))) { result.Add(ro); } } } catch { result = null; } finally { m_childrenRWLock.ReleaseReaderLock(); } return(result); }