public void CloseCharacterInfo() { if (hasRaycastLock) { RaycastLock.GiveLock(); hasRaycastLock = false; } CloseCharacterEdit(); if (charToEdit != null) { charToEdit.GetComponent <Animator>().enabled = true; } if (navMeshWanderToEdit != null) { if (destinationDropDown.value == 0) { navMeshWanderToEdit.ConfigureDestination(); } else { navMeshWanderToEdit.ConfigureDestination(destinationDropDown.value - 1); } } ApplyOptions(); charToEdit = null; navMeshWanderToEdit = null; charInfoOpen = false; charInfoPanel.gameObject.SetActive(false); }
public void OnMouseUp() { if (!hasRaycastLock && RaycastLock.GetLock()) { hasRaycastLock = true; MarkerInfoCanvasRefs.activeMarker = gameObject; markerInfoCanvasRef.SetActive(true); markerInfoCanvasRef.transform.GetChild(0).GetComponent <RectTransform>().anchoredPosition = Input.mousePosition; markerInfoCanvasRef.GetComponent <MarkerInfoCanvasRefs>().nameText.GetComponent <Text>().text = transform.parent.GetComponent <POIInfo>().name; markerInfoCanvasRef.GetComponent <MarkerInfoCanvasRefs>().positionText.GetComponent <Text>().text = transform.parent.GetComponent <POIInfo>().position.ToString(); } }
public void CloseMarkerInfo() { activeMarker.GetComponent <MarkerInfoCanvasSetup>().hasRaycastLock = false; RaycastLock.GiveLock(); gameObject.SetActive(false); }
void Update() { // this finds the camera whose viewport contains the mouse cursor mouseCam = FindMouseCamera(); // if the char edit group is set to patrol, disable the mask if (charEditOpen && charEditWanderToggleGroup.ActiveToggles().ToArray().Count() != 0 && charEditWanderToggleGroup.ActiveToggles().ToArray()[0].name == "Patrol") { radiusProjector.transform.position = navMeshWanderToEdit.localWanderCenter + new Vector3(0, 2, 0); if (userSetRadius) { radiusProjector.orthographicSize = float.Parse(radiusInput.text); } else { radiusProjector.orthographicSize = navMeshWanderToEdit.localWanderRadius; } radiusSelectMask.enabled = false; } else if (charEditOpen) { radiusProjector.orthographicSize = 0; radiusSelectMask.enabled = true; } //manage raycast lock if (charRadiusSelect || newCharDrop || charInfoOpen) { if (!hasRaycastLock && RaycastLock.GetLock()) { hasRaycastLock = true; } } else if (hasRaycastLock) { RaycastLock.GiveLock(); hasRaycastLock = false; } if (charRadiusSelect || charInfoOpen) { radiusProjector.gameObject.SetActive(true); radiusProjector.transform.position = navMeshWanderToEdit.localWanderCenter + new Vector3(0, 2, 0); } else { radiusProjector.gameObject.SetActive(false); } //radius select mode if (charRadiusSelect) { if (!userSetRadius) { //set size of the projector to the distance between the character being editted and the raycast hit at the mouse location if (mouseCam != null && hasRaycastLock) { RaycastLock.Raycast(mouseCam.ScreenPointToRay(Input.mousePosition), ~(1 << 9 | 1 << 8)); radiusProjector.orthographicSize = (charToEdit.transform.position - RaycastLock.hit.point).magnitude; } else { radiusProjector.orthographicSize = navMeshWanderToEdit.localWanderRadius; } } radiusInput.text = radiusProjector.orthographicSize.ToString("F2"); if (Input.GetMouseButtonDown(0)) { StopCharRadiusSelect(!charEditOpen); } } // if we are dropping a new character else if (newCharDrop) { #region dropping new char #region toggles if (randomToggle.isOn) { if (modelToggleGroup.AnyTogglesOn()) { modelToggleGroup.SetAllTogglesOff(); } if (!modelOptionsGreyed) { foreach (Toggle tog in modelToggleGroup.GetComponentsInChildren <Toggle>()) { tog.GetComponentInChildren <Text>().color = Color.grey; } modelOptionsGreyed = true; } } else { if (modelOptionsGreyed) { foreach (Toggle tog in modelToggleGroup.GetComponentsInChildren <Toggle>()) { tog.GetComponentInChildren <Text>().color = Color.black; } modelOptionsGreyed = false; } } // this if is to make sure that a toggle in the toggle group is on if the random toggle is off if (!modelToggleGroup.AnyTogglesOn() && !randomToggle.isOn) { modelToggleGroup.GetComponentInChildren <Toggle>().isOn = true; modelToggleGroup.NotifyToggleOn(modelToggleGroup.GetComponentInChildren <Toggle>()); } #endregion //raycast that ignores characters in the scene if (mouseCam != null && hasRaycastLock) { RaycastLock.Raycast(mouseCam.ScreenPointToRay(Input.mousePosition), ~(1 << 9 | 1 << 8)); } #region makes sure the displayed char is correct if (charToDrop == null) { charToDrop = GetCharacter(); } if (modelToggleGroup.ActiveToggles().Count() > 0 && charToDrop.name != modelToggleGroup.ActiveToggles().ToList()[0].name + "(Clone)" && !randomToggle.isOn) { Destroy(charToDrop); charToDrop = GetCharacter(); } #endregion //sets the position of the temp avatar if (mouseCam != null) { if (RaycastLock.hit.point != null) { dropLocation = RaycastLock.hit.point; } else { dropLocation = avatar.transform.position + avatar.transform.forward * 2f; } //Debug.Log("drop location: " + dropLocation + " haslock: " + hasRaycastLock); } if (charToDrop != null) { charToDrop.transform.position = dropLocation; } //if we right click at a valid location, drop the character if (Input.GetMouseButtonUp(1) && RaycastLock.hit.transform != null) { DropCharacter(); } #endregion } else // this is when we are not dropping a new character { //raycast that ignores the user avatar if (mouseCam != null && Input.GetMouseButtonDown(0)) { if (!hasRaycastLock && RaycastLock.GetLock()) { hasRaycastLock = true; } if (hasRaycastLock) { RaycastLock.Raycast(mouseCam.ScreenPointToRay(Input.mousePosition), ~(1 << 9)); //if we are pointing at an existing avatar and left click, open char info if (RaycastLock.hit.transform != null && RaycastLock.hit.transform.GetComponent <NavMeshWander>() != null && !charInfoOpen) { OpenCharacterInfo(); } else { RaycastLock.GiveLock(); hasRaycastLock = false; } } } } }