Skip to content

Commit

Permalink
Remove hardcoded passthrough GUID
Browse files Browse the repository at this point in the history
Replaced
PASSTHROUGH_GUID = "e38af599-4575-46ff-a040-459703dbcd36";
with a new property isPassthrough in the environment scriptable object.
  • Loading branch information
sbanca committed Dec 19, 2024
1 parent 7b9f6a1 commit 4712b79
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Guid:
m_storage: e38af599-4575-46ff-a040-459703dbcd36
m_Description: ENVIRONMENT_PASSTHROUGH
m_EnvironmentDescription:
m_TableReference:
m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86
Expand Down Expand Up @@ -63,6 +62,7 @@ MonoBehaviour:
m_WidgetHome: {x: 0, y: 0, z: 0}
m_SkyboxColorA: {r: 0, g: 0, b: 0, a: 0}
m_SkyboxColorB: {r: 0, g: 0, b: 0, a: 0}
isPassthrough: 1
references:
version: 2
RefIds: []
1 change: 1 addition & 0 deletions Assets/Scripts/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public Material m_SkyboxMaterial

public Color m_SkyboxColorA;
public Color m_SkyboxColorB;
public bool isPassthrough;
}

} // namespace TiltBrush
15 changes: 8 additions & 7 deletions Assets/Scripts/GUI/LightingPopUpWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace TiltBrush

public class LightingPopUpWindow : PagingPopUpWindow
{
private const string PASSTHROUGH_GUID = "e38af599-4575-46ff-a040-459703dbcd36";

private string m_CurrentPresetGuid;
[SerializeField] private Transform m_PassthroughControls;
Expand Down Expand Up @@ -105,8 +104,7 @@ public void RemovePassthrough()
{
foreach (var env in m_Environments)
{
// Passthrough
if (env.m_Guid.ToString() == PASSTHROUGH_GUID)
if (env.isPassthrough)
{
m_Environments.Remove(env);
break;
Expand All @@ -127,8 +125,7 @@ public void HandleCanvasReset(ActionButton btn)
override protected void RefreshPage()
{
base.RefreshPage();
bool passthroughActive = m_CurrentPresetGuid == PASSTHROUGH_GUID;
if (passthroughActive)
if (isPassThroughActive())
{
m_PassthroughControls.gameObject.SetActive(true);
}
Expand All @@ -144,8 +141,7 @@ protected void OnFadingToDesiredEnvironment()
if (rCurrentPreset != null)
{
m_CurrentPresetGuid = rCurrentPreset.m_Guid.ToString();
bool passthroughActive = m_CurrentPresetGuid == PASSTHROUGH_GUID;
if (passthroughActive)
if (isPassThroughActive())
{
m_PassthroughControls.gameObject.SetActive(true);
m_WorldLockToggle.IsToggledOn = true;
Expand All @@ -161,6 +157,11 @@ protected void OnFadingToDesiredEnvironment()
RefreshPage();
}

private bool isPassThroughActive()
{
return m_Environments.Any(env => env.isPassthrough && env.m_Guid.ToString() == m_CurrentPresetGuid);
}

void OnDestroy()
{
SceneSettings.m_Instance.FadingToDesiredEnvironment -= OnFadingToDesiredEnvironment;
Expand Down
4 changes: 1 addition & 3 deletions Assets/Scripts/GUI/MultiplayerPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,13 @@ private Tuple<bool, string> CheckIfRoomExist()

}

// hardoded copied from LightingPopUpWindow
private const string PASSTHROUGH_GUID = "e38af599-4575-46ff-a040-459703dbcd36";
private Tuple<bool, string> CheckIfPassThroughEnvironment()
{

if (MultiplayerManager.m_Instance != null && MultiplayerManager.m_Instance.State == ConnectionState.IN_LOBBY)
{
TiltBrush.Environment targetEnvironment = SceneSettings.m_Instance.GetDesiredPreset();
if (targetEnvironment.m_Guid.ToString() == PASSTHROUGH_GUID)
if (targetEnvironment.isPassthrough)
return Tuple.Create(true, m_AlertsPassThroughAcive.GetLocalizedString());
}

Expand Down

0 comments on commit 4712b79

Please sign in to comment.