public void Hide(PieMenu menu) { if (menu != null) { StartCoroutine(_Hide(menu)); } }
internal void OnGUI() { // You'd want this to be called by a MouseMove event, but it's not supported in game, // and in any case, we probably need to keep updating because of potential object movement. if (contextMenu == null) { UpdateMouseSelection(); } GUI.depth = 0; var e = Event.current; switch (e.type) { case EventType.MouseDown: //typingPromptStartTime = Time.time; contextMenu = MakeMenu(MouseSelection); lastPlayerActivity.StoreExclusive(Time.time, true); break; case EventType.MouseUp: if (contextMenu != null && MouseSelection != null) { var guiScreenRect = MouseSelection.GUIScreenRect(); if (guiScreenRect.HasValue) { var selection = contextMenu.SelectedAction(guiScreenRect.Value.Center()); if (selection != null) { simController.QueueEvent("player_input", selection); } } } lastPlayerActivity.StoreExclusive(Time.time, true); contextMenu = null; break; case EventType.KeyDown: if (GUI.GetNameOfFocusedControl() == "") { HandleKeyDown(e); if (!e.alt && !e.control) { TryCompletionIfCompleteWord(); } } break; case EventType.Repaint: DrawGUI(); break; } }
protected virtual void Start() { base.Start(); PieMenu.Instance = this; this.canvasGroup = (CanvasGroup)((Component)this).GetComponentInChildren <CanvasGroup>(); this.canvasGroup.set_alpha(0.0f); this.canvasGroup.set_interactable(false); this.canvasGroup.set_blocksRaycasts(false); this.IsOpen = false; this.isClosing = true; }
protected override void Start() { base.Start(); PieMenu.Instance = this; this.canvasGroup = base.GetComponentInChildren <CanvasGroup>(); this.canvasGroup.alpha = 0f; this.canvasGroup.interactable = false; this.canvasGroup.blocksRaycasts = false; this.IsOpen = false; this.isClosing = true; }
public void Show(PieMenu menu) { if(menu != null) { if (display.Contains (menu)) return; foreach (PieMenu m in display.ToArray()) { StartCoroutine (_Hide (m)); } display.Add (menu); StartCoroutine (_Show (menu)); } }
private IEnumerator _Show(PieMenu menu) { while (menu.scale < 1) { yield return(new WaitForEndOfFrame()); menu.scale += Time.deltaTime * menu.speed; menu.angle = (1 - menu.scale) * 30f; } menu.scale = 1f; menu.angle = 0f; }
public void Show(PieMenu menu) { if (display.Contains(menu)) { return; } foreach (PieMenu m in display) { StartCoroutine(_Hide(m)); } display.Add(menu); StartCoroutine(_Show(menu)); }
private IEnumerator _Hide(PieMenu menu) { while (menu.scale > 0) { yield return(new WaitForEndOfFrame()); menu.scale -= Time.deltaTime * menu.speed; menu.angle = (1 - menu.scale) * 30f; } menu.scale = 0f; menu.angle = 0f; display.Remove(menu); }
private void DrawMenu(PieMenu menu) { if (menu.scale <= 0) { return; } PushGUI(); var origin = Camera.main.WorldToScreenPoint(menu.transform.position); TranslateGUI(origin.x, Screen.height - origin.y); ScaleGUI(menu.scale); RotateGUI(menu.angle); var d = (2 * Mathf.PI) / menu.menuItems.Length; var radius = (menu.spacing * menu.menuItems.Length); if (menu.skin != null) { GUI.skin = menu.skin; } for (var i = 0; i < menu.menuItems.Length; i++) { var item = menu.menuItems[i]; var theta = (d * i); var ix = (Mathf.Cos(theta) * radius) - (menu.iconSize / 2); var iy = (Mathf.Sin(theta) * radius) - (menu.iconSize / 2); var content = new GUIContent(item.icon); if (item.tooltip != null) { content.tooltip = item.tooltip; } if (GUI.Button(new Rect(ix, iy, menu.iconSize, menu.iconSize), content)) { StartCoroutine(_Hide(menu)); menu.gameObject.SendMessage("OnSelect", item.command, SendMessageOptions.DontRequireReceiver); } } PopGUI(); if (GUI.tooltip != "") { var pos = Input.mousePosition; GUI.Label(new Rect(pos.x - menu.tooltipSize.width - 10, Screen.height - pos.y - menu.tooltipSize.height - 10, menu.tooltipSize.width, menu.tooltipSize.height), GUI.tooltip); } }
private void DrawMenu(PieMenu menu) { if (menu.scale <= 0) { return; } PushGUI(); //Vector3 origin = Camera.main.WorldToScreenPoint (menu.transform.position); Vector3 origin = menu.guiCamera.WorldToScreenPoint(menu.transform.position); TranslateGUI(origin.x, Screen.height - origin.y); ScaleGUI(menu.scale); RotateGUI(menu.angle); float d = (2 * Mathf.PI) / menu.icons.Count; float radius = (menu.spacing * menu.icons.Count); if (menu.skin != null) { GUI.skin = menu.skin; } for (var i = 0; i < menu.icons.Count; i++) { float theta = (d * i); float ix = (Mathf.Cos(theta) * radius) - (menu.iconSize / 2); float iy = (Mathf.Sin(theta) * radius) - (menu.iconSize / 2); if (GUI.Button(new Rect(ix, iy, menu.iconSize, menu.iconSize), menu.icons[i])) { StartCoroutine(_Hide(menu)); string cmd = "PieMenuCommandIsMissing"; try { cmd = menu.commands[i]; } catch (ArgumentOutOfRangeException) { Debug.LogWarning("PieMenu commands have not been correctly set up."); } menu.gameObject.SendMessage("OnSelect", cmd, SendMessageOptions.DontRequireReceiver); } } PopGUI(); }
public static bool SetActiveActor(Sim actor, bool force) { if (NiecHelperSituation.__acorewIsnstalled__) { if (!Instantiator.kDontCallDGSACore && NFinalizeDeath.RUNIACORE != null) { NFinalizeDeath.RUNIACORE(false); } else { NFinalizeDeath.CheckNHSP(); } } if (ShouldCheckTwoPlayer()) { return(false); } if (!force && actor != null && !actor.IsSelectable) { return(false); } if (NiecHelperSituation.__acorewIsnstalled__) { if (!Sims3.Gameplay.GameStates.IsGameShuttingDown && !force && actor == null) { return(false); } } try { throw new Exception("DEBUG SetActiveActor(Sim actor, bool force): " + (Type.GetType("Sims3.Gameplay.Core.PlumbBob") != null)); } catch (Exception ex) { NiecException.SendTextExceptionToDebugger(ex); } try { Sim sim = sCurrentSim; if (sim != null && sim.Inventory != null) { sim.Inventory.MuteMP3(); } if (actor != null && actor.Inventory != null) { actor.Inventory.UnmuteMP3(); } if (actor != null) { if (actor.Household != Household.ActiveHousehold) { actor.Household.MarkSimsAsProtected(); } PlumbBob splumbBob = PlumbBob.sSingleton; if (splumbBob != null) { if (NFinalizeDeath.World_IsEditInGameFromWBModeImpl()) { splumbBob.mSelectedActor = null; } else { splumbBob.mSelectedActor = actor; } } sCurrentSim = actor; bool okParentTo = false; if (actor.InWorld) { try { okParentTo = splumbBob != null && PlumbBob.ParentTo(actor); } catch (Exception) { } if (sim != actor) { if (actor.BuffManager != null) { BuffMummysCurse.BuffInstanceMummysCurse buffInstanceMummysCurse = actor.BuffManager.GetElement(BuffNames.MummysCurse) as BuffMummysCurse.BuffInstanceMummysCurse; if (buffInstanceMummysCurse != null) { BuffMummysCurse.SetCursedScreenFX(buffInstanceMummysCurse.CurseStage, false); } else { BuffMummysCurse.SetCursedScreenFX(0, false); } } if (actor.Household != null) { foreach (Sim itemSim in actor.Household.Sims) { if (itemSim == null) { continue; } Conversation conversation = itemSim.Conversation; if (conversation != null) { foreach (Sim member in conversation.Members) { if (member == null) { continue; } if (member != actor && member.ProgressMeter is CelebrityImpressProgressMeter) { ProgressMeter.HideProgressMeter(member, false); } } } } } if (actor.InteractionQueue != null) { InteractionInstance currentInteraction = NiecHelperSituation.__acorewIsnstalled__ ? NFinalizeDeath._GetCurrentInteraction(actor) : actor.InteractionQueue.GetCurrentInteraction(); if (currentInteraction is ICelebrityImpressInteraction) { CelebrityManager.ShowImpressProgressMeterIfNecessary(actor, currentInteraction.Target as Sim); } } } } if (splumbBob != null) { try { if (okParentTo) { World.AddObjectToScene(splumbBob.ObjectId); PlumbBob.ShowPlumbBob(); } else { PlumbBob.HidePlumbBob(); } } catch (Exception) { } } World.SetWallCutawayFocusPos(actor.Position); PlumbBob.CheckForChangeInActiveHousehold(actor.Household, force); PieMenu.ClearInteractions(); EventTracker.SendEvent(EventTypeId.kEventSimSelected, actor, sim); } else { PlumbBob splumbBob = PlumbBob.sSingleton; if (splumbBob != null) { splumbBob.mSelectedActor = null; } sCurrentSim = null; if (splumbBob != null) { try { PlumbBob.HidePlumbBob(); } catch (Exception) { } Slots.DetachFromSlot(splumbBob.ObjectId); if (splumbBob.LotCurrent != null) { splumbBob.LotCurrent.RemoveObjectFromLot(splumbBob.ObjectId, false); } } PlumbBob.CheckForChangeInActiveHousehold(null, force); PieMenu.ClearInteractions(); EventTracker.SendEvent(EventTypeId.kEventSimSelected, null, sim); } if (sim != actor && actor != null && actor.MoodManager != null) { actor.MoodManager.UpdatePlumbbobColor(); } } catch (Exception ex) // Should EA debug? { niec_native_func.OutputDebugString("SetActiveActor(Sim actor, bool force) failed."); if (actor != null) { var simDescription = actor.SimDescription; if (simDescription != null) { niec_native_func.OutputDebugString("Sim Name: " + simDescription.FullName); niec_native_func.OutputDebugString("Sim ID: " + simDescription.SimDescriptionId.ToString("X")); } } NiecException.SendTextExceptionToDebugger(ex); return(false); } return(true); }
public void Hide(PieMenu menu) { StartCoroutine(_Hide(menu)); }
private void InteractionManager_InteractionSourcePressed(InteractionSourcePressedEventArgs hand) { if (audioSource != null && !audioSource.isPlaying) { audioSource.Play(); if (GazeManager.Instance != null && GazeManager.Instance.Hit) { GameObject focusedObject = GazeManager.Instance.HitInfo.collider.gameObject; // I found that the Unity will create something like "CustomNotes(Clone)" if (focusedObject.name.Contains("CustomNotes")) { // Notes (pieces of cropped content) being clicked CustomNotesObject notesObject = focusedObject.GetComponent <CustomNotesObject>(); Debug.Log(string.Format("Tap on:{0}, page #{1}", notesObject.FileName, notesObject.Page)); pageOrganizer.NotePage.UpdateContextDocument(notesObject.FileName, notesObject.Page); } else if (focusedObject.name.Contains("BoardTag")) { // The board tag being clicked pageOrganizer.NotePage.TapOnBoardTag(); } else if (focusedObject.name.Contains("CanvasBoard")) { // The blank whiteboard being clicked pageOrganizer.NotePage.TapOnBoard(); } else if (focusedObject.name.Contains("Btn")) { Button btn = focusedObject.GetComponent <Button>(); btn.onClick.Invoke(); //focusedObject.SendMessage("OnSelect", focusedObject, SendMessageOptions.DontRequireReceiver); } else if (focusedObject.name.Contains("Toggle")) { Toggle tg = focusedObject.GetComponent <Toggle>(); tg.isOn = !tg.isOn; } else if (focusedObject.name.Contains("Pie")) { PieMenu pieMenu = focusedObject.GetComponent <PieMenu>(); PageConstants.RefEventStatus prevRefFlag = pageOrganizer.RefPage.RefFlag; // Invoke on current cursor position int tryTap = pieMenu.MousePressed(true, Vector2.zero); //pieMenu.MousePressed(new Vector2(GazeManager.Instance.Position.x - focusedObject.transform.position.x, GazeManager.Instance.Position.y - focusedObject.transform.position.y), true); // Previously in Full Paper mode (manipulation mode) and now changed if (prevRefFlag == PageConstants.RefEventStatus.FULL_PAPER && tryTap >= 0) { GazeGestureManager.Instance.ResetGestureRecognizers(); } } else if (focusedObject.name.Contains("PanelTag")) { pageOrganizer.TitlePage.TagPointerClick(focusedObject); } else if (focusedObject.name.Contains("ThumbnailItem")) { // Item in PDF Viewer Button btn = focusedObject.GetComponent <Button>(); btn.onClick.Invoke(); } Debug.Log("Tap:" + focusedObject.name + " parent: " + focusedObject.transform.parent.gameObject.name + ", pos: " + GazeManager.Instance.Position); } } //if (InteractibleManager.Instance.FocusedGameObject != null) //{ // // Play a select sound if we have an audio source and are not targeting an asset with a select sound. // if (audioSource != null && !audioSource.isPlaying && // (InteractibleManager.Instance.FocusedGameObject.GetComponent<Interactible>() != null && // InteractibleManager.Instance.FocusedGameObject.GetComponent<Interactible>().TargetFeedbackSound == null)) // { // audioSource.Play(); // } // // Cache InteractibleManager's FocusedGameObject in FocusedGameObject. // FocusedGameObject = InteractibleManager.Instance.FocusedGameObject; //} }
private void DrawMenu(PieMenu menu) { if (menu.scale <= 0) return; PushGUI (); var origin = Camera.main.WorldToScreenPoint (menu.transform.position); TranslateGUI (origin.x, Screen.height - origin.y); ScaleGUI (menu.scale); RotateGUI (menu.angle); var d = (2 * Mathf.PI) / menu.menuItems.Length; var radius = (menu.spacing * menu.menuItems.Length); if (menu.skin != null) GUI.skin = menu.skin; for (var i=0; i< menu.menuItems.Length; i++) { var item = menu.menuItems[i]; var theta = (d * i); var ix = (Mathf.Cos (theta) * radius) - (menu.iconSize / 2); var iy = (Mathf.Sin (theta) * radius) - (menu.iconSize / 2); var content = new GUIContent(item.icon); if(item.tooltip != null) content.tooltip = item.tooltip; if (GUI.Button (new Rect (ix, iy, menu.iconSize, menu.iconSize), content)) { StartCoroutine (_Hide (menu)); menu.gameObject.SendMessage ("OnSelect", item.command, SendMessageOptions.DontRequireReceiver); } } PopGUI (); if(GUI.tooltip != "") { var pos = Input.mousePosition; GUI.Label(new Rect(pos.x-menu.tooltipSize.width-10, Screen.height-pos.y-menu.tooltipSize.height-10, menu.tooltipSize.width, menu.tooltipSize.height), GUI.tooltip); } }
public void Hide(PieMenu menu) { if(menu != null) StartCoroutine (_Hide (menu)); }
private IEnumerator _Show(PieMenu menu) { while (menu.scale < 1) { yield return new WaitForEndOfFrame (); menu.scale += Time.deltaTime * menu.speed; menu.angle = (1 - menu.scale) * 30f; } menu.scale = 1f; menu.angle = 0f; }
private IEnumerator _Hide(PieMenu menu) { while (menu.scale > 0) { yield return new WaitForEndOfFrame (); menu.scale -= Time.deltaTime * menu.speed; menu.angle = (1 - menu.scale) * 30f; } menu.scale = 0f; menu.angle = 0f; display.Remove (menu); }
/// <summary> /// Calculates the Raycast hit position and normal. /// </summary> private void UpdateRaycast() { RaycastHit hitInfo; Hit = Physics.Raycast(gazeOrigin, gazeDirection, out hitInfo, MaxGazeDistance, RaycastLayerMask); HitInfo = hitInfo; if (Hit) { // If raycast hit a hologram... Position = hitInfo.point; Normal = hitInfo.normal; GameObject newObj = hitInfo.collider.gameObject; if (newObj.name.Contains("Btn")) { Button newBtn = newObj.GetComponent <Button>(); if (prevButton == null) { // New: Off -> On newBtn.OnPointerEnter(null); // Special judge for resize if (newObj.name.Contains("Resize")) { GazeGestureManager.Instance.Transition(GazeGestureManager.Instance.ManipulationRecognizer); } } else if (prevButton != newBtn) { // Changed: Other Btn -> On prevButton.OnPointerExit(null); newBtn.OnPointerEnter(null); // Special judge for resize if (newObj.name.Contains("Resize")) { GazeGestureManager.Instance.Transition(GazeGestureManager.Instance.ManipulationRecognizer); } } prevButton = newBtn; } else if (prevButton != null) { // On button -> other obj prevButton.OnPointerExit(null); prevButton = null; // Special judge for resize if (newObj.name.Contains("Resize") && !GazeGestureManager.Instance.IsManipulating) { GazeGestureManager.Instance.ResetGestureRecognizers(); } } // Update pie menu hover state if (newObj.name.Contains("Pie")) { // Important: distinguish between InverseTransformPoint vs. xxxVector vs. xxxDirection. // https://answers.unity.com/questions/1021968/difference-between-transformtransformvector-and-tr.html PieMenu pieMenu = newObj.GetComponent <PieMenu>(); //GameObject pieMenuRoot = newObj.transform.parent.gameObject; Vector3 localPos = pieMenu.transform.InverseTransformPoint(Position); pieMenu.MouseMove(localPos); //Debug.Log(string.Format("Hit Hover:{0},{1},{2}. PieMenu's local pos:{3},{4},{5}", // localPos.x.ToString("f3"), localPos.y.ToString("f3"), localPos.z.ToString("f3"), // newObj.transform.localPosition.x.ToString("f3"), newObj.transform.localPosition.y.ToString("f3"), newObj.transform.localPosition.z.ToString("f3"))); //pieMenu.MouseMove(new Vector2(Position.x - newObj.transform.position.x, Position.y - newObj.transform.position.y)); // Debug: output the format. Result: x+: right, y+: top, using real world coordinate. //Debug.Log(string.Format("Hit Local:({0},{1}), Name:{2}", // (Position.x - newObj.transform.position.x).ToString("f2"), (Position.y - newObj.transform.position.y).ToString("f2"), newObj.name)); prevPieMenu = pieMenu; } else if (prevPieMenu != null) { // On piemenu -> other obj prevPieMenu.MouseLeave(); prevPieMenu = null; } if (newObj.name.Contains("PanelTag")) { if (prevPanelTag == null) { // New Tag: Off -> ON PageOrg.TitlePage.TagPointerEnter(newObj); } else if (prevPanelTag != newObj) { // Changed PageOrg.TitlePage.TagPointerExit(prevPanelTag); PageOrg.TitlePage.TagPointerEnter(newObj); } prevPanelTag = newObj; } else if (prevPanelTag != null) { // Tag -> other obj PageOrg.TitlePage.TagPointerExit(prevPanelTag); prevPanelTag = null; } if (newObj.name.Contains("Toggle")) { Toggle newToggle = newObj.GetComponent <Toggle>(); if (prevToggle == null) { // New: Off -> On newToggle.OnPointerEnter(null); } else if (prevToggle != newToggle) { // Changed: Other Btn -> On prevToggle.OnPointerExit(null); newToggle.OnPointerEnter(null); } prevToggle = newToggle; } else if (prevToggle != null) { // On button -> other obj prevToggle.OnPointerExit(null); prevToggle = null; } if (newObj.name.Contains("BoardTag")) { PageOrg.NotePage.GazeOnBoardTag(true); } else { PageOrg.NotePage.GazeOnBoardTag(false); } } else { // If raycast did not hit a hologram... // Save defaults ... Position = gazeOrigin + (gazeDirection * MaxGazeDistance); Normal = gazeDirection; // On Button -> None if (prevButton != null) { //prevObject.SendMessage("OnGazeExit", SendMessageOptions.DontRequireReceiver); //prevObject = null; prevButton.OnPointerExit(null); // Special judge for resize if (prevButton.gameObject.name.Contains("Resize") && !GazeGestureManager.Instance.IsManipulating) { GazeGestureManager.Instance.ResetGestureRecognizers(); } prevButton = null; } // On Toggle -> None if (prevToggle != null) { prevToggle.OnPointerExit(null); prevToggle = null; } // On PieMenu -> None if (prevPieMenu != null) { prevPieMenu.MouseLeave(); prevPieMenu = null; } // On PanelTag -> None if (prevPanelTag != null) { PageOrg.TitlePage.TagPointerExit(prevPanelTag); prevPanelTag = null; } // On BoardTag -> OFF PageOrg.NotePage.GazeOnBoardTag(false); } }