public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        if (Application.isPlaying)
        {
            showSelectables = EditorGUILayout.Foldout(showSelectables, "Active Selectables", true);
            if (showSelectables)
            {
                GUI.enabled = false;
                ISelectable[] selectables = simPanel.GetActiveSelectables();
                ShowSizeField(selectables.Length);
                for (int i = 0; i < selectables.Length; ++i)
                {
                    EditorGUILayout.ObjectField(selectables[i] as MonoBehaviour, typeof(MonoBehaviour), true);
                }
                GUI.enabled = true;
            }

            showDraggables = EditorGUILayout.Foldout(showDraggables, "Active Draggables", true);
            if (showDraggables)
            {
                GUI.enabled = false;
                IDraggable[] draggables = simPanel.GetActiveDraggables();
                ShowSizeField(draggables.Length);
                for (int i = 0; i < draggables.Length; ++i)
                {
                    EditorGUILayout.ObjectField(draggables[i] as MonoBehaviour, typeof(MonoBehaviour), true);
                }
                GUI.enabled = true;
            }

            showConfigurables = EditorGUILayout.Foldout(showConfigurables, "Active Configurables", true);
            if (showConfigurables)
            {
                GUI.enabled = false;
                IConfigurable[] configurables = simPanel.GetActiveConfigurables();
                ShowSizeField(configurables.Length);
                for (int i = 0; i < configurables.Length; ++i)
                {
                    EditorGUILayout.ObjectField(configurables[i] as MonoBehaviour, typeof(MonoBehaviour), true);
                }
                GUI.enabled = true;
            }
        }
    }
Esempio n. 2
0
    void ProcessMouseInput()
    {
        EditorInput     input    = EditorInput.instance;
        SimulationPanel simPanel = SimulationPanel.instance;

        if (FloatingSelection.instance.HasFloatingComponent())
        {
            if (input.singleClick)
            {
                FloatingSelection.instance.PlaceFloatingComponent();
            }
        }
        else
        {
            if (input.singleClick)
            {
                if (!Input.GetKey(KeyCode.LeftShift))
                {
                    SelectedObjects.instance.ClearSelection();
                }
                foreach (var selectable in simPanel.GetActiveSelectables())
                {
                    if (selectable.RequestedSelect())
                    {
                        SelectedObjects.instance.SelectObject(selectable);
                        break;
                    }
                }
            }
            if (input.doubleClick)
            {
                foreach (var configurable in simPanel.GetActiveConfigurables())
                {
                    if (configurable.RequestedConfig())
                    {
                        SelectedObjects.instance.ClearSelection();
                        configurable.OpenConfigWindow();
                        break;
                    }
                }
            }
            if (input.mouseDragStart)
            {
                foreach (var draggable in simPanel.GetActiveDraggables())
                {
                    if (draggable.RequestedDrag())
                    {
                        draggable.StartDragging();
                        currentDraggable = draggable;
                        break;
                    }
                }
                if (currentDraggable == null)
                {
                    BoxSelection.instance.StartSelecting();
                }
            }
            if (input.mouseDragEnd)
            {
                if (currentDraggable != null)
                {
                    currentDraggable.StopDragging();
                    currentDraggable = null;
                }
                else
                {
                    BoxSelection.instance.StopSelecting();
                }
            }
        }
    }