/// <summary> /// Call from your Start method /// </summary> protected void Start() { if (null != iface) { return; } AdvertisePath(); GameObject go = this.gameObject; PathHolder holder = null; string usedPath = path; while (null != go && 0 == usedPath.Length) { holder = go.GetComponent <PathHolder>(); if (null != holder) { usedPath = holder.path; //print("[OSVR] " + name + ": Found path " + usedPath + " in ancestor " + go.name); } go = GetParent.Get(go); } if (0 == usedPath.Length) { Debug.LogError("[OSVR] Missing path for " + name + " - no path found in this object's InterfaceGameObject or any ancestor!"); return; } iface = ScriptableObject.CreateInstance <InterfaceCallbacks>(); iface.path = usedPath; iface.Start(); }
// Use this for initialization void Start() { _camera = gameObject.GetComponent <Camera>(); if (_camera == null) { Debug.LogError("[PVR-Unity] PVRSurface need Camera component."); return; } _eyeOffset = gameObject.GetComponent <PVREyeOffset>(); if (_eyeOffset == null) { Debug.LogError("[PVR-Unity] PVRSurface need PVREyeOffset script component."); return; } GameObject parent = GetParent.Get(this.gameObject); if (parent) { _tracking = parent.GetComponent <PVRPoseTracking>(); _headlocked = (_tracking == null || (!_tracking.enabled)); _layerId = parent.GetInstanceID(); Camera parentCamera = parent.GetComponent <Camera>(); if (parentCamera) { _camera.CopyFrom(parentCamera); } } EnsureRenderTarget(); }
/// <summary> /// Call from your Start method /// </summary> protected virtual void Start() { AdvertisePath(); GameObject go = this.gameObject; PathHolder holder = null; while (null != go && System.String.IsNullOrEmpty(usedPath)) { usedPath = path; holder = go.GetComponent <PathHolder>(); if (null != holder) { usedPath = holder.path; //Debug.Log("[OSVR-Unity] " + name + ": Found path " + usedPath + " in ancestor " + go.name); } go = GetParent.Get(go); } if (0 == usedPath.Length) { Debug.LogError("[OSVR-Unity] Missing path for " + name + " - no path found in this object's InterfaceGameObject or any ancestor!"); return; } }
public void MouseMove(MouseEventArgs e, Size parentControlSize) { RectangleF barArea = getBarArea(parentControlSize); switch (_selectionMode) { case SelectionMode.SelectedLimit0: _selectedLimit0 = FromVisualY(barArea, e.Y); InvalidateParent?.Invoke(); break; case SelectionMode.SelectedLimit1: _selectedLimit1 = FromVisualY(barArea, e.Y); InvalidateParent?.Invoke(); break; case SelectionMode.SelectedLimitBoth: float barHeight = _selectedLimit1 - _selectedLimit0; float newBarPos = FromVisualY(barArea, _barMouseOffset + e.Y); newBarPos = (float)Math.Max(Math.Min(newBarPos + (double)barHeight, MaxDepth), MinDepth) - barHeight; _selectedLimit0 = newBarPos; _selectedLimit1 = newBarPos + barHeight; InvalidateParent?.Invoke(); break; case SelectionMode.RoomMove: float destinationHeight = FromVisualY(barArea, e.Y) - _roomMouseOffset; if (_roomsToMove == null) { HashSet <Room> roomsToMove = new HashSet <Room>(); // If multiple rooms are selected, build a list of rooms to move based on that. // Otherwise, use only room which was clicked before. if (_editor.SelectedRooms.Count > 1) { foreach (var room in _editor.SelectedRooms) { roomsToMove.UnionWith(_editor.Level.GetConnectedRooms(room)); } } else { roomsToMove = _editor.Level.GetConnectedRooms(_roomMouseClicked); } if (EditorActions.CheckForLockedRooms(GetParent?.Invoke(), roomsToMove)) { _roomsToMove = null; _selectionMode = SelectionMode.None; break; } _roomsToMove = roomsToMove; InvalidateParent?.Invoke(); } // limit room movement to valid range float maxHeight = MaxDepth; float minHeight = MinDepth; foreach (Room room in _roomsToMove) { float roomUpperLimit = MaxDepth - (room.Position.Y - _roomMouseClicked.Position.Y + room.GetHighestCorner()); float roomLowerLimit = MinDepth - (room.Position.Y - _roomMouseClicked.Position.Y + room.GetLowestCorner()); maxHeight = Math.Min(maxHeight, roomUpperLimit); minHeight = Math.Max(minHeight, roomLowerLimit); } destinationHeight = Math.Max(Math.Min(destinationHeight, maxHeight), minHeight); int delta = (int)(Math.Ceiling(destinationHeight) - _roomMouseClicked.Position.Y); // Snapping if (!(Control.ModifierKeys.HasFlag(Keys.Alt) || Control.ModifierKeys.HasFlag(Keys.Shift))) { HashSet <Room> roomsInGroup = new HashSet <Room>(); List <List <RelevantRoom> > roomSequences = groupBuildRoomSequences(Vector2.Zero, _groupMouseClicked); for (int i = 0; i < roomSequences.Count; ++i) { for (int j = 0; j < roomSequences[i].Count; ++j) { roomsInGroup.Add(roomSequences[i][j].Room); } } int highestGroupPoint = _editor.Level.GetHighestRoomGroupPoint(_roomsToMove); int lowestGroupPoint = _editor.Level.GetLowestRoomGroupPoint(_roomsToMove); Room nearbyRoom = _editor.Level.GetNearbyRoomBelow(_roomsToMove, roomsInGroup, lowestGroupPoint, _snappingMargin); if (nearbyRoom != null) { if (Math.Abs(delta) <= _snappingMargin) { int newDelta = -(lowestGroupPoint - (nearbyRoom.Position.Y + nearbyRoom.GetHighestCorner())); if (newDelta + highestGroupPoint > MaxDepth) { break; // Do not push room out of bounds } delta = newDelta; } else if (Math.Abs(delta) <= _snappingMargin + 1) { break; // Noise reduction } } else { nearbyRoom = _editor.Level.GetNearbyRoomAbove(_roomsToMove, roomsInGroup, highestGroupPoint, 5); if (nearbyRoom != null) { if (Math.Abs(delta) <= _snappingMargin) { int newDelta = ((nearbyRoom.Position.Y + nearbyRoom.GetLowestCorner()) - highestGroupPoint); if (newDelta + lowestGroupPoint < MinDepth) { break; // Do not push room out of bounds } delta = newDelta; } else if (Math.Abs(delta) <= _snappingMargin + 1) { break; // Noise reduction } } } } // do movement if (delta != 0) { _overallDelta += delta; EditorActions.MoveRooms(new VectorInt3(0, delta, 0), _roomsToMove, true); } break; } }