/// <summary> /// Draw the custom wizard. /// </summary> void OnGUI() { NGUIEditorTools.SetLabelWidth(80f); List <Camera> list = NGUIEditorTools.FindAll <Camera>(); if (list.Count > 0) { DrawRow(null); NGUIEditorTools.DrawSeparator(); mScroll = GUILayout.BeginScrollView(mScroll); { var __list1 = list; var __listCount1 = __list1.Count; for (int __i1 = 0; __i1 < __listCount1; ++__i1) { var cam = (Camera)__list1[__i1]; DrawRow(cam); } } GUILayout.EndScrollView(); } else { GUILayout.Label("No cameras found in the scene"); } }
/// <summary> /// Collect a list of panels. /// </summary> static List <UIPanel> GetListOfPanels() { List <UIPanel> panels = NGUIEditorTools.FindAll <UIPanel>(); for (int i = panels.Count; i > 0;) { if (!panels[--i].showInPanelTool) { panels.RemoveAt(i); } } return(panels); }
void MarkAsChanged() { List <UILabel> labels = NGUIEditorTools.FindAll <UILabel>(); foreach (UILabel lbl in labels) { if (UIFont.CheckIfRelated(lbl.bitmapFont, mFont)) { lbl.bitmapFont = null; lbl.bitmapFont = mFont; } } }
void MarkAsChanged() { var labels = NGUIEditorTools.FindAll <UILabel>(); foreach (UILabel lbl in labels) { if (NGUITools.CheckIfRelated(lbl.font as INGUIFont, mFont)) { lbl.font = null; lbl.font = mFont; } } }
/// <summary> /// Update all labels associated with this font. /// </summary> void MarkAsChanged() { if (NGUISettings.font != null) { List <UILabel> labels = NGUIEditorTools.FindAll <UILabel>(); foreach (UILabel lbl in labels) { if (lbl.font == NGUISettings.font) { lbl.font = null; lbl.font = NGUISettings.font; } } } }
/// <summary> /// Update all labels associated with this font. /// </summary> void MarkAsChanged() { Object obj = (Object)NGUISettings.FMFont ?? (Object)NGUISettings.BMFont; if (obj != null) { List <UILabel> labels = NGUIEditorTools.FindAll <UILabel>(); foreach (UILabel lbl in labels) { if (lbl.ambigiousFont == obj) { lbl.ambigiousFont = null; lbl.ambigiousFont = obj; } } } }
void MarkAsChanged() { List <UILabel> labels = NGUIEditorTools.FindAll <UILabel>(); { var __list1 = labels; var __listCount1 = __list1.Count; for (int __i1 = 0; __i1 < __listCount1; ++__i1) { var lbl = (UILabel)__list1[__i1]; { if (UIFont.CheckIfRelated(lbl.bitmapFont, mFont)) { lbl.bitmapFont = null; lbl.bitmapFont = mFont; } } } } }
/// <summary> /// Draw the custom wizard. /// </summary> void OnGUI() { NGUIEditorTools.SetLabelWidth(80f); List <Camera> list = NGUIEditorTools.FindAll <Camera>(); if (list.Count > 0) { DrawRow(null); NGUIEditorTools.DrawSeparator(); mScroll = GUILayout.BeginScrollView(mScroll); foreach (Camera cam in list) { DrawRow(cam); } GUILayout.EndScrollView(); } else { GUILayout.Label("No cameras found in the scene"); } }
/// <summary> /// Update all labels associated with this font. /// </summary> void MarkAsChanged() { Object obj = (Object)NGUISettings.FMFont ?? (Object)NGUISettings.BMFont; if (obj != null) { List <UILabel> labels = NGUIEditorTools.FindAll <UILabel>(); { var __list1 = labels; var __listCount1 = __list1.Count; for (int __i1 = 0; __i1 < __listCount1; ++__i1) { var lbl = (UILabel)__list1[__i1]; { if (lbl.ambigiousFont == obj) { lbl.ambigiousFont = null; lbl.ambigiousFont = obj; } } } } } }
static public void Upgrade() { int count = 0; List <UISlicedSprite> sliced = NGUIEditorTools.FindAll <UISlicedSprite>(); List <UIFilledSprite> filled = NGUIEditorTools.FindAll <UIFilledSprite>(); List <UITiledSprite> tiled = NGUIEditorTools.FindAll <UITiledSprite>(); int spriteID, inputID; SerializedObject ob; // Determine the object instance ID of the UISprite class { GameObject go = EditorUtility.CreateGameObjectWithHideFlags("Temp", HideFlags.HideAndDontSave); UISprite uiSprite = go.AddComponent <UISprite>(); ob = new SerializedObject(uiSprite); spriteID = ob.FindProperty("m_Script").objectReferenceInstanceIDValue; UIInput uiInput = go.AddComponent <UIInput>(); ob = new SerializedObject(uiInput); inputID = ob.FindProperty("m_Script").objectReferenceInstanceIDValue; NGUITools.DestroyImmediate(go); } // Upgrade sliced sprites for (int i = 0; i < sliced.Count; ++i) { UIWidget w = sliced[i]; if (w != null) { ++count; ob = new SerializedObject(w); ob.Update(); ob.FindProperty("m_Script").objectReferenceInstanceIDValue = spriteID; ob.ApplyModifiedProperties(); ob.Update(); ob.FindProperty("mType").intValue = (int)UISprite.Type.Sliced; ob.ApplyModifiedProperties(); } } // Upgrade filled sprites for (int i = 0; i < filled.Count; ++i) { UIWidget w = filled[i]; if (w != null) { ++count; ob = new SerializedObject(w); ob.Update(); ob.FindProperty("m_Script").objectReferenceInstanceIDValue = spriteID; ob.ApplyModifiedProperties(); ob.Update(); ob.FindProperty("mType").intValue = (int)UISprite.Type.Filled; ob.ApplyModifiedProperties(); } } // Upgrade tiled sprites for (int i = 0; i < tiled.Count; ++i) { UIWidget w = tiled[i]; if (w != null) { ++count; ob = new SerializedObject(w); ob.Update(); ob.FindProperty("m_Script").objectReferenceInstanceIDValue = spriteID; ob.ApplyModifiedProperties(); ob.Update(); ob.FindProperty("mType").intValue = (int)UISprite.Type.Tiled; ob.ApplyModifiedProperties(); } } List <UIInputSaved> saved = NGUIEditorTools.FindAll <UIInputSaved>(); // Upgrade UI inputs for (int i = 0; i < saved.Count; ++i) { UIInputSaved inp = saved[i]; if (inp != null) { ++count; ob = new SerializedObject(inp); ob.Update(); ob.FindProperty("m_Script").objectReferenceInstanceIDValue = inputID; ob.ApplyModifiedProperties(); } } Debug.Log(count + " widgets upgraded"); }
/// <summary> /// Create a brand-new UI hierarchy. /// </summary> static public GameObject CreateNewUI() { NGUIEditorTools.RegisterUndo("Create New UI"); // Root for the UI GameObject root = null; if (camType == CameraType.Simple2D) { root = new GameObject("UI Root (2D)"); root.AddComponent <UIRoot>().scalingStyle = UIRoot.Scaling.PixelPerfect; } else { root = new GameObject((camType == CameraType.Advanced3D) ? "UI Root (3D)" : "UI Root"); root.transform.localScale = new Vector3(0.0025f, 0.0025f, 0.0025f); root.AddComponent <UIRoot>().scalingStyle = UIRoot.Scaling.FixedSize; } // Assign the layer to be used by everything root.layer = NGUISettings.layer; // Figure out the depth of the highest camera if (camType == CameraType.None) { // No camera requested -- simply add a panel UIPanel panel = NGUITools.AddChild <UIPanel>(root.gameObject); Selection.activeGameObject = panel.gameObject; } else { int mask = 1 << NGUISettings.layer; float depth = -1f; bool clearColor = true; bool audioListener = true; List <Camera> cameras = NGUIEditorTools.FindAll <Camera>(); foreach (Camera c in cameras) { // Choose the maximum depth depth = Mathf.Max(depth, c.depth); // Automatically exclude the specified layer mask from the camera if it can see more than that layer if (NGUISettings.layer != 0 && c.cullingMask != mask) { c.cullingMask = (c.cullingMask & (~mask)); } // Only consider this object if it's active if (c.enabled && NGUITools.GetActive(c.gameObject)) { clearColor = false; } // If this camera has an audio listener, we won't need to add one if (c.GetComponent <AudioListener>() != null) { audioListener = false; } } // Camera and UICamera for this UI Camera cam = NGUITools.AddChild <Camera>(root); cam.depth = depth + 1; cam.backgroundColor = Color.grey; cam.cullingMask = mask; if (camType == CameraType.Simple2D) { cam.orthographicSize = 1f; cam.orthographic = true; cam.nearClipPlane = -2f; cam.farClipPlane = 2f; } else { cam.nearClipPlane = 0.1f; cam.farClipPlane = 4f; cam.transform.localPosition = new Vector3(0f, 0f, -700f); } // We don't want to clear color if this is not the first camera if (cameras.Count > 0) { cam.clearFlags = clearColor ? CameraClearFlags.Skybox : CameraClearFlags.Depth; } // Add an audio listener if we need one if (audioListener) { cam.gameObject.AddComponent <AudioListener>(); } // Add a UI Camera for event handling cam.gameObject.AddComponent <UICamera>(); if (camType == CameraType.Simple2D) { // Anchor is useful to have UIAnchor anchor = NGUITools.AddChild <UIAnchor>(cam.gameObject); anchor.uiCamera = cam; // And finally -- the first UI panel UIPanel panel = NGUITools.AddChild <UIPanel>(anchor.gameObject); Selection.activeGameObject = panel.gameObject; } else { UIPanel panel = NGUITools.AddChild <UIPanel>(root); Selection.activeGameObject = panel.gameObject; } } return(Selection.activeGameObject); }