Quantcast
Channel: Latest Questions by Yanger_xy
Viewing all articles
Browse latest Browse all 61

Modal Dialog

$
0
0
Hello, everyone! I wanna to write a function that show a dialog window, the only method i thought about is that defining a global boolean variable to record whether we are showing a gui, if so, i must maintain its value when i or my partner is showing a gui! Are there any other method? i find a way here : [link text][1] [1]: http://forum.unity3d.com/threads/38911-Modal-GUI.Windows but it is in javascript version, can anybody translate it into C# version? Thanks in advance! static function ModalWindow(rect:Rect,title:String,windowFunction:Function) { return GUILayout.Window(GUIUtility.GetControlID(FocusType.Passive),rect,function(id:int) { GUI.depth=0; //first get a control id. every subsequent call to GUI control function will get a larger id var min=GUIUtility.GetControlID(FocusType.Native); //we can use the id to check if current control is inside our window if(GUIUtility.hotControlmax && max!=-1)) setHotControl(-1); //focus the window and bring it to front GUI.FocusWindow(id); GUI.BringWindowToFront(id); },title); } static function setHotControl(id:int) { //don't block events if mousePointer is outside "Screen", otherwise if we run the game in editor //we would block the editor GUI as well. if(Rect(0,0,Screen.width,Screen.height).Contains(GUIUtility.GUIToScreenPoint(Event.current.mousePosition))) GUIUtility.hotControl=id; }

Viewing all articles
Browse latest Browse all 61

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>