public IActionResult AddHotspot(HotspotAddVM hotspot) { var success = true; var message = "Pointer was successfully added!"; IHotspot hotspotToAdd = null; try { double pitch = double.Parse(hotspot.Pitch); double yaw = double.Parse(hotspot.Yaw); if (hotspot.HotspotType == "info") { hotspotToAdd = new InfoHotspot { Description = hotspot.Description, Footer = hotspot.Footer, Pitch = pitch, Yaw = yaw, Subtitle = hotspot.Subtitle, Title = hotspot.Title, URL = hotspot.HasURL ? hotspot.URL : null }; } else if (hotspot.HotspotType == "scene") { if (!hotspot.HasNextSceneId) { throw new Exception("Pointer should have scene!"); } hotspotToAdd = new SceneHotspot { Description = hotspot.Description, Footer = hotspot.Footer, Pitch = pitch, Yaw = yaw, Subtitle = hotspot.Subtitle, Title = hotspot.Title, SceneId = hotspot.NextSceneId }; } var scene = Loader.Scenes.FirstOrDefault(x => x.Name == hotspot.CurrentSceneId); if (scene != null) { scene.Hotspots.Add(hotspotToAdd); Loader.UpdateScenes(); } else { throw new Exception($"Scene isn't found with name '{hotspot.CurrentSceneId}'!"); } } catch (Exception ex) { success = false; message = ex.Message; } return(new ObjectResult(new { success, message })); }
private void OnHitRaycast(Transform hitRaycastTransform) { TextHotspot textHotspot = hitRaycastTransform.GetComponent <TextHotspot> (); if (textHotspot != null) { textHotspot.ChangeVisiblePopup(); } SceneHotspot sceneHotspot = hitRaycastTransform.GetComponent <SceneHotspot> (); if (sceneHotspot != null) { sceneHotspot.PresentScene(); } Button button = hitRaycastTransform.GetComponent <Button> (); if (button != null) { button.onClick.Invoke(); } }