/// <summary> /// Inserts a reference to the specified child into the Owner /// in the List specified by the ChildInfo property</summary> /// <param name="child">Child to be inserted</param> public bool AddChild(object child) { DomNode childNode = child.As <DomNode>(); bool isGobRef = child.Is <IGameObject>() && childNode.GetRoot().Is <IGame>() && m_childInfo.Type == Schema.gameObjectReferenceType.Type; bool isResRef = ResourceReference.CanReference(m_childInfo.Type, child.As <IResource>()); DomNode refNode = null; if (isGobRef) { GameObjectReference gobRef = GameObjectReference.Create(childNode); refNode = gobRef.Cast <DomNode>(); } else if (isResRef) { IReference <IResource> resReference = ResourceReference.Create(m_childInfo.Type, child.As <IResource>()); refNode = resReference.As <DomNode>(); } if (m_childInfo.IsList) { m_owner.GetChildList(m_childInfo).Add(refNode); } else { m_owner.SetChild(m_childInfo, refNode); } return(true); }
/// <summary> /// Returns true iff a reference to specified child can be inserted into this slot</summary> /// <param name="child">Child to be inserted</param> /// <returns>True iff the specified child can be inserted into this slot</returns> public bool CanAddChild(object child) { DomNode childNode = child.As <DomNode>(); bool isGobRef = child.Is <IGameObject>() && childNode.GetRoot().Is <IGame>() && m_childInfo.Type == Schema.gameObjectReferenceType.Type; bool isResRef = ResourceReference.CanReference(m_childInfo.Type, child.As <IResource>()); return(isGobRef || isResRef); }