public void SelectionChangeSlot(params object[] parameters) { DraggableList.StopDrag(); // solves the bug of still dragging when view changed Transform selectedTransform = (Transform)parameters[0]; bool shouldDeselect = false; if (null != selectedTransform) { /** * When the game object is selected (in the hierarchy window) we need to select the component on screen * The component might not be created by this time, so we need to defer the component selection * until the hierarchy change and delta processing * */ if (null != EditorState.Instance.Adapter && null != DesignerOverlay.Instance) { var selectedComponent = EditorState.Instance.Adapter.Component; if (null != selectedComponent) { //Debug.Log("Immediate selection: " + _selectedComponent); DesignerOverlay.Instance.Select(selectedComponent); } else { shouldDeselect = true; _doDefferedSelection = true; } } else { _selectedComponent = null; shouldDeselect = true; } } else { shouldDeselect = true; } if (shouldDeselect) { if (null != DesignerOverlay.Instance) { DesignerOverlay.Instance.Deselect(); } } HierarchyViewDecorator.Instance.ReScan(); PlayModeStateChangeEmitter.Instance.SelectionChangedSignal.Emit(); }
/// <summary> /// Fires when in-game GUI element clicked /// </summary> /// <param name="parameters"></param> internal static void ClickSlot(object[] parameters) { if (!EditorSettings.InspectorEnabled) { return; } /** * 1. No component with adapter selected -> remove the hierarchy selection * */ if (parameters.Length == 0) { // ReSharper disable ConditionIsAlwaysTrueOrFalse if (DipSwitches.DeselectHierarchyOnNonAdaptedComponentSelection) // ReSharper restore ConditionIsAlwaysTrueOrFalse #pragma warning disable 162 { Selection.activeTransform = null; } #pragma warning restore 162 return; } Component comp = parameters[0] as Component; #if DEBUG if (DebugMode) { Debug.Log(string.Format("Component clicked in the game view: {0}", comp)); } #endif DraggableList.StopDrag(); // solves the bug of still dragging when view changed /** * 2. The adapted component selected * */ if (null != comp) { /** * 2.a) Get game object having adapter for this component attached<br/> * If no adapter found, it means that this component is not bound to an adapter<br/> * For instance Alert (created from code), or component created by an adapter working in factory mode * */ GameObject gameObject = GuiLookup.GetGameObject(comp); /** * 2.b) Check if game object found * If not, nullify the selection and return * */ if (null == gameObject) { Selection.activeTransform = null; return; } /** * 2.c) If game object found, ping it (highlight it) and select it * Selecting it will in turn execute all the mechanisms for processing the selection change * */ //EditorGUIUtility.PingObject(gameObject); // ping Selection.activeTransform = gameObject.transform; // select if (parameters.Length > 1) { MouseEvent me = (MouseEvent)parameters[1]; ProcessMouseEvent(me); } } }