Exemplo n.º 1
0
        /// <summary>
        /// Gets a component from the adapter specified by ID
        /// </summary>
        /// <returns></returns>
        public static Component GetComponent(GameObject parentGameObject, string id)
        {
            ComponentAdapter adapter = GetAdapter(parentGameObject);

            if (null == adapter)
            {
                Debug.LogWarning("Cannot find component adapter on game object: " + parentGameObject);
                return(null);
            }

            if (null == adapter.Component)
            {
                Debug.LogWarning("Component not instantiated. Adapter: " + adapter);
                return(null);
            }

            Component parentComponent = adapter.Component;

            // TODO: create method ComponentManager.Instance.GetMultiple(id); and use it here!
            InteractiveComponent component = ComponentManager.Instance.Get(id);

            if (parentComponent.HasChild(component))
            {
                return((Component)component);
            }

            return(null);
        }