예제 #1
0
        private void Start()
        {
            if (GLRenderer.Instance == null)
            {
                GameObject glRenderer = new GameObject();
                glRenderer.name = "GLRenderer";
                glRenderer.AddComponent <GLRenderer>();
            }

            if (SceneCamera != null)
            {
                if (!SceneCamera.GetComponent <GLCamera>())
                {
                    SceneCamera.gameObject.AddComponent <GLCamera>();
                }
            }

            if (m_exposeToEditor != null)
            {
                GLRenderer.Instance.Add(this);
            }

            if (!RuntimeSelection.IsSelected(gameObject))
            {
                Destroy(this);
            }
        }
예제 #2
0
        private void LateUpdate()
        {
            if (InputController._GetMouseButtonDown(0))
            {
                if (RuntimeTools.ActiveTool != null && RuntimeTools.ActiveTool != BoxSelection.Current)
                {
                    return;
                }

                if (!IPointerOverEditorArea)
                {
                    return;
                }

                if (RuntimeTools.IsViewing)
                {
                    return;
                }

                if (!RuntimeSelection.Enabled)
                {
                    return;
                }

                bool       rangeSelect = InputController._GetKey(RangeSelectKey);
                bool       multiselect = InputController._GetKey(MultiselectKey) || InputController._GetKey(MultiselectKey2) || rangeSelect;
                Ray        ray         = SceneCamera.ScreenPointToRay(InputController._MousePosition);
                RaycastHit hitInfo;

                //if (Physics.Raycast(ray, out hitInfo, float.MaxValue, LayerMask.value))
                if (Physics.Raycast(ray, out hitInfo, float.MaxValue))
                {
                    GameObject hitGO     = hitInfo.collider.gameObject;
                    bool       canSelect = CanSelect(hitGO);
                    if (canSelect)
                    {
                        hitGO = hitGO.GetComponentInParent <ExposeToEditor>().gameObject;
                        if (multiselect)
                        {
                            List <Object> selection;
                            if (RuntimeSelection.objects != null)
                            {
                                selection = RuntimeSelection.objects.ToList();
                            }
                            else
                            {
                                selection = new List <Object>();
                            }

                            if (selection.Contains(hitGO))
                            {
                                selection.Remove(hitGO);
                                if (rangeSelect)
                                {
                                    selection.Insert(0, hitGO);
                                }
                            }
                            else
                            {
                                selection.Insert(0, hitGO);
                            }
                            RuntimeSelection.Select(hitGO, selection.ToArray());
                        }
                        else
                        {
                            RuntimeSelection.activeObject = hitGO;
                        }
                    }
                    else
                    {
                        if (!multiselect)
                        {
                            RuntimeSelection.activeObject = null;
                        }
                    }
                }
                else
                {
                    if (!multiselect)
                    {
                        RuntimeSelection.activeObject = null;
                    }
                }
            }

            if (RuntimeEditorApplication.IsActiveWindow(this))
            {
                if (InputController._GetKeyDown(SelectAllKey) && InputController._GetKey(ModifierKey))
                {
                    IEnumerable <GameObject> filtered = RuntimeEditorApplication.IsPlaying ?
                                                        ExposeToEditor.FindAll(ExposeToEditorObjectType.PlayMode) :
                                                        ExposeToEditor.FindAll(ExposeToEditorObjectType.EditorMode);
                    RuntimeSelection.objects = filtered.ToArray();
                }
            }
        }