/// <summary> /// Callback when a TreeViewItem is double clicked /// </summary> /// <param name="element">the TreeElement attached to the TreeViewItem</param> internal static void OnItemDoubleClicked(LayerTreeElement[] elements) { List <UnityEngine.Object> selectedObjs = new List <UnityEngine.Object>(); foreach (var element in elements) { switch (element.Type) { case LayerTreeViewElementType.Table: case LayerTreeViewElementType.Layer: { LayerTreeElement[] items = element.GetChildren(child => child.Type == LayerTreeViewElementType.Item); selectedObjs.AddRange(items.Select(item => EditorUtility.InstanceIDToObject(item.Id)).ToArray()); break; } case LayerTreeViewElementType.Item: { selectedObjs.Add(EditorUtility.InstanceIDToObject(element.Id)); break; } } } Selection.objects = selectedObjs.ToArray(); SceneViewFramer.FrameObjects(Selection.objects); }
private void OnSceneGUI(SceneView sceneView) { if (_table == null) { return; } var bb = _table.Item.BoundingBox; var sndData = _selectedItem.SoundData; _tableCenter = new Vector3((bb.Right - bb.Left) * 0.5f, (bb.Bottom - bb.Top) * 0.5f, (bb.ZHigh - bb.ZLow) * 0.5f); _tableCenter = _table.gameObject.transform.TransformPoint(_tableCenter); _tableSize = new Vector3(bb.Width, bb.Height, bb.Depth); _tableSize = _table.gameObject.transform.TransformVector(_tableSize); if (_shouldDisplaySoundPosition) { if (_displayAllSounds) { foreach (var snd in _table.Sounds) { if (snd.Data != sndData) { RenderSound(snd.Data, false); } } } RenderSound(sndData, true); } //Ask for framing after _tableCenter calculation if (_needFraming) { //Frame to Top View SceneViewFramer.FrameObjects(Selection.objects); var view = SceneView.lastActiveSceneView; var quat = Quaternion.identity; quat.SetLookRotation(Vector3.down); view.LookAt(_tableCenter, quat, Mathf.Max(_tableSize.x, _tableSize.z) * 1.1f); _needFraming = false; } }