void Start() { Debug.Log("GuiController start"); foreach (var curPrefab in screenPrefabs) { // Debug.Log("Screen " + curPrefab.name + " instantiated"); GameObject curScreen = Instantiate(curPrefab); if (screensRoot != null) { curScreen.transform.SetParent(screensRoot.transform, false); } else { curScreen.transform.SetParent(this.gameObject.transform, false); } GUIScreen guiScreen = curScreen.GetComponent <GUIScreen>(); screens.Add(guiScreen); } foreach (var curScreen in screens) { curScreen.gameObject.SetActive(false); } foreach (var curScreen in currentScreens) { curScreen.Show(); } }
private void Clear() { if (current != null) { GameObject.Destroy(current.gameObject); } current = null; }
public void ShowScreen <T>(bool hideAll = false) where T : GUIScreen { GUIScreen foundScreen = FoundScreen <T>(); if (foundScreen != null) { ShowScreen(foundScreen, hideAll); } }
private T CreateScreen <T>() where T : GUIScreen { Clear(); T screen = GameObject.Instantiate(Resources.Load <T>("GUI/Screens/" + typeof(T).Name)); screen.transform.SetParent(this.parent); current = screen; return(screen); }
public void HideScreen <T>() where T : GUIScreen { GUIScreen foundScreen = FoundScreen <T>(); if (foundScreen != null) { foundScreen.Hide(); } }
public void PushScreen <T>(bool isPopup) where T : GUIScreen { GUIScreen foundScreen = FoundScreen <T>(); if (foundScreen != null) { PushScreen(foundScreen, isPopup); } }
public void HideCurrentScreen() { if (currentScreen == null) return; //QQ if (currentScreen.type == ScreenType.GameGUI) return; Debug.Log("Hiding " + currentScreen.type); currentScreen.Hide(); currentScreen = null; }
private void OnEnable() { guiController = GetComponentInParent<GUIController>(); guiScreen = GetComponent<GUIScreen>(); var inGame = !!SpaceTraderConfig.LocalPlayer; guiScreen.ShowHeader = inGame; headerImage.gameObject.SetActive(!inGame); }
public void Update() { if (timeout != 0.0f && Time.time > timeout) { if ( Screen != null ) { GUIManager.GetInstance().Remove(Screen.Parent); Screen = null; } } }
public void PushScreen <T>(bool isPopup) where T : GUIScreen { GUIScreen foundScreen = FoundScreen <T>(); if (foundScreen != null) { PushScreen(foundScreen, isPopup); } else { Debug.LogWarning("Screen " + typeof(T) + " not found!"); } }
public void ShowScreen <T>(bool hideAll = false) where T : GUIScreen { GUIScreen foundScreen = FoundScreen <T>(); if (foundScreen != null) { ShowScreen(foundScreen, hideAll); } else { Debug.LogWarning("Screen " + typeof(T) + " not found!"); } }
public override void OnInspectorGUI() { GUILayout.BeginHorizontal(); GUILayout.Label("Show Default Inspector"); GUILayout.FlexibleSpace(); Color oldColor = GUI.color; showDefaultInspector = GUILayout.Toggle(showDefaultInspector, ""); GUILayout.EndHorizontal(); if (showDefaultInspector) DrawDefaultInspector(); if (!onSelected) // this must be Pauls name. { onSelected = true; OnSelected(); //?this is called just to get OnSelected called when the first gui call happens ? } // Save / Load GUILayout.BeginHorizontal(); if (GUILayout.Button("SAVE TO OBJECT")) { if (menuTree.info != null) { //myObject.screenInfo = menuTree.info; myObject.screenInfo = new ScreenInfo(); myObject.screenInfo.Screens = new List<GUIScreen>(); foreach (GUIScreen screen in menuTree.info.Screens) { GUIScreen newScreen = new GUIScreen(); newScreen.CopyFrom(screen); myObject.screenInfo.Screens.Add(newScreen); } } } if (GUILayout.Button("READ FROM OBJECT")) { menuTree = SIIMenuTreeNode.BuildMenu(myObject.screenInfo); } GUILayout.EndHorizontal(); GUI.color = Color.cyan; if (menuTree != null) menuTree.ShowInspectorGUI(0); else { GUILayout.Button("No Menu exists for XMLName"); } GUI.color = oldColor; return; }
public void PushScreen(GUIScreen screen, bool isPopup) { if (!isPopup) { foreach (var curScreen in screenStack) { curScreen.Hide(); } } screen.Show(); screenStack.Push(screen); int i = 0; }
public void HideScreen <T>() where T : GUIScreen { GUIScreen foundScreen = FoundScreen <T>(); if (foundScreen != null) { foundScreen.Hide(); SortByLayer(); } else { Debug.LogWarning("Screen " + typeof(T) + " not found!"); } }
public void ShowScreen(GUIScreen screen, bool hideAll = false) { if (hideAll) { foreach (var curScreen in screens) { if (curScreen.GetType() != screen.GetType()) { curScreen.Hide(); } } screenStack.Clear(); } screen.Show(); }
public void PopScreen() { if (screenStack.Count == 0) { return; } GUIScreen curScreen = screenStack.Pop(); curScreen.Hide(); if (screenStack.Count > 0) { GUIScreen newScreen = screenStack.Peek(); newScreen.Show(); } }
// set the screenSource top and left to be relative to the screen center, although if the dialog is allowed // to move, we can add a centerX and centerY // Use this for initialization void Start () { // build a matrix to map the screenSource rectangle to a render texture viewport_x = Screen.width; viewport_y = Screen.height; mapSourceToTextureXfm = SetupMatrix(); if (alsoUse != null){ alsoUse.renderer.material = overlay.renderer.material; } color1 = new Color(1f,1f,1f,.95f); color2 = new Color(1f,1f,1f,.4f); // create the dialog DialogMsg dmsg = new DialogMsg(); dmsg.xmlName = "dialog.vitals.grapher"; dmsg.className = "VitalsGUI"; vitalsGUI = GUIManager.GetInstance().LoadDialog( dmsg ); vitalsGUI.Close(); }
public GUIScreen Load( string XMLName, string ClassName ) { if ( XMLName == null || XMLName == "" || ClassName == null || ClassName == "" ) return null; // this code loads the screen but doesn't start it in the GUI manager ScreenInfo si = GUIManager.GetInstance().LoadFromFileRaw(XMLName,ClassName); guiScreen = si.Screen; // call the class Load method for init GUIDialog dialog = si.Screen as GUIDialog; if ( dialog != null ) { // dummy, not really needed DialogMsg dmsg = new DialogMsg(); dmsg.className = ClassName; dmsg.xmlName = XMLName; // load dialog.Load(dmsg); } // get W/H of overall area if ( ForceToGUISize == true ) { #if USE_AREA screenSource.x = guiScreen.Area.x; screenSource.y = guiScreen.Area.y; screenSource.width = guiScreen.Area.width; screenSource.height = guiScreen.Area.height; #else screenSource.x = guiScreen.Style.contentOffset.x; screenSource.y = guiScreen.Style.contentOffset.y; screenSource.width = guiScreen.Style.fixedWidth; screenSource.height = guiScreen.Style.fixedHeight; #endif } // save startup state forceToGUISize = ForceToGUISize; return guiScreen; }
public void PushScreen(GUIScreen screen, bool isPopup) { if (!isPopup) { foreach (var curScreen in screenStack) { Debug.Log(curScreen.gameObject); curScreen.Hide(); } } screen.Show(); screenStack.Push(screen); int i = 0; foreach (var curScreen in screenStack) { curScreen.OffsetZ = i++; } SortByLayer(); }
public static GameObject GetParentObject(GameObject go) { GameObject result = null; Transform parent = go.transform.parent; while (parent != null) { GUIScreen component = parent.gameObject.GetComponent <GUIScreen>(); CommonDialog component2 = parent.gameObject.GetComponent <CommonDialog>(); if (component != null) { result = parent.gameObject; break; } if (component2 != null) { result = parent.gameObject; break; } parent = parent.parent; } return(result); }
public static SIIMenuTreeNode BuildMenu(ScreenInfo screenInfo) { if (screenInfo == null) return null; SIIMenuTreeNode returnNode = new SIIMenuTreeNode(); returnNode.filePath = "Object"; returnNode.info = new ScreenInfo(); returnNode.info.Screens = new List<GUIScreen>(); returnNode.children = new List<ScreenMenuTreeNode>(); foreach(GUIScreen screen in screenInfo.Screens) { GUIScreen newScreen = new GUIScreen(); newScreen.CopyFrom(screen); returnNode.info.Screens.Add(newScreen); ScreenMenuTreeNode newNode = ScreenMenuTreeNode.BuildMenu(newScreen); newNode.parent = returnNode; returnNode.children.Add(newNode); } return returnNode; }
ElementMenuTreeNode newNode; // used when building up new menus public static ScreenMenuTreeNode BuildMenu(GUIScreen info) // pass in the relative path { ScreenMenuTreeNode returnNode = new ScreenMenuTreeNode(); returnNode.info = info; returnNode.children = new List<ElementMenuTreeNode>(); foreach (GUIObject obj in returnNode.info.Elements) { // Containers nest, so deal with it slightly different. if (obj.GetType() == typeof(GUIContainer) || obj.GetType().BaseType == typeof(GUIContainer)) { ElementMenuTreeNode newNode = ElementMenuTreeNode.BuildMenu(returnNode, obj as GUIContainer); if (newNode != null) { newNode.screenParent = returnNode; returnNode.children.Add(newNode); } } else { ElementMenuTreeNode newNode = new ElementMenuTreeNode(); newNode.screenParent = returnNode; returnNode.children.Add(newNode); } } return returnNode; }
public void OkCallback( GUIScreen screen, GUIObject guiobj, string args ) { // find edit box string utterance; GUIEditbox editbox = screen.Find("contentText") as GUIEditbox; if (editbox != null) { utterance = editbox.text; UnityEngine.Debug.Log("NluPrompt().OkCallback() : Text=" + utterance); } else return; // close the dialog GUIManager.GetInstance().Remove(screen.Parent); // send txt to Nlu UnityEngine.Debug.Log("Say <" + utterance + ">"); // send to Nlu NluMgr.GetInstance().Utterance(utterance, "nurse"); // send to brain //SpeechProcessor.GetInstance().SpeechToText(utterance); }
public void SetType( string guiName, GUIEditObject.GUITypes guiType ) { // create based on type if ( guiType == GUITypes.Screen ) { guiScreen = new GUIScreen(); guiScreen.name = guiName; } if ( guiType == GUITypes.Area ) { guiObject = new GUIArea(); guiObject.name = guiName; } if ( guiType == GUITypes.Label ) { guiObject = new GUILabel(); guiObject.name = guiName; } if ( guiType == GUITypes.Button ) { guiObject = new GUIButton(); guiObject.name = guiName; } if ( guiType == GUITypes.Horizontal ) { guiObject = new GUIHorizontalCommand(); guiObject.name = guiName; } if ( guiType == GUITypes.Vertical ) { guiObject = new GUIVerticalCommand(); guiObject.name = guiName; } if ( guiType == GUITypes.Scrollview ) { guiObject = new GUIScrollView(); guiObject.name = guiName; } if ( guiType == GUITypes.Toggle ) { guiObject = new GUIToggle(); guiObject.name = guiName; } if ( guiType == GUITypes.Space ) { guiObject = new GUISpace(); guiObject.name = guiName; } if ( guiType == GUITypes.EditBox ) { guiObject = new GUIEditbox(); guiObject.name = guiName; } if ( guiType == GUITypes.Box ) { guiObject = new GUIBox(); guiObject.name = guiName; } if ( guiType == GUITypes.HorizontalSlider ) { guiObject = new GUIHorizontalSlider(); guiObject.name = guiName; } if ( guiType == GUITypes.VerticalSlider ) { guiObject = new GUIVerticalSlider(); guiObject.name = guiName; } if ( guiType == GUITypes.Movie ) { guiObject = new GUIMovie(); guiObject.name = guiName; } }
public override void PutMessage(GameMsg msg) { AssessmentMgrDialogMsg dmsg = msg as AssessmentMgrDialogMsg; if (dmsg != null) { if (dmsg.List != null) List = dmsg.List; if ( dmsg.Report != null ) Report = dmsg.Report; // close info dialog InfoDialogMsg idmsg = new InfoDialogMsg(); idmsg.command = DialogMsg.Cmd.close; InfoDialogLoader.GetInstance().PutMessage(idmsg); // put up assessment dialog if (Screen != null) { GUIManager.GetInstance().Remove(Screen.Parent); Screen = null; } DialogLoader dl = DialogLoader.GetInstance(); if (dl != null) { dl.LoadXML("dialog.assessment"); GUIScreen dp = Screen = dl.ScreenInfo.FindScreen("AssessmentScreen"); dp.SetLabelText("titleBarText", "Scenario Assessment"); GUIContainer guiobj = dp.Find("scrollBox") as GUIContainer; if (guiobj != null) { GUIReportObject reportObj = new GUIReportObject(Report); reportObj.SetSkin(gSkin); guiobj.Elements.Add(reportObj); } } } //base.PutMessage(msg); }
public void AddBlankScreenInfo( string name ) { // create new SI structure with new screen inside ScreenInfo si = new ScreenInfo(); GUIManager.GetInstance().Add(si); GUIScreen newscreen = new GUIScreen(); newscreen.name = name; si.AddScreen(newscreen); // build the heirarchy BuildScreenHeirarchy(name,si); }
public virtual GameObject BuildScreen( GUIScreen screen, GUIEditScreenInfo esi ) { GameObject newobj = new GameObject(name); if ( newobj != null ) { GUIEditObject eo = newobj.AddComponent(typeof(GUIEditObject)) as GUIEditObject; eo.guiScreen = screen; eo.name = screen.name; eo.LoadedXML = esi.loadName; eo.editSI = esi; // add all the objects below this foreach( GUIObject guiObj in screen.Elements ) BuildObject(newobj, guiObj); // initialize (sets up all skins/styles) //screen.Initialize(esi.ScreenInfo); } return newobj; }
public bool BuildScreenHeirarchy( string pathname, ScreenInfo si, bool makeNewSI=false ) { makeNewSI=false; if ( si == null || si.Screens.Count == 0 ) return false; string name = Path.GetFileNameWithoutExtension(pathname); GUIEditScreenInfo esi=null; // make name string loadedXML = name + ".xml"; // add game object for this heirarchy GameObject newobj = new GameObject(name + ".xml"); if ( newobj != null ) { // either make a new SI if inspecting, or use the original if loading esi = newobj.AddComponent(typeof(GUIEditScreenInfo)) as GUIEditScreenInfo; if ( makeNewSI == true ) { ScreenInfo newSI = new ScreenInfo(); newSI.isModal = false; esi.ScreenInfo = newSI; } else { esi.ScreenInfo = si; } esi.saveName = loadedXML; esi.loadName = pathname; // make this a child of the GUIManager newobj.transform.parent = myObject.gameObject.transform; newobj.transform.localPosition = Vector3.zero; // make this selected object Selection.activeGameObject = newobj; } // build only first screen (for now) if ( si.Screens.Count > 0 ) { foreach( GUIScreen s in si.Screens ) { GUIScreen tmp = s; // make sure that this is a base screen if we're making new if ( makeNewSI == true ) { GUIScreen newScreen = new GUIScreen(); newScreen.type = "GUIScreen"; newScreen.CopyFrom(s); newScreen.name = s.name; esi.ScreenInfo.AddScreen(newScreen); tmp = newScreen; } // this will recursively build the whole structure GameObject go = BuildScreen(tmp,esi); // handle parenting go.transform.parent = newobj.transform; go.transform.localPosition = Vector3.zero; } // add new one //GUIManager.GetInstance().Add (esi.ScreenInfo); // we're ok return true; } return false; }
public void ShowScreen(ScreenType type) { HideCurrentScreen(); currentScreen = GUIScreens.First(screen => screen.type == type); currentScreen.Show(); }
public static void SetActive(this GUIScreen @this, bool state) { @this.gameObject.SetActive(state); }
private void Awake() { guiScreen = GetComponent<GUIScreen>(); }
override public void PutMessage(GameMsg msg) { QuickInfoMsg dialogmsg = msg as QuickInfoMsg; if (dialogmsg != null) { // only call base if this message is for us base.PutMessage(msg); switch ( dialogmsg.command ) { case DialogMsg.Cmd.open: { if (dialogmsg.timeout == 0.0f) timeout = 0.0f; else timeout = Time.time + dialogmsg.timeout; DialogLoader dl = DialogLoader.GetInstance(); if (dl != null) { DialogMsg dmsg = new DialogMsg(); dmsg.className = "GUIDialog"; dmsg.xmlName = "dialog.quickinfo.template"; dmsg.modal = false; Screen = GUIManager.GetInstance().LoadDialog(dmsg); Screen.SetLabelText("titleBarText", dialogmsg.title); Screen.SetLabelText("contentText", dialogmsg.text); } LogMgr.GetInstance().Add(new ParamLogItem(Time.time, "QuickInfoMsg", dialogmsg.text)); } break; case DialogMsg.Cmd.close: GUIManager.GetInstance().Remove(Screen.Parent); Screen = null; break; } } }
public static GameObject LoadCommonGUI(string guiName, GameObject parent) { string path = "UICommon/" + guiName; GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(Resources.Load(path, typeof(GameObject))); if (gameObject == null) { return(null); } gameObject.name = guiName; gameObject.SetActive(true); Vector3 localPosition = gameObject.transform.localPosition; if (parent != null) { Vector3 localScale = gameObject.transform.localScale; gameObject.transform.parent = parent.transform; gameObject.transform.localScale = localScale; } gameObject.transform.localPosition = localPosition; if (localPosition.x < 0f) { localPosition.x = -localPosition.x; localPosition.x = (float)((int)localPosition.x % 2000); if (localPosition.x > 1000f) { localPosition.x -= 2000f; } localPosition.x = -localPosition.x; } else { if (localPosition.x > 1000f) { localPosition.x -= 2000f; } localPosition.x = (float)((int)localPosition.x % 2000); } if (localPosition.y < 0f) { localPosition.y = -localPosition.y; localPosition.y = (float)((int)localPosition.y % 2000); if (localPosition.y > 1000f) { localPosition.y -= 2000f; } localPosition.y = -localPosition.y; } else { if (localPosition.y > 1000f) { localPosition.y -= 2000f; } localPosition.y = (float)((int)localPosition.y % 2000); } gameObject.transform.localPosition = localPosition; GUICollider component = gameObject.GetComponent <GUICollider>(); if (component != null) { component.SetOriginalPos(localPosition); } GUIScreen component2 = gameObject.GetComponent <GUIScreen>(); if (component2 != null) { component2.ShowGUI(); } return(gameObject); }
public override void Process(GUIScreen parentScreen, GUIArea container) { base.Process(parentScreen, container); if (scrollMenu != null) { scrollMenu.Process(parentScreen, container); menus = new GUIScrollMenu[4]; menus[0] = new GUIScrollMenu(); menus[1] = new GUIScrollMenu(); menus[2] = new GUIScrollMenu(); menus[3] = new GUIScrollMenu(); menus[0].CopyFrom(scrollMenu); menus[1].CopyFrom(scrollMenu); menus[2].CopyFrom(scrollMenu); menus[3].CopyFrom(scrollMenu); menus[0].buttonTemplate = scrollMenu.buttonTemplate; menus[0].scrollviewTemplate = scrollMenu.scrollviewTemplate; menus[0].Process(parentScreen, container); menus[1].buttonTemplate = scrollMenu.buttonTemplate; menus[1].scrollviewTemplate = scrollMenu.scrollviewTemplate; menus[1].Process(parentScreen, container); menus[2].buttonTemplate = scrollMenu.buttonTemplate; menus[2].scrollviewTemplate = scrollMenu.scrollviewTemplate; menus[2].Process(parentScreen, container); menus[3].buttonTemplate = scrollMenu.buttonTemplate; menus[3].scrollviewTemplate = scrollMenu.scrollviewTemplate; menus[3].Process(parentScreen, container); } if (divider != null) divider.Process(parentScreen, container); }