public override void RenderInspectorGui(ParkitectObj parkitectObj) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Create 1 Seats")) { GameObject seat1 = new GameObject(SEAT); seat1.transform.parent = parkitectObj.GetGameObjectRef(true).transform; seat1.transform.localPosition = new Vector3(0, 0.1f, 0); seat1.transform.localRotation = Quaternion.Euler(Vector3.zero); } if (GUILayout.Button("Create 2 Seat")) { GameObject seat1 = new GameObject(SEAT); GameObject seat2 = new GameObject(SEAT); seat1.transform.parent = parkitectObj.GetGameObjectRef(true).transform; seat2.transform.parent = parkitectObj.GetGameObjectRef(true).transform; seat1.transform.localPosition = new Vector3(0.1f, 0.1f, 0); seat1.transform.localRotation = Quaternion.Euler(Vector3.zero); seat2.transform.localPosition = new Vector3(-0.1f, 0.1f, 0); seat2.transform.localRotation = Quaternion.Euler(Vector3.zero); } GUILayout.EndHorizontal(); base.RenderInspectorGui(parkitectObj); }
public override void RenderSceneGui(ParkitectObj parkitectObj) { //Debug.Log (parkitectObj.Prefab.transform.GetInstanceID ()); //Debug.Log (parkitectObj.getGameObjectRef(true).transform.GetInstanceID ()); List <GameObject> seats = new List <GameObject>(); Utility.FindAllChildrenWithName(parkitectObj.GetGameObjectRef(true).transform, SEAT, seats); Handles.color = Color.white; Handles.zTest = CompareFunction.LessEqual; for (int x = 0; x < seats.Count; x++) { if (seats [x] != null) { var transform = seats [x].transform; Handles.SphereCap(200, transform.position, transform.rotation, 0.05f); Vector3 vector = transform.position - transform.up * 0.02f + transform.forward * 0.078f - transform.right * 0.045f; Handles.SphereCap(201, vector, transform.rotation, 0.03f); Vector3 vector2 = transform.position - transform.up * 0.02f + transform.forward * 0.078f + transform.right * 0.045f; Handles.SphereCap(202, vector2, transform.rotation, 0.03f); Vector3 center = transform.position + transform.up * 0.305f + transform.forward * 0.03f; Handles.SphereCap(203, center, transform.rotation, 0.1f); Vector3 center2 = vector + transform.forward * 0.015f - transform.up * 0.07f; Handles.SphereCap(204, center2, transform.rotation, 0.02f); Vector3 center3 = vector2 + transform.forward * 0.015f - transform.up * 0.07f; Handles.SphereCap(205, center3, transform.rotation, 0.02f); } } base.RenderSceneGui(parkitectObj); }
public override void RenderSceneGui(ParkitectObj parkitectObj) { GameObject gameObject = parkitectObj.GetGameObjectRef(false); if (gameObject) { var min = SnapCenter ? -2.5f : -3f; var max = SnapCenter ? 2.5f : 3f; for (float x = min; x <= max; x += 1 / GridSubdivision) { Handles.DrawLine(gameObject.transform.position + new Vector3(x, 0, min), gameObject.transform.position + new Vector3(x, 0, max)); } for (float z = min; z <= max; z += 1 / GridSubdivision) { Handles.DrawLine(gameObject.transform.position + new Vector3(min, 0, z), gameObject.transform.position + new Vector3(max, 0, z)); } } base.RenderSceneGui(parkitectObj); }
public override void RenderInspectorGui(ParkitectObj parkitectObj) { GameObject sceneTransform = parkitectObj.GetGameObjectRef(false); if (sceneTransform == null) { return; } //FlatrideDecorator flatRideDecorator = parkitectObj.GetDecorator (typeof(FlatrideDecorator)); string caption = "Enable Editing Waypoints"; if (EnableEditing) { caption = "Disable Editing Waypoints"; } if (EnableEditing) { GUI.color = Color.green; } bool currentEnableEditing = EnableEditing; if (GUILayout.Button(caption)) { SelectedWaypoint = null; EnableEditing = !EnableEditing; } if (EnableEditing) { GUI.color = Color.white; } if (currentEnableEditing != EnableEditing) { if (EnableEditing) { currentTool = Tools.current; Tools.current = Tool.None; } else { Tools.current = currentTool; } } if (EnableEditing) { GUILayout.Label("S - Snap to axis of connected waypoints"); HelperPlaneY = EditorGUILayout.FloatField("Helper Plane Y", HelperPlaneY); if (GUILayout.Button("Add Waypoint")) { addWaypoint(sceneTransform.transform); } if (GUILayout.Button("Rotate 90°")) { rotateWaypoints(sceneTransform.transform); } if (GUILayout.Button("Clear all")) { Waypoints.Clear(); } } base.RenderInspectorGui(parkitectObj); }
public override void RenderSceneGui(ParkitectObj parkitectObj) { GameObject sceneTransform = parkitectObj.GetGameObjectRef(false); if (sceneTransform == null) { return; } GUIStyle labelStyle = new GUIStyle(); labelStyle.normal.textColor = Color.black; if (EnableEditing) { switch (Event.current.type) { case EventType.Layout: break; case EventType.KeyDown: if (Event.current.keyCode == KeyCode.S) { Snap = true; } break; case EventType.KeyUp: if (Event.current.keyCode == KeyCode.C) { if (_state != State.CONNECT) { _state = State.CONNECT; } else { _state = State.NONE; } } else if (Event.current.keyCode == KeyCode.R) { removeSelectedWaypoint(); } /*else if (Event.current.keyCode == KeyCode.A) * { * addWaypoint(sceneTransform.transform); * }*/ else if (Event.current.keyCode == KeyCode.O && SelectedWaypoint != null) { SelectedWaypoint.isOuter = !SelectedWaypoint.isOuter; } else if (Event.current.keyCode == KeyCode.I && SelectedWaypoint != null) { SelectedWaypoint.isRabbitHoleGoal = !SelectedWaypoint.isRabbitHoleGoal; } else if (Event.current.keyCode == KeyCode.S) { Snap = false; } SceneView.RepaintAll(); HandleUtility.Repaint(); break; } } int i = 0; foreach (SPWaypoint waypoint in Waypoints) { if (waypoint == SelectedWaypoint) { Handles.color = Color.red; } else if (waypoint.isOuter) { Handles.color = Color.green; } else if (waypoint.isRabbitHoleGoal) { Handles.color = Color.blue; } else { Handles.color = Color.yellow; } Vector3 worldPos = waypoint.localPosition + sceneTransform.transform.position; Handles.zTest = CompareFunction.LessEqual; if (Handles.Button(worldPos, Quaternion.identity, HandleUtility.GetHandleSize(worldPos) * 0.2f, HandleUtility.GetHandleSize(worldPos) * 0.2f, Handles.SphereCap)) { if (EnableEditing) { handleClick(waypoint); } } Handles.color = Color.blue; foreach (int connectedIndex in waypoint.connectedTo) { Handles.zTest = CompareFunction.Always; Handles.DrawLine(worldPos, Waypoints[connectedIndex].localPosition + sceneTransform.transform.position); } Handles.Label(worldPos, "#" + i, labelStyle); i++; } if (SelectedWaypoint != null) { Vector3 worldPos = SelectedWaypoint.localPosition + sceneTransform.transform.position; if (_state == State.CONNECT) { Handles.Label(worldPos, "\nConnecting...", labelStyle); } else { Vector3 newPos = Handles.PositionHandle(SelectedWaypoint.GetWorldPosition(sceneTransform.transform), Quaternion.identity); SelectedWaypoint.localPosition = handleSnap(newPos, SelectedWaypoint); SelectedWaypoint.localPosition = handleSnap(newPos, SelectedWaypoint); Handles.Label(worldPos, "\n(C)onnect\n(R)emove\n(O)uter\nRabb(i)t Hole", labelStyle); } } base.RenderSceneGui(parkitectObj); }