コード例 #1
0
 public void Set(ProjectItemType resourceType, Object resource)
 {
     m_resource     = resource;
     m_resrouceType = resourceType;
     IsSelected     = RuntimeSelection.IsSelected(m_resource);
     if (m_started)
     {
         UpdatePreview();
     }
 }
コード例 #2
0
ファイル: RuntimeEditor.cs プロジェクト: simonkhc/VRMaker-1
        private void LateUpdate()
        {
            if (Input.GetKeyDown(DuplicateKey) && Input.GetKey(DuplicateKey2))
            {
                Object[] selectedObjects = RuntimeSelection.objects;
                if (selectedObjects != null && selectedObjects.Length > 0)
                {
                    Object[] duplicates = new Object[selectedObjects.Length];
                    for (int i = 0; i < duplicates.Length; ++i)
                    {
                        GameObject go          = selectedObjects[i] as GameObject;
                        Object     duplicate   = Instantiate(selectedObjects[i]);
                        GameObject duplicateGo = duplicate as GameObject;
                        if (go != null && duplicateGo != null)
                        {
                            if (go.transform.parent != null)
                            {
                                duplicateGo.transform.SetParent(go.transform.parent, true);
                            }
                        }

                        duplicates[i] = duplicate;
                    }
                    RuntimeSelection.objects = duplicates;
                }
            }

            if (Input.GetMouseButtonDown(0))
            {
                if (PositionHandle.Current != null && PositionHandle.Current.IsDragging)
                {
                    return;
                }
                if (ScaleHandle.Current != null && ScaleHandle.Current.IsDragging)
                {
                    return;
                }
                if (RotationHandle.Current != null && RotationHandle.Current.IsDragging)
                {
                    return;
                }

                if (!SceneView.IsPointerOver && EventSystem.current != null && EventSystem.current.IsPointerOverGameObject())
                {
                    return;
                }

                if (RuntimeTools.IsLocked)
                {
                    return;
                }

                if (RuntimeTools.IsSceneGizmoSelected)
                {
                    return;
                }

                bool       rangeSelect = Input.GetKey(RangeSelectKey);
                bool       multiselect = Input.GetKey(MultiselectKey) || rangeSelect;
                Ray        ray         = SceneCamera.ScreenPointToRay(Input.mousePosition);
                RaycastHit hitInfo;
                if (Physics.Raycast(ray, out hitInfo, float.MaxValue, m_raycastLayerMask.value))
                {
                    ExposeToEditor exposeToEditor = hitInfo.collider.gameObject.GetComponent <ExposeToEditor>();
                    if (exposeToEditor != null)
                    {
                        if (multiselect)
                        {
                            List <Object> selection;
                            if (RuntimeSelection.objects != null)
                            {
                                selection = RuntimeSelection.objects.ToList();
                            }
                            else
                            {
                                selection = new List <Object>();
                            }

                            if (selection.Contains(exposeToEditor.gameObject))
                            {
                                selection.Remove(exposeToEditor.gameObject);
                                if (rangeSelect)
                                {
                                    selection.Insert(0, exposeToEditor.gameObject);
                                }
                            }
                            else
                            {
                                selection.Insert(0, exposeToEditor.gameObject);
                            }
                            RuntimeSelection.Select(exposeToEditor.gameObject, selection.ToArray());
                        }
                        else
                        {
                            RuntimeSelection.activeObject = exposeToEditor.gameObject;
                        }
                    }
                    else
                    {
                        if (!multiselect)
                        {
                            RuntimeSelection.activeObject = null;
                        }
                    }
                }
                else
                {
                    if (!multiselect)
                    {
                        RuntimeSelection.activeObject = null;
                    }
                }
            }
        }
コード例 #3
0
 private void OnSelectionChanged(Object[] unselectedObjects)
 {
     IsSelected = RuntimeSelection.IsSelected(m_resource);
 }