Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BoundsControl Bug #11698

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ public BoundsControl BoundsControlRoot

private bool wasOccludedLastFrame = false;

private Vector3 initialLocalScale;

private float initialParentScale;

protected override void Awake()
Expand All @@ -100,23 +98,13 @@ protected override void Awake()
DisableInteractorType(typeof(IPokeInteractor));

handleRenderer = GetComponentInChildren<MeshRenderer>();

// Start occluded, so we don't show a frame of handles
// on startup when they should start disabled.
// We'll un-occlude on the next frame if we need to.
if (handleRenderer != null)
{
handleRenderer.enabled = false;
}
colliders[0].enabled = false;
wasOccludedLastFrame = true;
HideOnStartup();
}

// Record initial values at Start(), so that we
// capture the bounds sizing, etc.
void Start()
{
initialLocalScale = transform.localScale;
initialParentScale = MaxComponent(transform.parent.lossyScale);
}

Expand Down Expand Up @@ -153,6 +141,19 @@ private float MaxComponent(Vector3 v)
return Mathf.Max(Mathf.Abs(v.x), Mathf.Abs(v.y), Mathf.Abs(v.z));
}

/// <summary>
/// Occludes the handle so it is not initially visible when it should start disabled.
/// </summary>
public void HideOnStartup()
{
if (handleRenderer != null)
{
handleRenderer.enabled = false;
}
colliders[0].enabled = false;
wasOccludedLastFrame = true;
}

/// <inheritdoc />
protected override void OnSelectEntered(SelectEnterEventArgs args)
{
Expand All @@ -167,4 +168,4 @@ protected override void OnSelectExited(SelectExitEventArgs args)
BoundsControlRoot.OnHandleSelectExited(this, args);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ Animator:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
m_WriteDefaultValuesOnDisable: 1
--- !u!114 &6880724489352698737
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ Animator:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
m_WriteDefaultValuesOnDisable: 1
--- !u!114 &8925431220799339971
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ Animator:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
m_WriteDefaultValuesOnDisable: 1
--- !u!114 &8541032172729434893
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,14 @@ private void Update()
}
}

protected virtual void OnEnable()
{
foreach (var handle in handles)
{
handle.HideOnStartup();
}
}

/// <summary>
/// Writes the property values into the renderer. Override this if you have custom box visuals that use different material property bindings.
/// </summary>
Expand Down