/// <summary>
        /// Tries the get information about a currently attached component.
        /// </summary>
        private bool TryGetAttachedComponent(
            SceneComponentBase component, ViewInformation correspondingView,
            out SceneComponentInfo componentInfo, out int componentIndex)
        {
            int attachedComponentCount = m_attachedComponents.Count;

            for (int loop = 0; loop < m_attachedComponents.Count; loop++)
            {
                if (component.IsViewSpecific)
                {
                    if ((component == m_attachedComponents[loop].Component) &&
                        (correspondingView != null) &&
                        (correspondingView == m_attachedComponents[loop].CorrespondingView))
                    {
                        componentInfo  = m_attachedComponents[loop];
                        componentIndex = loop;
                        return(true);
                    }
                }
                else
                {
                    if (component == m_attachedComponents[loop].Component)
                    {
                        componentInfo  = m_attachedComponents[loop];
                        componentIndex = loop;
                        return(true);
                    }
                }
            }

            componentInfo  = default(SceneComponentInfo);
            componentIndex = -1;
            return(false);
        }
        /// <summary>
        /// Detaches the given component from this scene.
        /// </summary>
        /// <param name="component">The component to be detached.</param>
        /// <param name="sourceView">The view which attached the component initially.</param>
        internal void DetachComponent(SceneComponentBase component, ViewInformation sourceView)
        {
            component.EnsureNotNull(nameof(component));
            if (component.IsViewSpecific)
            {
                sourceView.EnsureNotNull(nameof(sourceView));
            }

            m_componentRequests.Enqueue(new SceneComponentRequest()
            {
                RequestType       = SceneComponentRequestType.Detach,
                Component         = component,
                CorrespondingView = component.IsViewSpecific ? sourceView : null
            });
        }
Exemple #3
0
 /// <summary>
 /// Detaches the given component from this scene.
 /// </summary>
 /// <param name="component">The component to be detached.</param>
 /// <param name="sourceView">The view which attached the component initially.</param>
 public void DetachComponent(SceneComponentBase component, ViewInformation sourceView = null)
 {
     m_sceneComponents.AttachComponent(component, sourceView);
 }