Skip to content
Permalink
Browse files

Allocation-free cursor spawning.

  • Loading branch information...
valyard committed Aug 1, 2017
1 parent 6229054 commit 74f58155ddcd42c0a37428f2dd6814e05ec70215
@@ -47,6 +47,7 @@ GameObject:
- component: {fileID: 22499528}
- component: {fileID: 11416202}
- component: {fileID: 223878911915740246}
- component: {fileID: 225715774982127120}
m_Layer: 0
m_Name: Mouse Cursor
m_TagString: Untagged
@@ -419,3 +420,14 @@ Canvas:
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!225 &225715774982127120
CanvasGroup:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 185820}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 0
m_BlocksRaycasts: 0
m_IgnoreParentGroups: 0
@@ -28,6 +28,7 @@ GameObject:
- component: {fileID: 22480400}
- component: {fileID: 11486812}
- component: {fileID: 223912096970254378}
- component: {fileID: 225894359780410702}
m_Layer: 0
m_Name: Pen Cursor
m_TagString: Untagged
@@ -421,3 +422,14 @@ Canvas:
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!225 &225894359780410702
CanvasGroup:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 118164}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 0
m_BlocksRaycasts: 0
m_IgnoreParentGroups: 0
@@ -28,6 +28,7 @@ GameObject:
- component: {fileID: 22471328}
- component: {fileID: 11468960}
- component: {fileID: 223813922742015622}
- component: {fileID: 225429637618999960}
m_Layer: 0
m_Name: Pointer
m_TagString: Untagged
@@ -188,3 +189,14 @@ Canvas:
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!225 &225429637618999960
CanvasGroup:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 183852}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 0
m_BlocksRaycasts: 0
m_IgnoreParentGroups: 0
@@ -46,6 +46,7 @@ GameObject:
- component: {fileID: 22499528}
- component: {fileID: 11435582}
- component: {fileID: 223147991810450650}
- component: {fileID: 225477107791102178}
m_Layer: 0
m_Name: Touch Cursor
m_TagString: Untagged
@@ -283,3 +284,14 @@ Canvas:
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!225 &225477107791102178
CanvasGroup:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 185820}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 0
m_BlocksRaycasts: 0
m_IgnoreParentGroups: 0
@@ -206,6 +206,8 @@ public float Size
/// </summary>
protected uint hash = uint.MaxValue;

private CanvasGroup group;

#endregion

#region Public methods
@@ -218,11 +220,13 @@ public float Size
public void Init(RectTransform parent, IPointer pointer)
{
hash = uint.MaxValue;
group = GetComponent<CanvasGroup>();

show();
rect.SetParent(parent);
rect.SetAsLastSibling();
state = CursorState.Released;

UpdatePointer(pointer);
}

@@ -290,16 +294,21 @@ private void Awake()
/// </summary>
protected virtual void hide()
{
gameObject.SetActive(false);
gameObject.name = "inactive pointer";
group.alpha = 0;
#if UNITY_EDITOR
gameObject.name = "Inactive Pointer";
#endif
}

/// <summary>
/// Shows this instance.
/// </summary>
protected virtual void show()
{
gameObject.SetActive(true);
group.alpha = 1;
#if UNITY_EDITOR
gameObject.name = "Pointer";
#endif
}

/// <summary>

0 comments on commit 74f5815

Please sign in to comment.
You can’t perform that action at this time.