/// <summary> /// Draw the custom wizard. /// </summary> void OnGUI() { NGUIEditorTools.SetLabelWidth(80f); if (NGUISettings.atlas == null) { GUILayout.Label("No Atlas selected.", "LODLevelNotifyText"); } else { UIAtlas atlas = NGUISettings.atlas; bool close = false; GUILayout.Label(atlas.name + " Sprites", "LODLevelNotifyText"); NGUIEditorTools.DrawSeparator(); GUILayout.BeginHorizontal(); GUILayout.Space(84f); string before = NGUISettings.partialSprite; string after = EditorGUILayout.TextField("", before, "SearchTextField"); if (before != after) { NGUISettings.partialSprite = after; } if (GUILayout.Button("", "SearchCancelButton", GUILayout.Width(18f))) { NGUISettings.partialSprite = ""; GUIUtility.keyboardControl = 0; } GUILayout.Space(84f); GUILayout.EndHorizontal(); Texture2D tex = atlas.texture as Texture2D; if (tex == null) { GUILayout.Label("The atlas doesn't have a texture to work with"); return; } BetterList <string> sprites = atlas.GetListOfSprites(NGUISettings.partialSprite); float size = 80f; float padded = size + 10f; int columns = Mathf.FloorToInt(Screen.width / padded); if (columns < 1) { columns = 1; } int offset = 0; Rect rect = new Rect(10f, 0, size, size); GUILayout.Space(10f); mPos = GUILayout.BeginScrollView(mPos); int rows = 1; while (offset < sprites.size) { GUILayout.BeginHorizontal(); { int col = 0; rect.x = 10f; for (; offset < sprites.size; ++offset) { UISpriteData sprite = atlas.GetSprite(sprites[offset]); if (sprite == null) { continue; } // Button comes first if (GUI.Button(rect, "")) { if (Event.current.button == 0) { float delta = Time.realtimeSinceStartup - mClickTime; mClickTime = Time.realtimeSinceStartup; if (NGUISettings.selectedSprite != sprite.name) { if (mSprite != null) { NGUIEditorTools.RegisterUndo("Atlas Selection", mSprite); mSprite.MakePixelPerfect(); EditorUtility.SetDirty(mSprite.gameObject); } NGUISettings.selectedSprite = sprite.name; NGUIEditorTools.RepaintSprites(); if (mCallback != null) { mCallback(sprite.name); } } else if (delta < 0.5f) { close = true; } } else { NGUIContextMenu.AddItem("Edit", false, EditSprite, sprite); NGUIContextMenu.AddItem("Delete", false, DeleteSprite, sprite); NGUIContextMenu.Show(); } } if (Event.current.type == EventType.Repaint) { // On top of the button we have a checkboard grid NGUIEditorTools.DrawTiledTexture(rect, NGUIEditorTools.backdropTexture); Rect uv = new Rect(sprite.x, sprite.y, sprite.width, sprite.height); uv = NGUIMath.ConvertToTexCoords(uv, tex.width, tex.height); // Calculate the texture's scale that's needed to display the sprite in the clipped area float scaleX = rect.width / uv.width; float scaleY = rect.height / uv.height; // Stretch the sprite so that it will appear proper float aspect = (scaleY / scaleX) / ((float)tex.height / tex.width); Rect clipRect = rect; if (aspect != 1f) { if (aspect < 1f) { // The sprite is taller than it is wider float padding = size * (1f - aspect) * 0.5f; clipRect.xMin += padding; clipRect.xMax -= padding; } else { // The sprite is wider than it is taller float padding = size * (1f - 1f / aspect) * 0.5f; clipRect.yMin += padding; clipRect.yMax -= padding; } } GUI.DrawTextureWithTexCoords(clipRect, tex, uv); // Draw the selection if (NGUISettings.selectedSprite == sprite.name) { NGUIEditorTools.DrawOutline(rect, new Color(0.4f, 1f, 0f, 1f)); } } GUI.backgroundColor = new Color(1f, 1f, 1f, 0.5f); GUI.contentColor = new Color(1f, 1f, 1f, 0.7f); GUI.Label(new Rect(rect.x, rect.y + rect.height, rect.width, 32f), sprite.name, "ProgressBarBack"); GUI.contentColor = Color.white; GUI.backgroundColor = Color.white; if (++col >= columns) { ++offset; break; } rect.x += padded; } } GUILayout.EndHorizontal(); GUILayout.Space(padded); rect.y += padded + 26; ++rows; } GUILayout.Space(rows * 26); GUILayout.EndScrollView(); if (close) { Close(); } } }
/// <summary> /// Add commonly NGUI context menu options. /// </summary> static public void AddCommonItems(GameObject target) { if (target != null) { UIWidget widget = target.GetComponent <UIWidget>(); string myName = string.Format("Selected {0}", (widget != null) ? NGUITools.GetTypeName(widget) : "Object"); AddItem(myName + "/Bring to Front", false, delegate(object obj) { NGUITools.BringForward(Selection.activeGameObject); }, null); AddItem(myName + "/Push to Back", false, delegate(object obj) { NGUITools.PushBack(Selection.activeGameObject); }, null); AddItem(myName + "/Nudge Forward", false, delegate(object obj) { NGUITools.AdjustDepth(Selection.activeGameObject, 1); }, null); AddItem(myName + "/Nudge Back", false, delegate(object obj) { NGUITools.AdjustDepth(Selection.activeGameObject, -1); }, null); if (widget != null) { NGUIContextMenu.AddSeparator(myName + "/"); AddItem(myName + "/Make Pixel-Perfect", false, OnMakePixelPerfect, Selection.activeTransform); if (target.GetComponent <BoxCollider>() != null) { AddItem(myName + "/Reset Collider Size", false, OnBoxCollider, target); } } NGUIContextMenu.AddSeparator(myName + "/"); AddItem(myName + "/Delete", false, OnDelete, target); NGUIContextMenu.AddSeparator(""); if (Selection.activeTransform.parent != null && widget != null) { AddChildWidget("Create/Sprite/Child", false, NGUISettings.AddSprite); AddChildWidget("Create/Label/Child", false, NGUISettings.AddLabel); AddChildWidget("Create/Invisible Widget/Child", false, NGUISettings.AddWidget); AddChildWidget("Create/Simple Texture/Child", false, NGUISettings.AddTexture); #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_1 && !UNITY_4_2 AddChildWidget("Create/Unity 2D Sprite/Child", false, NGUISettings.Add2DSprite); #endif AddSiblingWidget("Create/Sprite/Sibling", false, NGUISettings.AddSprite); AddSiblingWidget("Create/Label/Sibling", false, NGUISettings.AddLabel); AddSiblingWidget("Create/Invisible Widget/Sibling", false, NGUISettings.AddWidget); AddSiblingWidget("Create/Simple Texture/Sibling", false, NGUISettings.AddTexture); #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_1 && !UNITY_4_2 AddSiblingWidget("Create/Unity 2D Sprite/Sibling", false, NGUISettings.Add2DSprite); #endif } else { AddChildWidget("Create/Sprite", false, NGUISettings.AddSprite); AddChildWidget("Create/Label", false, NGUISettings.AddLabel); AddChildWidget("Create/Invisible Widget", false, NGUISettings.AddWidget); AddChildWidget("Create/Simple Texture", false, NGUISettings.AddTexture); #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_1 && !UNITY_4_2 AddChildWidget("Create/Unity 2D Sprite", false, NGUISettings.Add2DSprite); #endif } NGUIContextMenu.AddSeparator("Create/"); AddItem("Create/Panel", false, AddPanel, target); AddItem("Create/Scroll View", false, AddScrollView, target); AddItem("Create/Grid", false, AddChild <UIGrid>, target); AddItem("Create/Table", false, AddChild <UITable>, target); AddItem("Create/Anchor (Legacy)", false, AddChild <UIAnchor>, target); if (target.GetComponent <UIPanel>() != null) { if (target.GetComponent <UIScrollView>() == null) { AddItem("Attach/Scroll View", false, delegate(object obj) { target.AddComponent <UIScrollView>(); }, null); NGUIContextMenu.AddSeparator("Attach/"); } } else if (target.collider == null) { AddItem("Attach/Box Collider", false, delegate(object obj) { NGUITools.AddWidgetCollider(target); }, null); NGUIContextMenu.AddSeparator("Attach/"); } if (target.collider != null) { if (target.GetComponent <UIDragScrollView>() == null) { for (int i = 0; i < UIPanel.list.size; ++i) { UIPanel pan = UIPanel.list[i]; if (pan.clipping == UIDrawCall.Clipping.None) { continue; } UIScrollView dr = pan.GetComponent <UIScrollView>(); if (dr == null) { continue; } AddItem("Attach/Drag Scroll View", false, delegate(object obj) { target.AddComponent <UIDragScrollView>().scrollView = dr; }, null); NGUIContextMenu.AddSeparator("Attach/"); break; } } AddItem("Attach/Button Script", false, delegate(object obj) { target.AddComponent <UIButton>(); }, null); AddItem("Attach/Toggle Script", false, delegate(object obj) { target.AddComponent <UIToggle>(); }, null); AddItem("Attach/Slider Script", false, delegate(object obj) { target.AddComponent <UISlider>(); }, null); AddItem("Attach/Scroll Bar Script", false, delegate(object obj) { target.AddComponent <UIScrollBar>(); }, null); AddItem("Attach/Progress Bar Script", false, delegate(object obj) { target.AddComponent <UISlider>(); }, null); AddItem("Attach/Popup List Script", false, delegate(object obj) { target.AddComponent <UIPopupList>(); }, null); AddItem("Attach/Input Field Script", false, delegate(object obj) { target.AddComponent <UIInput>(); }, null); NGUIContextMenu.AddSeparator("Attach/"); if (target.GetComponent <UIAnchor>() == null) { AddItem("Attach/Anchor Script", false, delegate(object obj) { target.AddComponent <UIAnchor>(); }, null); } if (target.GetComponent <UIStretch>() == null) { AddItem("Attach/Stretch Script", false, delegate(object obj) { target.AddComponent <UIStretch>(); }, null); } AddItem("Attach/Key Binding Script", false, delegate(object obj) { target.AddComponent <UIKeyBinding>(); }, null); NGUIContextMenu.AddSeparator("Attach/"); AddItem("Attach/Play Tween Script", false, delegate(object obj) { target.AddComponent <UIPlayTween>(); }, null); AddItem("Attach/Play Animation Script", false, delegate(object obj) { target.AddComponent <UIPlayAnimation>(); }, null); AddItem("Attach/Play Sound Script", false, delegate(object obj) { target.AddComponent <UIPlaySound>(); }, null); } if (widget != null) { AddMissingItem <TweenAlpha>(target, "Tween/Alpha"); AddMissingItem <TweenColor>(target, "Tween/Color"); AddMissingItem <TweenWidth>(target, "Tween/Width"); AddMissingItem <TweenHeight>(target, "Tween/Height"); } else if (target.GetComponent <UIPanel>() != null) { AddMissingItem <TweenAlpha>(target, "Tween/Alpha"); } NGUIContextMenu.AddSeparator("Tween/"); AddMissingItem <TweenPosition>(target, "Tween/Position"); AddMissingItem <TweenRotation>(target, "Tween/Rotation"); AddMissingItem <TweenScale>(target, "Tween/Scale"); AddMissingItem <TweenTransform>(target, "Tween/Transform"); if (target.GetComponent <AudioSource>() != null) { AddMissingItem <TweenVolume>(target, "Tween/Volume"); } if (target.GetComponent <Camera>() != null) { AddMissingItem <TweenFOV>(target, "Tween/Field of View"); AddMissingItem <TweenOrthoSize>(target, "Tween/Orthographic Size"); } } }
/// <summary> /// Draw the custom wizard. /// </summary> void OnGUI() { Event currentEvent = Event.current; EventType type = currentEvent.type; int x = cellPadding, y = cellPadding; int width = Screen.width - cellPadding; int spacingX = cellSize + cellPadding; int spacingY = spacingX; if (mMode == Mode.DetailedMode) { spacingY += 32; } GameObject dragged = draggedObject; bool isDragging = (dragged != null); int indexUnderMouse = GetCellUnderMouse(spacingX, spacingY); Item selection = isDragging ? FindItem(dragged) : null; string searchFilter = NGUISettings.searchField; int newTab = mTab; GUILayout.BeginHorizontal(); if (GUILayout.Toggle(newTab == 0, "1", "ButtonLeft")) { newTab = 0; } if (GUILayout.Toggle(newTab == 1, "2", "ButtonMid")) { newTab = 1; } if (GUILayout.Toggle(newTab == 2, "3", "ButtonMid")) { newTab = 2; } if (GUILayout.Toggle(newTab == 3, "4", "ButtonMid")) { newTab = 3; } if (GUILayout.Toggle(newTab == 4, "5", "ButtonRight")) { newTab = 4; } GUILayout.EndHorizontal(); if (mTab != newTab) { Save(); mTab = newTab; mReset = true; NGUISettings.SetInt("NGUI Prefab Tab", mTab); Load(); } if (mReset && type == EventType.Repaint) { mReset = false; foreach (Item item in mItems) { GeneratePreview(item, null); } RectivateLights(); } // Search field GUILayout.BeginHorizontal(); { string after = EditorGUILayout.TextField("", searchFilter, "SearchTextField", GUILayout.Width(Screen.width - 20f)); if (GUILayout.Button("", "SearchCancelButton", GUILayout.Width(18f))) { after = ""; GUIUtility.keyboardControl = 0; } if (searchFilter != after) { NGUISettings.searchField = after; searchFilter = after; } } GUILayout.EndHorizontal(); bool eligibleToDrag = (currentEvent.mousePosition.y < Screen.height - 40); if (type == EventType.MouseDown) { mMouseIsInside = true; } else if (type == EventType.MouseDrag) { mMouseIsInside = true; if (indexUnderMouse != -1 && eligibleToDrag) { // Drag operation begins if (draggedObjectIsOurs) { DragAndDrop.StartDrag("Prefab Tool"); } currentEvent.Use(); } } else if (type == EventType.MouseUp) { DragAndDrop.PrepareStartDrag(); mMouseIsInside = false; Repaint(); } else if (type == EventType.DragUpdated) { // Something dragged into the window mMouseIsInside = true; UpdateVisual(); currentEvent.Use(); } else if (type == EventType.DragPerform) { // We've dropped a new object into the window if (dragged != null) { if (selection != null) { DestroyTexture(selection); mItems.Remove(selection); } AddItem(dragged, indexUnderMouse); draggedObject = null; } mMouseIsInside = false; currentEvent.Use(); } else if (type == EventType.DragExited || type == EventType.Ignore) { mMouseIsInside = false; } // If the mouse is not inside the window, clear the selection and dragged object if (!mMouseIsInside) { selection = null; dragged = null; } // Create a list of indices, inserting an entry of '-1' underneath the dragged object BetterList <int> indices = new BetterList <int>(); for (int i = 0; i < mItems.size;) { if (dragged != null && indices.size == indexUnderMouse) { indices.Add(-1); } if (mItems[i] != selection) { if (string.IsNullOrEmpty(searchFilter) || mItems[i].prefab.name.IndexOf(searchFilter, System.StringComparison.CurrentCultureIgnoreCase) != -1) { indices.Add(i); } } ++i; } // There must always be '-1' (Add/Move slot) present if (!indices.Contains(-1)) { indices.Add(-1); } // We want to start dragging something from within the window if (eligibleToDrag && type == EventType.MouseDown && indexUnderMouse > -1) { GUIUtility.keyboardControl = 0; if (currentEvent.button == 0 && indexUnderMouse < indices.size) { int index = indices[indexUnderMouse]; if (index != -1 && index < mItems.size) { selection = mItems[index]; draggedObject = selection.prefab; dragged = selection.prefab; currentEvent.Use(); } } } //else if (type == EventType.MouseUp && currentEvent.button == 1 && indexUnderMouse > mItems.size) //{ // NGUIContextMenu.AddItem("Reset", false, RemoveItem, index); // NGUIContextMenu.Show(); //} // Draw the scroll view with prefabs mPos = GUILayout.BeginScrollView(mPos); { Color normal = new Color(1f, 1f, 1f, 0.5f); for (int i = 0; i < indices.size; ++i) { int index = indices[i]; Item ent = (index != -1) ? mItems[index] : selection; if (ent != null && ent.prefab == null) { mItems.RemoveAt(index); continue; } Rect rect = new Rect(x, y, cellSize, cellSize); Rect inner = rect; inner.xMin += 2f; inner.xMax -= 2f; inner.yMin += 2f; inner.yMax -= 2f; rect.yMax -= 1f; // Button seems to be mis-shaped. It's height is larger than its width by a single pixel. if (!isDragging && (mMode == Mode.CompactMode || (ent == null || ent.tex != null))) { mContent.tooltip = (ent != null) ? ent.prefab.name : "Click to add"; } else { mContent.tooltip = ""; } //if (ent == selection) { GUI.color = normal; NGUIEditorTools.DrawTiledTexture(inner, NGUIEditorTools.backdropTexture); } GUI.color = Color.white; GUI.backgroundColor = normal; if (GUI.Button(rect, mContent, "Button")) { if (ent == null || currentEvent.button == 0) { string path = EditorUtility.OpenFilePanel("Add a prefab", NGUISettings.currentPath, "prefab"); if (!string.IsNullOrEmpty(path)) { NGUISettings.currentPath = System.IO.Path.GetDirectoryName(path); Item newEnt = CreateItemByPath(path); if (newEnt != null) { mItems.Add(newEnt); Save(); } } } else if (currentEvent.button == 1) { NGUIContextMenu.AddItem("Delete", false, RemoveItem, index); NGUIContextMenu.Show(); } } string caption = (ent == null) ? "" : ent.prefab.name.Replace("Control - ", ""); if (ent != null) { if (ent.tex != null) { GUI.DrawTexture(inner, ent.tex); } else if (mMode != Mode.DetailedMode) { GUI.Label(inner, caption, mStyle); caption = ""; } } else { GUI.Label(inner, "Add", mStyle); } if (mMode == Mode.DetailedMode) { GUI.backgroundColor = new Color(1f, 1f, 1f, 0.5f); GUI.contentColor = new Color(1f, 1f, 1f, 0.7f); GUI.Label(new Rect(rect.x, rect.y + rect.height, rect.width, 32f), caption, "ProgressBarBack"); GUI.contentColor = Color.white; GUI.backgroundColor = Color.white; } x += spacingX; if (x + spacingX > width) { y += spacingY; x = cellPadding; } } GUILayout.Space(y); } GUILayout.EndScrollView(); // Mode Mode modeAfter = (Mode)EditorGUILayout.EnumPopup(mMode); if (modeAfter != mMode) { mMode = modeAfter; mReset = true; NGUISettings.SetEnum("NGUI Prefab Mode", mMode); } }
/// <summary> /// Add commonly NGUI context menu options. /// </summary> static public void AddCommonItems(GameObject target) { if (target != null) { UIWidget widget = target.GetComponent <UIWidget>(); string myName = string.Format("Selected {0}", (widget != null) ? NGUITools.GetTypeName(widget) : "Object"); AddItem(myName + "/Bring to Front", false, delegate(object obj) { for (int i = 0; i < Selection.gameObjects.Length; ++i) { NGUITools.BringForward(Selection.gameObjects[i]); } }, null); AddItem(myName + "/Push to Back", false, delegate(object obj) { for (int i = 0; i < Selection.gameObjects.Length; ++i) { NGUITools.PushBack(Selection.gameObjects[i]); } }, null); AddItem(myName + "/Nudge Forward", false, delegate(object obj) { for (int i = 0; i < Selection.gameObjects.Length; ++i) { NGUITools.AdjustDepth(Selection.gameObjects[i], 1); } }, null); AddItem(myName + "/Nudge Back", false, delegate(object obj) { for (int i = 0; i < Selection.gameObjects.Length; ++i) { NGUITools.AdjustDepth(Selection.gameObjects[i], -1); } }, null); if (widget != null) { NGUIContextMenu.AddSeparator(myName + "/"); AddItem(myName + "/Make Pixel-Perfect", false, OnMakePixelPerfect, Selection.activeTransform); if (target.GetComponent <BoxCollider>() != null) { AddItem(myName + "/Reset Collider Size", false, OnBoxCollider, target); } } NGUIContextMenu.AddSeparator(myName + "/"); AddItem(myName + "/Delete", false, OnDelete, target); NGUIContextMenu.AddSeparator(""); if (Selection.activeTransform.parent != null && widget != null) { AddChildWidget("Create/Sprite/Child", false, NGUISettings.AddSprite); AddChildWidget("Create/Label/Child", false, NGUISettings.AddLabel); AddChildWidget("Create/Invisible Widget/Child", false, NGUISettings.AddWidget); AddChildWidget("Create/Simple Texture/Child", false, NGUISettings.AddTexture); AddChildWidget("Create/Unity 2D Sprite/Child", false, NGUISettings.Add2DSprite); AddSiblingWidget("Create/Sprite/Sibling", false, NGUISettings.AddSprite); AddSiblingWidget("Create/Label/Sibling", false, NGUISettings.AddLabel); AddSiblingWidget("Create/Invisible Widget/Sibling", false, NGUISettings.AddWidget); AddSiblingWidget("Create/Simple Texture/Sibling", false, NGUISettings.AddTexture); AddSiblingWidget("Create/Unity 2D Sprite/Sibling", false, NGUISettings.Add2DSprite); } else { AddChildWidget("Create/Sprite", false, NGUISettings.AddSprite); AddChildWidget("Create/Label", false, NGUISettings.AddLabel); AddChildWidget("Create/Invisible Widget", false, NGUISettings.AddWidget); AddChildWidget("Create/Simple Texture", false, NGUISettings.AddTexture); AddChildWidget("Create/Unity 2D Sprite", false, NGUISettings.Add2DSprite); } NGUIContextMenu.AddSeparator("Create/"); AddItem("Create/Panel", false, AddPanel, target); AddItem("Create/Scroll View", false, AddScrollView, target); AddItem("Create/Grid", false, AddChild <UIGrid>, target); AddItem("Create/Table", false, AddChild <UITable>, target); AddItem("Create/Anchor (Legacy)", false, AddChild <UIAnchor>, target); if (target.GetComponent <UIPanel>() != null) { if (target.GetComponent <UIScrollView>() == null) { AddItem("Attach/Scroll View", false, Attach, typeof(UIScrollView)); NGUIContextMenu.AddSeparator("Attach/"); } } else if (target.GetComponent <Collider>() == null && target.GetComponent <Collider2D>() == null) { AddItem("Attach/Box Collider", false, AttachCollider, null); NGUIContextMenu.AddSeparator("Attach/"); } bool header = false; UIScrollView scrollView = NGUITools.FindInParents <UIScrollView>(target); if (scrollView != null) { if (scrollView.GetComponentInChildren <UICenterOnChild>() == null) { AddItem("Attach/Center Scroll View on Child", false, Attach, typeof(UICenterOnChild)); header = true; } } if (target.GetComponent <Collider>() != null || target.GetComponent <Collider2D>() != null) { if (scrollView != null) { if (target.GetComponent <UIDragScrollView>() == null) { AddItem("Attach/Drag Scroll View", false, Attach, typeof(UIDragScrollView)); header = true; } if (target.GetComponent <UICenterOnClick>() == null && NGUITools.FindInParents <UICenterOnChild>(target) != null) { AddItem("Attach/Center Scroll View on Click", false, Attach, typeof(UICenterOnClick)); header = true; } } if (header) { NGUIContextMenu.AddSeparator("Attach/"); } AddItem("Attach/Button Script", false, Attach, typeof(UIButton)); AddItem("Attach/Toggle Script", false, Attach, typeof(UIToggle)); AddItem("Attach/Slider Script", false, Attach, typeof(UISlider)); AddItem("Attach/Scroll Bar Script", false, Attach, typeof(UIScrollBar)); AddItem("Attach/Progress Bar Script", false, Attach, typeof(UIProgressBar)); AddItem("Attach/Popup List Script", false, Attach, typeof(UIPopupList)); AddItem("Attach/Input Field Script", false, Attach, typeof(UIInput)); NGUIContextMenu.AddSeparator("Attach/"); if (target.GetComponent <UIDragResize>() == null) { AddItem("Attach/Drag Resize Script", false, Attach, typeof(UIDragResize)); } if (target.GetComponent <UIDragScrollView>() == null) { for (int i = 0; i < UIPanel.list.Count; ++i) { UIPanel pan = UIPanel.list[i]; if (pan.clipping == UIDrawCall.Clipping.None) { continue; } UIScrollView dr = pan.GetComponent <UIScrollView>(); if (dr == null) { continue; } AddItem("Attach/Drag Scroll View", false, delegate(object obj) { target.AddComponent <UIDragScrollView>().scrollView = dr; }, null); header = true; break; } } AddItem("Attach/Key Binding Script", false, Attach, typeof(UIKeyBinding)); if (target.GetComponent <UIKeyNavigation>() == null) { AddItem("Attach/Key Navigation Script", false, Attach, typeof(UIKeyNavigation)); } NGUIContextMenu.AddSeparator("Attach/"); AddItem("Attach/Play Tween Script", false, Attach, typeof(UIPlayTween)); AddItem("Attach/Play Animation Script", false, Attach, typeof(UIPlayAnimation)); AddItem("Attach/Play Sound Script", false, Attach, typeof(UIPlaySound)); } AddItem("Attach/Property Binding", false, Attach, typeof(PropertyBinding)); if (target.GetComponent <UILocalize>() == null) { AddItem("Attach/Localization Script", false, Attach, typeof(UILocalize)); } if (widget != null) { AddMissingItem <TweenAlpha>(target, "Tween/Alpha"); AddMissingItem <TweenColor>(target, "Tween/Color"); AddMissingItem <TweenWidth>(target, "Tween/Width"); AddMissingItem <TweenHeight>(target, "Tween/Height"); } else if (target.GetComponent <UIPanel>() != null) { AddMissingItem <TweenAlpha>(target, "Tween/Alpha"); } NGUIContextMenu.AddSeparator("Tween/"); AddMissingItem <TweenPosition>(target, "Tween/Position"); AddMissingItem <TweenRotation>(target, "Tween/Rotation"); AddMissingItem <TweenScale>(target, "Tween/Scale"); AddMissingItem <TweenTransform>(target, "Tween/Transform"); if (target.GetComponent <AudioSource>() != null) { AddMissingItem <TweenVolume>(target, "Tween/Volume"); } if (target.GetComponent <Camera>() != null) { AddMissingItem <TweenFOV>(target, "Tween/Field of View"); AddMissingItem <TweenOrthoSize>(target, "Tween/Orthographic Size"); } } }