Various patches and also enabled the ReorderableList in SS-Camera / Worldspace

release
Simon Jackson 2017-06-03 17:59:12 +01:00
parent e4991aba05
commit a059c148a6
9 changed files with 1141 additions and 900 deletions

View File

@ -549,9 +549,10 @@ namespace UnityEditor.UI
Selection.activeGameObject = uiVerticalScrollerRoot;
}
#endregion
#endregion
[MenuItem("GameObject/UI/Extensions/UI Button", false)]
#region UI Button
[MenuItem("GameObject/UI/Extensions/UI Button", false)]
static public void AddUIButton(MenuCommand menuCommand)
{
GameObject uiButtonRoot = CreateUIElementRoot("UI Button", menuCommand, s_ThickGUIElementSize);
@ -578,8 +579,10 @@ namespace UnityEditor.UI
Selection.activeGameObject = uiButtonRoot;
}
#endregion
[MenuItem("GameObject/UI/Extensions/UI Flippable", false)]
#region UI Flippable
[MenuItem("GameObject/UI/Extensions/UI Flippable", false)]
static public void AddUIFlippableImage(MenuCommand menuCommand)
{
GameObject go = CreateUIElementRoot("UI Flippable", menuCommand, s_ImageGUIElementSize);
@ -587,8 +590,10 @@ namespace UnityEditor.UI
go.AddComponent<UIFlippable>();
Selection.activeGameObject = go;
}
#endregion
[MenuItem("GameObject/UI/Extensions/UI Window Base", false)]
#region UI WindowBase
[MenuItem("GameObject/UI/Extensions/UI Window Base", false)]
static public void AddUIWindowBase(MenuCommand menuCommand)
{
GameObject go = CreateUIElementRoot("UI Window Base", menuCommand, s_ThickGUIElementSize);
@ -596,9 +601,10 @@ namespace UnityEditor.UI
go.AddComponent<Image>();
Selection.activeGameObject = go;
}
#endregion
#region Accordian
[MenuItem("GameObject/UI/Extensions/Accordion/Accordion Group", false)]
#region Accordian
[MenuItem("GameObject/UI/Extensions/Accordion/Accordion Group", false)]
static public void AddAccordionGroup(MenuCommand menuCommand)
{
GameObject go = CreateUIElementRoot("Accordion Group", menuCommand, s_ThickGUIElementSize);
@ -1134,6 +1140,7 @@ namespace UnityEditor.UI
go.AddComponent<UIGridRenderer>();
Selection.activeGameObject = go;
}
#endregion
#region Re-Orderable Lists
@ -1401,7 +1408,7 @@ namespace UnityEditor.UI
[MenuItem("GameObject/UI/Extensions/Re-orderable Lists/Re-orderable Vertical List", false)]
static public void AddReorderableVerticalList(MenuCommand menuCommand)
{
GameObject reorderableScrollRoot = CreateUIElementRoot("Re-orderable Vertial List", menuCommand, s_ThickGUIElementSize);
GameObject reorderableScrollRoot = CreateUIElementRoot("Re-orderable Vertical List", menuCommand, s_ThickGUIElementSize);
GameObject childContent = CreateUIObject("List_Content", reorderableScrollRoot);
@ -1643,9 +1650,10 @@ namespace UnityEditor.UI
}
#endregion
#endregion
[MenuItem("GameObject/UI/Extensions/UI Knob", false)]
#region UI Knob
[MenuItem("GameObject/UI/Extensions/UI Knob", false)]
static public void AddUIKnob(MenuCommand menuCommand)
{
GameObject go = CreateUIElementRoot("UI Knob", menuCommand, s_ImageGUIElementSize);
@ -1653,14 +1661,17 @@ namespace UnityEditor.UI
go.AddComponent<UI_Knob>();
Selection.activeGameObject = go;
}
[MenuItem("GameObject/UI/Extensions/TextPic", false)]
#endregion
#region TextPic
[MenuItem("GameObject/UI/Extensions/TextPic", false)]
static public void AddTextPic(MenuCommand menuCommand)
{
GameObject go = CreateUIElementRoot("TextPic", menuCommand, s_ImageGUIElementSize);
go.AddComponent<TextPic>();
Selection.activeGameObject = go;
}
#endregion
#region BoxSlider
[MenuItem("GameObject/UI/Extensions/Box Slider", false)]
@ -1699,7 +1710,7 @@ namespace UnityEditor.UI
#endregion
#region Non Drawing Graphic options
[MenuItem("GameObject/UI/Extensions/NonDrawingGraphicClickable", false)]
[MenuItem("GameObject/UI/Extensions/NonDrawingGraphic", false)]
static public void AddNonDrawingGraphic(MenuCommand menuCommand)
{
GameObject go = CreateUIElementRoot("NonDrawing Graphic", menuCommand, s_ImageGUIElementSize);
@ -1707,7 +1718,7 @@ namespace UnityEditor.UI
Selection.activeGameObject = go;
}
[MenuItem("GameObject/UI/Extensions/NonDrawingGraphic", false)]
[MenuItem("GameObject/UI/Extensions/NonDrawingGraphicClickable", false)]
static public void AddClickableNonDrawingGraphic(MenuCommand menuCommand)
{
GameObject go = CreateUIElementRoot("NonDrawing Graphic-Clickable", menuCommand, s_ImageGUIElementSize);

File diff suppressed because it is too large Load Diff

View File

@ -133,20 +133,20 @@ namespace UnityEngine.UI.Extensions
try
{
_rectTransform = GetComponent<RectTransform>();
_inputRT = _rectTransform.FindChild("InputField").GetComponent<RectTransform>();
_inputRT = _rectTransform.Find("InputField").GetComponent<RectTransform>();
_mainInput = _inputRT.GetComponent<InputField>();
//_arrow_Button = _rectTransform.FindChild ("ArrowBtn").GetComponent<Button> ();
_overlayRT = _rectTransform.FindChild("Overlay").GetComponent<RectTransform>();
_overlayRT = _rectTransform.Find("Overlay").GetComponent<RectTransform>();
_overlayRT.gameObject.SetActive(false);
_scrollPanelRT = _overlayRT.FindChild("ScrollPanel").GetComponent<RectTransform>();
_scrollBarRT = _scrollPanelRT.FindChild("Scrollbar").GetComponent<RectTransform>();
_slidingAreaRT = _scrollBarRT.FindChild("SlidingArea").GetComponent<RectTransform>();
_scrollPanelRT = _overlayRT.Find("ScrollPanel").GetComponent<RectTransform>();
_scrollBarRT = _scrollPanelRT.Find("Scrollbar").GetComponent<RectTransform>();
_slidingAreaRT = _scrollBarRT.Find("SlidingArea").GetComponent<RectTransform>();
// scrollHandleRT = slidingAreaRT.FindChild("Handle").GetComponent<RectTransform>();
_itemsPanelRT = _scrollPanelRT.FindChild("Items").GetComponent<RectTransform>();
_itemsPanelRT = _scrollPanelRT.Find("Items").GetComponent<RectTransform>();
//itemPanelLayout = itemsPanelRT.gameObject.GetComponent<LayoutGroup>();
_canvas = GetComponentInParent<Canvas>();
@ -157,7 +157,7 @@ namespace UnityEngine.UI.Extensions
_scrollRect.movementType = ScrollRect.MovementType.Clamped;
_scrollRect.content = _itemsPanelRT;
itemTemplate = _rectTransform.FindChild("ItemTemplate").gameObject;
itemTemplate = _rectTransform.Find("ItemTemplate").gameObject;
itemTemplate.SetActive(false);
}
catch (System.NullReferenceException ex)
@ -238,7 +238,7 @@ namespace UnityEngine.UI.Extensions
if (i < AvailableOptions.Count)
{
itemObjs[i].name = "Item " + i + " " + _panelItems[i];
itemObjs[i].transform.FindChild("Text").GetComponent<Text>().text = _panelItems[i]; //set the text value
itemObjs[i].transform.Find("Text").GetComponent<Text>().text = _panelItems[i]; //set the text value
Button itemBtn = itemObjs[i].GetComponent<Button>();
itemBtn.onClick.RemoveAllListeners();

View File

@ -91,18 +91,18 @@ namespace UnityEngine.UI.Extensions
try
{
_rectTransform = GetComponent<RectTransform>();
_inputRT = _rectTransform.FindChild("InputField").GetComponent<RectTransform>();
_inputRT = _rectTransform.Find("InputField").GetComponent<RectTransform>();
_mainInput = _inputRT.GetComponent<InputField>();
_overlayRT = _rectTransform.FindChild("Overlay").GetComponent<RectTransform>();
_overlayRT = _rectTransform.Find("Overlay").GetComponent<RectTransform>();
_overlayRT.gameObject.SetActive(false);
_scrollPanelRT = _overlayRT.FindChild("ScrollPanel").GetComponent<RectTransform>();
_scrollBarRT = _scrollPanelRT.FindChild("Scrollbar").GetComponent<RectTransform>();
_slidingAreaRT = _scrollBarRT.FindChild("SlidingArea").GetComponent<RectTransform>();
_scrollPanelRT = _overlayRT.Find("ScrollPanel").GetComponent<RectTransform>();
_scrollBarRT = _scrollPanelRT.Find("Scrollbar").GetComponent<RectTransform>();
_slidingAreaRT = _scrollBarRT.Find("SlidingArea").GetComponent<RectTransform>();
// scrollHandleRT = slidingAreaRT.FindChild("Handle").GetComponent<RectTransform>();
_itemsPanelRT = _scrollPanelRT.FindChild("Items").GetComponent<RectTransform>();
_itemsPanelRT = _scrollPanelRT.Find("Items").GetComponent<RectTransform>();
//itemPanelLayout = itemsPanelRT.gameObject.GetComponent<LayoutGroup>();
_canvas = GetComponentInParent<Canvas>();
@ -113,7 +113,7 @@ namespace UnityEngine.UI.Extensions
_scrollRect.movementType = ScrollRect.MovementType.Clamped;
_scrollRect.content = _itemsPanelRT;
itemTemplate = _rectTransform.FindChild("ItemTemplate").gameObject;
itemTemplate = _rectTransform.Find("ItemTemplate").gameObject;
itemTemplate.SetActive(false);
}
catch (System.NullReferenceException ex)
@ -192,7 +192,7 @@ namespace UnityEngine.UI.Extensions
if (i < AvailableOptions.Count)
{
itemObjs[i].name = "Item " + i + " " + _panelItems[i];
itemObjs[i].transform.FindChild("Text").GetComponent<Text>().text = _panelItems[i]; //set the text value
itemObjs[i].transform.Find("Text").GetComponent<Text>().text = _panelItems[i]; //set the text value
Button itemBtn = itemObjs[i].GetComponent<Button>();
itemBtn.onClick.RemoveAllListeners();

View File

@ -94,17 +94,17 @@ namespace UnityEngine.UI.Extensions
try
{
_rectTransform = GetComponent<RectTransform>();
_mainButton = new DropDownListButton(_rectTransform.FindChild("MainButton").gameObject);
_mainButton = new DropDownListButton(_rectTransform.Find("MainButton").gameObject);
_overlayRT = _rectTransform.FindChild("Overlay").GetComponent<RectTransform>();
_overlayRT = _rectTransform.Find("Overlay").GetComponent<RectTransform>();
_overlayRT.gameObject.SetActive(false);
_scrollPanelRT = _overlayRT.FindChild("ScrollPanel").GetComponent<RectTransform>();
_scrollBarRT = _scrollPanelRT.FindChild("Scrollbar").GetComponent<RectTransform>();
_slidingAreaRT = _scrollBarRT.FindChild("SlidingArea").GetComponent<RectTransform>();
_scrollPanelRT = _overlayRT.Find("ScrollPanel").GetComponent<RectTransform>();
_scrollBarRT = _scrollPanelRT.Find("Scrollbar").GetComponent<RectTransform>();
_slidingAreaRT = _scrollBarRT.Find("SlidingArea").GetComponent<RectTransform>();
// scrollHandleRT = slidingAreaRT.FindChild("Handle").GetComponent<RectTransform>();
_itemsPanelRT = _scrollPanelRT.FindChild("Items").GetComponent<RectTransform>();
_itemsPanelRT = _scrollPanelRT.Find("Items").GetComponent<RectTransform>();
//itemPanelLayout = itemsPanelRT.gameObject.GetComponent<LayoutGroup>();
_canvas = GetComponentInParent<Canvas>();
@ -116,7 +116,7 @@ namespace UnityEngine.UI.Extensions
_scrollRect.content = _itemsPanelRT;
_itemTemplate = _rectTransform.FindChild("ItemTemplate").gameObject;
_itemTemplate = _rectTransform.Find("ItemTemplate").gameObject;
_itemTemplate.SetActive(false);
}
catch (System.NullReferenceException ex)

View File

@ -19,8 +19,8 @@ namespace UnityEngine.UI.Extensions
rectTransform = btnObj.GetComponent<RectTransform>();
btnImg = btnObj.GetComponent<Image>();
btn = btnObj.GetComponent<Button>();
txt = rectTransform.FindChild("Text").GetComponent<Text>();
img = rectTransform.FindChild("Image").GetComponent<Image>();
txt = rectTransform.Find("Text").GetComponent<Text>();
img = rectTransform.Find("Image").GetComponent<Image>();
}
}
}

