Skip to content

Commit

Permalink
Fix indentation for conditionally compiled code.
Browse files Browse the repository at this point in the history
  • Loading branch information
billyquith authored and mikeage committed May 23, 2021
1 parent 1236d81 commit 2b1f4a2
Show file tree
Hide file tree
Showing 7 changed files with 348 additions and 304 deletions.
8 changes: 3 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@

root = true

[*.{cs,py,json,cfg}]
[*.{json,cfg}]
indent_style = space
indent_size = 2

[*.py]
indent_size = 4

[*.cs]
[*.{cs,py}]
indent_style = space
indent_size = 4

# Microsoft .NET properties
Expand Down
48 changes: 24 additions & 24 deletions Assets/Editor/BuildTiltBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ private static readonly List<KeyValuePair<SdkMode, BuildTarget>> kValidSdkTarget
new KeyValuePair<SdkMode, BuildTarget>(SdkMode.SteamVR, BuildTarget.StandaloneLinux64),
new KeyValuePair<SdkMode, BuildTarget>(SdkMode.SteamVR, BuildTarget.StandaloneOSX),
#if OCULUS_SUPPORTED
new KeyValuePair<SdkMode, BuildTarget>(SdkMode.Oculus, BuildTarget.StandaloneWindows64),
new KeyValuePair<SdkMode, BuildTarget>(SdkMode.Oculus, BuildTarget.Android),
new KeyValuePair<SdkMode, BuildTarget>(SdkMode.Oculus, BuildTarget.StandaloneWindows64),
new KeyValuePair<SdkMode, BuildTarget>(SdkMode.Oculus, BuildTarget.Android),
#endif // OCULUS_SUPPORTED
new KeyValuePair<SdkMode, BuildTarget>(SdkMode.Gvr, BuildTarget.Android),
};
Expand Down Expand Up @@ -156,7 +156,7 @@ public static SdkMode GuiSelectedSdk
EditorPrefs.SetString(kMenuSdkPref, value.ToString());
Menu.SetChecked(kMenuSdkMonoscopic, false);
#if OCULUS_SUPPORTED
Menu.SetChecked(kMenuSdkOculus, false);
Menu.SetChecked(kMenuSdkOculus, false);
#endif // OCULUS_SUPPORTED
Menu.SetChecked(kMenuSdkSteamVr, false);
Menu.SetChecked(kMenuSdkGoogleVr, false);
Expand All @@ -168,7 +168,7 @@ public static SdkMode GuiSelectedSdk
break;
case SdkMode.Oculus:
#if OCULUS_SUPPORTED
Menu.SetChecked(kMenuSdkOculus, true);
Menu.SetChecked(kMenuSdkOculus, true);
#endif // OCULUS_SUPPORTED
break;
case SdkMode.SteamVR:
Expand Down Expand Up @@ -415,8 +415,8 @@ static void MenuItem_Sdk_Oculus()
static bool MenuItem_Sdk_Oculus_Validate()
{
#if OCULUS_SUPPORTED
Menu.SetChecked(kMenuSdkOculus, GuiSelectedSdk == SdkMode.Oculus);
return true;
Menu.SetChecked(kMenuSdkOculus, GuiSelectedSdk == SdkMode.Oculus);
return true;
#else
return false;
#endif
Expand Down Expand Up @@ -707,11 +707,11 @@ static void CommandLine()


#if OCULUS_SUPPORTED
// Call these once to create the files. Normally (i.e., in a GUI build), they're created with
// [UnityEditor.InitializeOnLoad], but in case they're missing, like in CI, make sure they're
// there!
OVRProjectConfig defaultOculusProjectConfig = OVRProjectConfig.GetProjectConfig();
string useless_app_id = Assets.Oculus.VR.Editor.OVRPlatformToolSettings.AppID;
// Call these once to create the files. Normally (i.e., in a GUI build), they're created with
// [UnityEditor.InitializeOnLoad], but in case they're missing, like in CI, make sure they're
// there!
OVRProjectConfig defaultOculusProjectConfig = OVRProjectConfig.GetProjectConfig();
string useless_app_id = Assets.Oculus.VR.Editor.OVRPlatformToolSettings.AppID;
#endif

{
Expand Down Expand Up @@ -1527,19 +1527,19 @@ public static void OnPostProcessBuild(BuildTarget target, string path)
// TODO: is it possible to embed loose files on iOS?
looseFilesDest = null;
#if UNITY_EDITOR_OSX && UNITY_IPHONE
string pbxPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
string pbxPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

PBXProject project = new PBXProject();
project.ReadFromString(File.ReadAllText(pbxPath));
string pbxTarget = project.TargetGuidByName("Unity-iPhone");
PBXProject project = new PBXProject();
project.ReadFromString(File.ReadAllText(pbxPath));
string pbxTarget = project.TargetGuidByName("Unity-iPhone");

// additional framework libs
project.AddFrameworkToProject(pbxTarget, "Security.framework", false);
project.AddFrameworkToProject(pbxTarget, "CoreData.framework", false);
// disable bitcode due to issue with Cardboard plugin (b/27129333)
project.SetBuildProperty(pbxTarget, "ENABLE_BITCODE", "false");
// additional framework libs
project.AddFrameworkToProject(pbxTarget, "Security.framework", false);
project.AddFrameworkToProject(pbxTarget, "CoreData.framework", false);
// disable bitcode due to issue with Cardboard plugin (b/27129333)
project.SetBuildProperty(pbxTarget, "ENABLE_BITCODE", "false");

File.WriteAllText(pbxPath, project.WriteToString());
File.WriteAllText(pbxPath, project.WriteToString());
#else
Die(5, "OS X required for building iOS target.");
#endif
Expand Down Expand Up @@ -1756,7 +1756,7 @@ public static void DoBackgroundBuild(TiltBuildOptions tiltOptions, bool interact
string logFile = Path.Combine(rootCopyDir.FullName, "BackgroundBuild.log");
FileUtil.DeleteFileOrDirectory(logFile);
#if UNITY_EDITOR_OSX
args.AppendFormat("--args ");
args.AppendFormat("--args ");
#endif
args.AppendFormat("-logFile {0} ", logFile);
if (!interactive) { args.Append("-batchmode "); }
Expand All @@ -1782,8 +1782,8 @@ public static void DoBackgroundBuild(TiltBuildOptions tiltOptions, bool interact
StringBuilder unityPath = new StringBuilder();
unityPath.AppendFormat(EditorApplication.applicationPath);
#if UNITY_EDITOR_OSX
// We want to run the inner Unity executable, not the GUI wrapper
unityPath.AppendFormat("/Contents/MacOS/Unity");
// We want to run the inner Unity executable, not the GUI wrapper
unityPath.AppendFormat("/Contents/MacOS/Unity");
#endif
process.StartInfo = new System.Diagnostics.ProcessStartInfo(unityPath.ToString(), args.ToString());
DetectBackgroundProcessExit(process);
Expand Down
9 changes: 6 additions & 3 deletions Assets/Scripts/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private class UserConfigChange
// is being used (Oculus VR, Steam's Open VR, Monoscopic, etc.).
public VrHardware VrHardware
{
// This is set lazily the first time VrHardware is accesssed.
// This is set lazily the first time VrHardware is accessed.
get
{
if (m_VrHardware == TiltBrush.VrHardware.Unset)
Expand Down Expand Up @@ -224,8 +224,11 @@ public bool IsMobileHardware
// Only sadness will ensue if the user tries to set Override.MobileHardware=true
// but their editor platform is still set to Windows.
#if UNITY_EDITOR && UNITY_ANDROID
get { return Application.platform == RuntimePlatform.Android
|| SpoofMobileHardware.MobileHardware; }
get
{
return Application.platform == RuntimePlatform.Android
|| SpoofMobileHardware.MobileHardware;
}
#else
get { return Application.platform == RuntimePlatform.Android; }
#endif
Expand Down
89 changes: 50 additions & 39 deletions Assets/Scripts/Entitlement/OculusAuth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,61 @@ namespace TiltBrush
public class OculusAuth : MonoBehaviour
{
#if OCULUS_SUPPORTED
private bool m_authenticated = false;
// The App ID is a public identifier for the Tilt Brush app on the Oculus platform. It is
// analogous to Apple's App ID, which shows up in URLs related to the app.
private string m_TiltBrushOculusRiftAppId => App.Config.OculusSecrets?.ClientId;
private string m_TiltBrushOculusMobileAppId => App.Config.OculusMobileSecrets?.ClientId;
private bool m_authenticated = false;
// The App ID is a public identifier for the Tilt Brush app on the Oculus platform. It is
// analogous to Apple's App ID, which shows up in URLs related to the app.
private string m_TiltBrushOculusRiftAppId => App.Config.OculusSecrets?.ClientId;
private string m_TiltBrushOculusMobileAppId => App.Config.OculusMobileSecrets?.ClientId;

private void Awake() {
string id = App.Config.IsMobileHardware
? m_TiltBrushOculusMobileAppId
: m_TiltBrushOculusRiftAppId;
if (string.IsNullOrEmpty(id)) {
return;
}
Oculus.Platform.Core.AsyncInitialize(id);
Oculus.Platform.Entitlements.IsUserEntitledToApplication().OnComplete(EntitlementCallback);
}
private void Awake()
{
string id = App.Config.IsMobileHardware
? m_TiltBrushOculusMobileAppId
: m_TiltBrushOculusRiftAppId;
if (string.IsNullOrEmpty(id))
{
return;
}
Oculus.Platform.Core.AsyncInitialize(id);
Oculus.Platform.Entitlements.IsUserEntitledToApplication().OnComplete(EntitlementCallback);
}

public void Update() {
Oculus.Platform.Request.RunCallbacks();
}
public void Update()
{
Oculus.Platform.Request.RunCallbacks();
}

private void EntitlementCallback(Oculus.Platform.Message msg)
{
string strMsg;
if (msg.IsError) {
if (msg.GetError() != null) {
strMsg = msg.GetError().Message;
} else {
strMsg = "Authentication failed";
}
} else {
m_authenticated = true;
strMsg = "";
}
private void EntitlementCallback(Oculus.Platform.Message msg)
{
string strMsg;
if (msg.IsError)
{
if (msg.GetError() != null)
{
strMsg = msg.GetError().Message;
}
else
{
strMsg = "Authentication failed";
}
}
else
{
m_authenticated = true;
strMsg = "";
}

if (strMsg != string.Empty) {
Debug.Log(strMsg, this);
}
if (strMsg != string.Empty)
{
Debug.Log(strMsg, this);
}

if (!m_authenticated) {
Debug.Log("User not authenticated! You must be logged in to continue.");
Application.Quit();
}
}
if (!m_authenticated)
{
Debug.Log("User not authenticated! You must be logged in to continue.");
Application.Quit();
}
}
#endif // OCULUS_SUPPORTED
}
} // namespace TiltBrush
8 changes: 4 additions & 4 deletions Assets/Scripts/GUI/SketchbookPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,10 @@ protected override void RefreshPage()

bool notSupported = false;
#if UNITY_ANDROID && OCULUS_SUPPORTED
notSupported = !polyDown && !outOfDate && OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Quest
&& (m_CurrentSketchSet == SketchSetType.Curated
|| m_CurrentSketchSet == SketchSetType.Liked);
m_NotSupportedMessage.SetActive(notSupported);
notSupported = !polyDown && !outOfDate && OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Quest
&& (m_CurrentSketchSet == SketchSetType.Curated
|| m_CurrentSketchSet == SketchSetType.Liked);
m_NotSupportedMessage.SetActive(notSupported);
#endif

if (outOfDate || polyDown || notSupported)
Expand Down
Loading

0 comments on commit 2b1f4a2

Please sign in to comment.