// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0) && !CheckUIHover.BlockedByUI) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { isWaypoint = false; foreach (var point in waypoints.points) { if (point.getGameObject().name == hit.transform.name) { isWaypoint = true; selectedWaypoint = point; break; } } if (isWaypoint) { Debug.Log("spawning UI"); selectedSphere = hit.transform; deleteInScreen = true; //Debug.Log("My object is clicked by mouse"); deleteButton.transform.position = new Vector3(Input.mousePosition.x - 50, Input.mousePosition.y, 0); moveButton.transform.position = new Vector3(Input.mousePosition.x + 50, Input.mousePosition.y, 0); moveUp.transform.position = new Vector3(Input.mousePosition.x, Input.mousePosition.y + 50, 0); moveDown.transform.position = new Vector3(Input.mousePosition.x, Input.mousePosition.y - 50, 0); command.transform.position = new Vector3(Input.mousePosition.x + 25, Input.mousePosition.y - 25, 0); changeAltitude.transform.position = new Vector3(Input.mousePosition.x - 25, Input.mousePosition.y + 25, 0); onSphere = true; sphereRender = selectedSphere.GetComponent(typeof(Renderer)) as Renderer; sphereRender.material.color = Color.green; ControlSphere.mySphere = hit.transform; Waypoints.addFlag = false; Waypoints.insertFlag = true; Debug.Log("on sphere"); } else { Debug.Log("removing UI"); onSphere = false; remove.removeUI(); remove.resetSphereStatus(); } } else { Debug.Log("removing UI"); onSphere = false; remove.removeUI(); remove.resetSphereStatus(); } } if (selectedSphere == null) { onSphere = false; } }
private void TaskOnClick() { command.cleanUpCommandUI(); float parse; Debug.Log(spawnUI.selectedWaypoint.getGameObject().name); Debug.Log("input: " + inputField.textComponent.text); if (float.TryParse(inputField.text, out parse)) { if (spawnUI.selectedWaypoint == null) { Debug.Log("null"); } Debug.Log("succeeded parse"); spawnUI.selectedWaypoint.Delay = (decimal)parse; } else { if (spawnUI.selectedWaypoint == null) { Debug.Log("null"); } Debug.Log("failed parse"); spawnUI.selectedWaypoint.Delay = (decimal)0.0; } Debug.Log(dropdown.captionText.text); spawnUI.selectedWaypoint.Command = dropdown.captionText.text; remove.resetSphereStatus(); }
/// <summary> /// adds a new waypoint to the map. /// </summary> /// <param name="altitude">the altitude of the created waypoint</param> /// <returns>true upon success</returns> public bool addWaypoint(float altitude) { Debug.Log("adding waypoint"); // Screen coordinate of the cursor. Vector3 mousePosition = Input.mousePosition; Debug.Log("mousePosition: " + mousePosition); Vector3 mouseGeoLocation = OnlineMapsControlBase.instance.GetCoords(mousePosition); Debug.Log("mouseGeoLocation: " + mouseGeoLocation); //mouseGeoLocation.z = 100; // should create a new marker newSphere = Instantiate(prefabSphere, mouseGeoLocation, Quaternion.identity); newSphere.transform.name = (pointCounter++).ToString(); newSphere.AddComponent <LineRenderer>(); newSphere.GetComponent <LineRenderer>().startWidth = 100; newSphere.GetComponent <LineRenderer>().endWidth = 100; Renderer newSphereRenderer = newSphere.GetComponent(typeof(Renderer)) as Renderer; newSphereRenderer.enabled = true; OnlineMapsMarker3D marker = OnlineMapsMarker3DManager.CreateItem(mouseGeoLocation, newSphere); marker.altitudeType = OnlineMapsAltitudeType.relative; marker.altitude = altitude; // create waypoint object and add it to list Waypoint point = new Waypoint(marker); point.Number = pointCounter; points.Add(point); OnlineMaps.instance.Redraw(); remove.removeUI(); remove.resetSphereStatus(); return(true); }
private void TaskOnClick() { command.cleanUpCommandUI(); remove.resetSphereStatus(); }