Fixed PageChanged event for HSS/VSS
Fixed WorldSpace use of HSS/VSS (also created a new feature :D) Minor editor options fix for boxslider --HG-- branch : develop_5.3release
parent
f0ba3cfae5
commit
aadba190c8
|
@ -1654,10 +1654,46 @@ namespace UnityEditor.UI
|
|||
Selection.activeGameObject = go;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region BoxSlider
|
||||
[MenuItem("GameObject/UI/Extensions/Box Slider", false)]
|
||||
static public void AddBoxSlider(MenuCommand menuCommand)
|
||||
{
|
||||
|
||||
#region Helper Functions
|
||||
private static GameObject AddInputFieldAsChild(GameObject parent)
|
||||
GameObject uiboxSliderRoot = CreateUIElementRoot("Box Slider", menuCommand, s_ImageGUIElementSize);
|
||||
|
||||
GameObject handleSlideArea = CreateUIObject("Handle Slide Area", uiboxSliderRoot);
|
||||
|
||||
GameObject handle = CreateUIObject("Handle", handleSlideArea);
|
||||
|
||||
// Set RectTransform to stretch
|
||||
SetAnchorsAndStretch(uiboxSliderRoot);
|
||||
Image backgroundImage = uiboxSliderRoot.AddComponent<Image>();
|
||||
backgroundImage.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>(kBackgroundSpriteResourcePath);
|
||||
backgroundImage.type = Image.Type.Sliced;
|
||||
backgroundImage.fillCenter = false;
|
||||
backgroundImage.color = new Color(1f, 1f, 1f, 0.392f);
|
||||
|
||||
RectTransform handleRect = SetAnchorsAndStretch(handle);
|
||||
handleRect.sizeDelta = new Vector2(25, 25);
|
||||
Image handleImage = handle.AddComponent<Image>();
|
||||
handleImage.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>(kKnobPath);
|
||||
handleImage.type = Image.Type.Simple;
|
||||
handleImage.fillCenter = false;
|
||||
handleImage.color = new Color(1f, 1f, 1f, 0.392f);
|
||||
|
||||
|
||||
BoxSlider selectableArea = uiboxSliderRoot.AddComponent<BoxSlider>();
|
||||
selectableArea.HandleRect = handle.GetComponent<RectTransform>();
|
||||
selectableArea.ValueX = selectableArea.ValueY = 0.5f;
|
||||
|
||||
Selection.activeGameObject = uiboxSliderRoot;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper Functions
|
||||
private static GameObject AddInputFieldAsChild(GameObject parent)
|
||||
{
|
||||
GameObject root = CreateUIObject("InputField", parent);
|
||||
|
||||
|
@ -1787,7 +1823,16 @@ namespace UnityEditor.UI
|
|||
return buttonRoot;
|
||||
}
|
||||
|
||||
#endregion
|
||||
private static RectTransform SetAnchorsAndStretch(GameObject root)
|
||||
{
|
||||
RectTransform rectTransformRoot = root.GetComponent<RectTransform>();
|
||||
rectTransformRoot.anchorMin = new Vector2(0.5f, 0.5f);
|
||||
rectTransformRoot.anchorMax = new Vector2(0.5f, 0.5f);
|
||||
rectTransformRoot.anchoredPosition = Vector2.zero;
|
||||
return rectTransformRoot;
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,12 +80,16 @@ namespace UnityEngine.UI.Extensions
|
|||
{
|
||||
_previousPage = _currentPage;
|
||||
_currentPage = value;
|
||||
ChangeBulletsInfo(_currentPage);
|
||||
if(MaskArea) UpdateVisible();
|
||||
ScreenChange();
|
||||
ChangeBulletsInfo(_currentPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Tooltip("(Experimental)\nBy default, child array objects will use the parent transform\nHowever you can disable this for some interesting effects")]
|
||||
public bool UseParentTransform = true;
|
||||
|
||||
[Tooltip("Scroll Snap children. (optional)\nEither place objects in the scene as children OR\nPrefabs in this array, NOT BOTH")]
|
||||
public GameObject[] ChildObjects;
|
||||
|
||||
|
@ -156,10 +160,21 @@ namespace UnityEngine.UI.Extensions
|
|||
internal void InitialiseChildObjectsFromArray()
|
||||
{
|
||||
int childCount = ChildObjects.Length;
|
||||
RectTransform childRect;
|
||||
GameObject child;
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
ChildObjects[i] = GameObject.Instantiate(ChildObjects[i]);
|
||||
ChildObjects[i].transform.SetParent(_screensContainer.transform);
|
||||
child = GameObject.Instantiate(ChildObjects[i]);
|
||||
//Optionally, use original GO transform when initialising, by default will use parent RectTransform position/rotation
|
||||
if (UseParentTransform)
|
||||
{
|
||||
childRect = child.GetComponent<RectTransform>();
|
||||
childRect.rotation = _screensContainer.rotation;
|
||||
childRect.localScale = _screensContainer.localScale;
|
||||
childRect.position = _screensContainer.position;
|
||||
}
|
||||
child.transform.SetParent(_screensContainer.transform);
|
||||
ChildObjects[i] = child;
|
||||
if (MaskArea && ChildObjects[i].activeSelf)
|
||||
{
|
||||
ChildObjects[i].SetActive(false);
|
||||
|
@ -306,9 +321,8 @@ namespace UnityEngine.UI.Extensions
|
|||
OnSelectionChangeStartEvent.Invoke();
|
||||
}
|
||||
|
||||
internal void ScreenChange(int previousScreen)
|
||||
internal void ScreenChange()
|
||||
{
|
||||
|
||||
OnSelectionPageChangedEvent.Invoke(_currentPage);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue