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

Add a pre-commit config that runs with the defines used for major projects (and run once) #793

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions .pre-commit-config-defines.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
repos:
- repo: local
hooks:
- id: dotnet-format-windows
name: dotnet-format for Windows
language: system
entry: ./pre-commit-dotnet-format-windows.sh
types_or: [c#, vb]
exclude: ^(Assets/ThirdParty)|(Packages/)|(Assets/Photon/)
- repo: local
hooks:
- id: dotnet-format-multiplayer
name: dotnet-format for multiplayer
language: system
entry: ./pre-commit-dotnet-format-multiplayer.sh
types_or: [c#, vb]
exclude: ^(Assets/ThirdParty)|(Packages/)|(Assets/Photon/)
- repo: local
hooks:
- id: dotnet-format-oculus
name: dotnet-format for oculus
language: system
entry: ./pre-commit-dotnet-format-oculus.sh
types_or: [c#, vb]
exclude: ^(Assets/ThirdParty)|(Packages/)|(Assets/Photon/)
35 changes: 20 additions & 15 deletions Assets/Scripts/Debug/Editor/SetStereoRenderPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,30 @@
namespace TiltBrush
{
#if UNITY_ANDROID || UNITY_IOS
[InitializeOnLoadAttribute]
public class SetStereoRenderPath {
[InitializeOnLoadAttribute]
public class SetStereoRenderPath
{

private static StereoRenderingPath s_OriginalStereoPath;
private static StereoRenderingPath s_OriginalStereoPath;

static SetStereoRenderPath() {
EditorApplication.playModeStateChanged += OnPlayModeChanged;
}
static SetStereoRenderPath()
{
EditorApplication.playModeStateChanged += OnPlayModeChanged;
}

static void OnPlayModeChanged(PlayModeStateChange stateChange) {
if (stateChange == PlayModeStateChange.ExitingEditMode) {
s_OriginalStereoPath = PlayerSettings.stereoRenderingPath;
PlayerSettings.stereoRenderingPath = StereoRenderingPath.SinglePass;
}
static void OnPlayModeChanged(PlayModeStateChange stateChange)
{
if (stateChange == PlayModeStateChange.ExitingEditMode)
{
s_OriginalStereoPath = PlayerSettings.stereoRenderingPath;
PlayerSettings.stereoRenderingPath = StereoRenderingPath.SinglePass;
}

if (stateChange == PlayModeStateChange.EnteredEditMode) {
PlayerSettings.stereoRenderingPath = s_OriginalStereoPath;
if (stateChange == PlayModeStateChange.EnteredEditMode)
{
PlayerSettings.stereoRenderingPath = s_OriginalStereoPath;
}
}
}
}
}
#endif
} // namespace TiltBrush
4 changes: 2 additions & 2 deletions Assets/Scripts/Export/Export.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public static class Export
{
const string kExportDocumentationUrl = "https://docs.google.com/document/d/11ZsHozYn9FnWG7y3s3WAyKIACfbfwb4PbaS8cZ_xjvo#heading=h.im5f33smiavy";
#if UNITY_ANDROID || UNITY_IOS
const string kExportReadmeName = "README.txt";
const string kExportReadmeBody = "Please see " + kExportDocumentationUrl;
const string kExportReadmeName = "README.txt";
const string kExportReadmeBody = "Please see " + kExportDocumentationUrl;
#else
const string kExportReadmeName = "README.url";
const string kExportReadmeBody = @"[InternetShortcut]
Expand Down
8 changes: 4 additions & 4 deletions Assets/Scripts/Export/ExportUsd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static class ExportUsd
// Serialization Classes
// -------------------------------------------------------------------------------------------- //

#region "Geometry Classes for Serialization"
#region "Geometry Classes for Serialization"

/// The root / sketch metadata for the file.
[Serializable]
Expand Down Expand Up @@ -109,9 +109,9 @@ public class BrushCurvesSample : USD.NET.Unity.BasisCurvesSample
public float[] pressures;
}

#endregion
#endregion

#region "Material Classes for Serialization"
#region "Material Classes for Serialization"

[Serializable]
[UsedImplicitly(ImplicitUseTargetFlags.Members)]
Expand Down Expand Up @@ -224,7 +224,7 @@ public PrimvarReader4fSample(string primvarName)
}
}

#endregion
#endregion

// -------------------------------------------------------------------------------------------- //
// Conversion Helpers
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/FrameTimingInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ void Update()
// Oculus only computes cumulative frames dropped, so we reset the perf stats
// each frame after recording.
#if OCULUS_SUPPORTED
// TODO: Currently not supported on Oculus OpenXR backend.
// OVRPlugin.ResetAppPerfStats();
// TODO: Currently not supported on Oculus OpenXR backend.
// OVRPlugin.ResetAppPerfStats();
#endif // OCULUS_SUPPORTED
}

Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/ModelCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ void ProcessDirectory(string sPath, Dictionary<string, Model> oldModels)
List<string> extensions = new() { ".gltf2", ".gltf", ".glb", ".ply", ".svg" };

#if USD_SUPPORTED
extensions.AddRange(new [] { ".usda", ".usdc", ".usd" });
extensions.AddRange(new[] { ".usda", ".usdc", ".usd" });
#endif
#if FBX_SUPPORTED
extensions.AddRange(new [] { ".obj", ".fbx" });
extensions.AddRange(new[] { ".obj", ".fbx" });
#endif

for (int i = 0; i < aFiles.Length; ++i)
Expand Down
3 changes: 2 additions & 1 deletion Assets/Scripts/Multiplayer/MultiplayerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ void Start()
{

#if OCULUS_SUPPORTED
OVRPlatform.Users.GetLoggedInUser().OnComplete((msg) => {
OVRPlatform.Users.GetLoggedInUser().OnComplete((msg) =>
{
if (!msg.IsError)
{
myOculusUserId = msg.GetUser().ID;
Expand Down
42 changes: 21 additions & 21 deletions Assets/Scripts/Multiplayer/Photon/PhotonManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public PhotonManager(MultiplayerManager manager)

public async Task<bool> Connect()
{
if(m_Runner != null)
if (m_Runner != null)
{
GameObject.Destroy(m_Runner);
}
Expand Down Expand Up @@ -74,12 +74,12 @@ public async Task<bool> Connect()
var result = await m_Runner.StartGame(args);

return result.Ok;

}

public bool IsConnected()
{
if(m_Runner == null)
if (m_Runner == null)
{
return false;
}
Expand All @@ -88,7 +88,7 @@ public bool IsConnected()

public async Task<bool> Disconnect(bool force)
{
if(m_Runner != null)
if (m_Runner != null)
{
await m_Runner.Shutdown(forceShutdownProcedure: force);
return m_Runner.IsShutdown;
Expand All @@ -110,11 +110,11 @@ public void Update()
}
}

#region IConnectionHandler Methods
#region IConnectionHandler Methods
public async Task<bool> PerformCommand(BaseCommand command)
{
await Task.Yield();
return ProcessCommand(command);;
return ProcessCommand(command); ;
}

public async Task<bool> UndoCommand(BaseCommand command)
Expand All @@ -137,13 +137,13 @@ public async Task<bool> RpcSyncToSharedAnchor(string uuid)
await Task.Yield();
return true;
}
#endregion
#endregion

#region Command Methods
#region Command Methods
private bool ProcessCommand(BaseCommand command)
{
bool success = true;
switch(command)
switch (command)
{
case BrushStrokeCommand:
success = CommandBrushStroke(command as BrushStrokeCommand);
Expand All @@ -160,9 +160,9 @@ private bool ProcessCommand(BaseCommand command)
break;
}

if(command.ChildrenCount > 0)
if (command.ChildrenCount > 0)
{
foreach(var child in command.Children)
foreach (var child in command.Children)
{
success &= ProcessCommand(child);
}
Expand Down Expand Up @@ -196,12 +196,12 @@ private bool CommandBrushStroke(BrushStrokeCommand command)
// Middle
for (int rounds = 1; rounds < numSplits + 1; ++rounds)
{
var controlPoints = stroke.m_ControlPoints.Skip(rounds*128).Take(128).ToArray();
var dropPoints = stroke.m_ControlPointsToDrop.Skip(rounds*128).Take(128).ToArray();
var controlPoints = stroke.m_ControlPoints.Skip(rounds * 128).Take(128).ToArray();
var dropPoints = stroke.m_ControlPointsToDrop.Skip(rounds * 128).Take(128).ToArray();

var netControlPoints = new NetworkedControlPoint[controlPoints.Length];

for (int point = 0; point < controlPoints.Length; ++ point)
for (int point = 0; point < controlPoints.Length; ++point)
{
netControlPoints[point] = new NetworkedControlPoint().Init(controlPoints[point]);
}
Expand Down Expand Up @@ -231,9 +231,9 @@ private bool CommandDeleteStroke(DeleteStrokeCommand command)
PhotonRPC.RPC_DeleteStroke(m_Runner, command.m_TargetStroke.m_Seed, command.Guid, command.ParentGuid, command.ChildrenCount);
return true;
}
#endregion
#endregion

#region Photon Callbacks
#region Photon Callbacks
public void OnConnectedToServer(NetworkRunner runner)
{
var rpc = m_Runner.gameObject.AddComponent<PhotonRPC>();
Expand All @@ -242,13 +242,13 @@ public void OnConnectedToServer(NetworkRunner runner)

public void OnPlayerJoined(NetworkRunner runner, PlayerRef player)
{
if(player == m_Runner.LocalPlayer)
if (player == m_Runner.LocalPlayer)
{
var playerPrefab = Resources.Load("Multiplayer/Photon/PhotonPlayerRig") as GameObject;
var playerObj = m_Runner.Spawn(playerPrefab, inputAuthority: m_Runner.LocalPlayer);
m_LocalPlayer = playerObj.GetComponent<PhotonPlayerRig>();
m_Runner.SetPlayerObject(m_Runner.LocalPlayer, playerObj);


m_Manager.localPlayerJoined?.Invoke(m_LocalPlayer);
}
Expand All @@ -257,9 +257,9 @@ public void OnPlayerJoined(NetworkRunner runner, PlayerRef player)
m_PlayersSpawning.Add(player);
}
}
#endregion
#endregion

#region Unused Photon Callbacks
#region Unused Photon Callbacks
public void OnPlayerLeft(NetworkRunner runner, PlayerRef player) { }
public void OnShutdown(NetworkRunner runner, ShutdownReason shutdownReason) { }
public void OnDisconnectedFromServer(NetworkRunner runner) { }
Expand All @@ -274,7 +274,7 @@ public void OnHostMigration(NetworkRunner runner, HostMigrationToken hostMigrati
public void OnReliableDataReceived(NetworkRunner runner, PlayerRef player, ArraySegment<byte> data) { }
public void OnSceneLoadDone(NetworkRunner runner) { }
public void OnSceneLoadStart(NetworkRunner runner) { }
#endregion
#endregion
}
}

Expand Down
8 changes: 4 additions & 4 deletions Assets/Scripts/Multiplayer/Photon/PhotonPlayerRig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public override void Spawned()

brushGuid = BrushCatalog.m_Instance.DefaultBrush.m_Guid.ToString();

if(!Object.HasStateAuthority)
if (!Object.HasStateAuthority)
{
transientPointer = PointerManager.m_Instance.CreateRemotePointer();
transientPointer.SetBrush(BrushCatalog.m_Instance.DefaultBrush);
Expand All @@ -81,7 +81,7 @@ public override void FixedUpdateNetwork()
{
base.FixedUpdateNetwork();

if(Object.HasStateAuthority)
if (Object.HasStateAuthority)
{
m_PlayerHead.transform.position = transmitData.HeadPosition;
m_PlayerHead.transform.rotation = transmitData.HeadRotation;
Expand All @@ -99,14 +99,14 @@ public override void Render()
{

}

else
{
var toolTR = TrTransform.TR(m_Tool.InterpolationTarget.position, m_Tool.InterpolationTarget.rotation);
App.Scene.AsScene[transientPointer.transform] = toolTR;

transientPointer.SetColor(brushColor);
if(brushGuid.ToString() != string.Empty)
if (brushGuid.ToString() != string.Empty)
{
transientPointer.SetBrush(BrushCatalog.m_Instance.GetBrush(new System.Guid(brushGuid.ToString())));
}
Expand Down
Loading
Loading