public override void HandleInput(bool tap, bool hold, float2 mousePosition) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay((Vector2)mousePosition); if (Physics.Raycast(ray, out hit)) { Vector3 point = hit.point; point.y = 0; if (tap && !hold) { Tap(hit, mousePosition, point); } else if (hold) { if (SelectedPlaceable == null) { //UiDrag1.gameObject.SetActive(true); //UiDrag1.position = new float3(mousePosition.xy, 0); var go = new GameObject(name, typeof(Placeable), typeof(MeshFilter), typeof(MeshRenderer), typeof(MeshCollider)); SelectedPlaceable = go.GetComponent <Placeable>(); SelectedPlaceable.SetFeature(FeatureOptions[selectedType]); SelectedPlaceable.UpdatePosition(point); if (SelectedPlaceable.data.Cutout) { Blueprint.Instance.AddCutout(SelectedPlaceable); } else { Blueprint.Instance.AddPlaceable(SelectedPlaceable); } } SelectedPlaceable.UpdatePosition(point); Vector3 sPoint = Camera.main.WorldToScreenPoint(SelectedPlaceable.Position); InputManger.Instance.MoveUIDrag1(sPoint); InputManger.Instance.MoveUiOptions(sPoint); InputManger.Instance.MoveUiRotation(sPoint); // Hold(hit, mousePosition, point); } } }
private void Tap(RaycastHit hit, float2 mousePosition, float3 point) { Debug.Log(hit.transform.name); if (hit.transform.name == name) { SelectedPlaceable = hit.transform.GetComponent <Placeable>(); //Options.gameObject.SetActive(true); Vector3 sPoint = Camera.main.WorldToScreenPoint(SelectedPlaceable.Position); InputManger.Instance.MoveUIDrag1(sPoint); InputManger.Instance.MoveUiOptions(sPoint); InputManger.Instance.MoveUiRotation(sPoint); } else if (SelectedPlaceable != null) { Deselect(); } else { if (SelectedPlaceable == null) { //UiDrag1.gameObject.SetActive(true); //UiDrag1.position = new float3(mousePosition.xy, 0); var go = new GameObject(name, typeof(Placeable), typeof(MeshFilter), typeof(MeshRenderer), typeof(MeshCollider)); go.layer = LayerMask.NameToLayer("Placeables"); SelectedPlaceable = go.GetComponent <Placeable>(); SelectedPlaceable.SetFeature(FeatureOptions[selectedType]); SelectedPlaceable.UpdatePosition(point); if (SelectedPlaceable.data.Cutout) { Blueprint.Instance.AddCutout(SelectedPlaceable); } else { Blueprint.Instance.AddPlaceable(SelectedPlaceable); } Vector3 sPoint = Camera.main.WorldToScreenPoint(SelectedPlaceable.Position); InputManger.Instance.MoveUIDrag1(sPoint); InputManger.Instance.MoveUiOptions(sPoint); InputManger.Instance.MoveUiRotation(sPoint); } else { SelectedPlaceable.UpdatePosition(point); } } }