View File

@ -84,10 +84,6 @@ namespace UnityEngine.UI.Extensions
Debug.LogError("You need to have a Graphic control (such as an Image) for the list [" + name + "] to be droppable", gameObject);
return;
}
if (GetCanvas().renderMode > RenderMode.ScreenSpaceCamera)
{
Debug.LogError("The ReOrderable List is only supported on a Screen-Space Canvas at the moment");
}
_listContent = ContentLayout.gameObject.AddComponent<ReorderableListContent>();
_listContent.Init(this);

View File

@ -78,10 +78,10 @@ namespace UnityEngine.UI.Extensions
_draggingObject = clone.GetComponent<RectTransform>();
}
//Put _dragging object into the draggin area
//Put _dragging object into the dragging area
_draggingObjectOriginalSize = gameObject.GetComponent<RectTransform>().rect.size;
_draggingObjectLE = _draggingObject.GetComponent<LayoutElement>();
_draggingObject.SetParent(_reorderableList.DraggableArea, false);
_draggingObject.SetParent(_reorderableList.DraggableArea, true);
_draggingObject.SetAsLastSibling();
//Create a fake element for previewing placement
@ -222,6 +222,7 @@ namespace UnityEngine.UI.Extensions
}
RefreshSizes();
_draggingObject.SetParent(_currentReorderableListRaycasted.Content, false);
_draggingObject.rotation = _currentReorderableListRaycasted.transform.rotation;
_draggingObject.SetSiblingIndex(_fakeElement.GetSiblingIndex());
_reorderableList.OnElementAdded.Invoke(args);
@ -271,6 +272,7 @@ namespace UnityEngine.UI.Extensions
{
RefreshSizes();
_draggingObject.SetParent(_reorderableList.Content, false);
_draggingObject.rotation = _reorderableList.Content.transform.rotation;
_draggingObject.SetSiblingIndex(_fromIndex);

View File

@ -8,44 +8,44 @@ namespace UnityEngine.UI.Extensions
public class UIGridRenderer : UILineRenderer
{
[SerializeField]
private int m_gridWidth = 10;
private int m_GridColumns = 10;
[SerializeField]
private int m_gridHeight = 10;
private int m_GridRows = 10;
/// <summary>
/// Width of the grid in Cells.
/// Number of columns in the Grid
/// </summary>
public int GridWidth
public int GridColumns
{
get
{
return m_gridWidth;
return m_GridColumns;
}
set
{
if (m_gridWidth == value)
if (m_GridColumns == value)
return;
m_gridWidth = value;
m_GridColumns = value;
SetAllDirty();
}
}
/// <summary>
/// Height of the Grid in cells.
/// Number of rows in the grid.
/// </summary>
public int GridHeight
public int GridRows
{
get
{
return m_gridHeight;
return m_GridRows;
}
set
{
if (m_gridHeight == value)
if (m_GridRows == value)
return;
m_gridHeight = value;
m_GridRows = value;
SetAllDirty();
}
}
@ -54,16 +54,16 @@ namespace UnityEngine.UI.Extensions
{
relativeSize = true;
int ArraySize = (GridHeight * 3) + 1;
if(GridHeight % 2 == 0)
int ArraySize = (GridRows * 3) + 1;
if(GridRows % 2 == 0)
++ArraySize; // needs one more line
ArraySize += (GridWidth * 3) + 1;
ArraySize += (GridColumns * 3) + 1;
m_points = new Vector2[ArraySize];
int Index = 0;
for(int i = 0; i < GridHeight; ++i)
for(int i = 0; i < GridRows; ++i)
{
float xFrom = 1;
float xTo = 0;
@ -74,7 +74,7 @@ namespace UnityEngine.UI.Extensions
xTo = 1;
}
float y = ((float)i) / GridHeight;
float y = ((float)i) / GridRows;
m_points[Index].x = xFrom;
m_points[Index].y = y;
++Index;
@ -82,11 +82,11 @@ namespace UnityEngine.UI.Extensions
m_points[Index].y = y;
++Index;
m_points[Index].x = xTo;
m_points[Index].y = (float)(i + 1) / GridHeight;
m_points[Index].y = (float)(i + 1) / GridRows;
++Index;
}
if(GridHeight % 2 == 0)
if(GridRows % 2 == 0)
{
// two lines to get to 0, 1
m_points[Index].x = 1;
@ -99,7 +99,7 @@ namespace UnityEngine.UI.Extensions
++Index;
// line is now at 0,1, so we can draw the columns
for(int i = 0; i < GridWidth; ++i)
for(int i = 0; i < GridColumns; ++i)
{
float yFrom = 1;
float yTo = 0;
@ -110,19 +110,19 @@ namespace UnityEngine.UI.Extensions
yTo = 1;
}
float x = ((float)i) / GridWidth;
float x = ((float)i) / GridColumns;
m_points[Index].x = x;
m_points[Index].y = yFrom;
++Index;
m_points[Index].x = x;
m_points[Index].y = yTo;
++Index;
m_points[Index].x = (float)(i + 1) / GridWidth;
m_points[Index].x = (float)(i + 1) / GridColumns;
m_points[Index].y = yTo;
++Index;
}
if(GridWidth % 2 == 0)
if(GridColumns % 2 == 0)
{
// one more line to get to 1, 1
m_points[Index].x = 1;