public CustomPanelInstanceData CreateObjectPanel(CustomPanelType type, IObjectContainer container) { PanelState state; if (!m_panelStates.TryGetValue(type, out state)) { state = new PanelState(); m_panelStates[type] = state; } var createdCount = state.CreatedPanels.Where(p => Object.ReferenceEquals(p.BoundObjectContainer, container)).Count(); if (createdCount == 0 || type.AllowMultipleInstances) { var panel = new CustomPanelInstanceData(type, container); if (panel != null) { state.CreatedPanels.Add(panel); panel.Disposed += Panel_Disposed; } return(panel); } else { return(null); } }
public CustomPanelInstanceData CreateObjectPanel(CustomPanelType type, string objectReference) { var foundObject = m_dynamicObjectManager.TryFindObject(objectReference); if (foundObject == null) { PanelState state; if (!m_panelStates.TryGetValue(type, out state)) { state = new PanelState(); m_panelStates[type] = state; } var createdCount = state.CreatedPanels.Where(p => p.TargetObjectReference.Equals(objectReference)).Count(); if (createdCount == 0 || type.AllowMultipleInstances) { var panel = new CustomPanelInstanceData(type); panel.SetObjectReference(objectReference); // Who's resolving this, then? if (panel != null) { state.CreatedPanels.Add(panel); panel.Disposed += Panel_Disposed; } return(panel); } else { return(null); } } else { return(CreateObjectPanel(type, foundObject)); } }