Skip to content

Commit

Permalink
Merge branch 'main' into feature/browserbridge-onquit
Browse files Browse the repository at this point in the history
  • Loading branch information
aarijimam authored Nov 25, 2024
2 parents 343f12b + b207723 commit 38311e1
Show file tree
Hide file tree
Showing 23 changed files with 249 additions and 209 deletions.
48 changes: 48 additions & 0 deletions Assets/PlayroomKit/Editor/PlayroomDevEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ public override VisualElement CreateInspectorGUI()
VisualElement insertCoinContainer = InsertCoinContainerCreator();
Button launchPlayerButton = LaunchPlayerButtonCreator();
VisualElement docsLink = DocumentationLinkCreator();
VisualElement enableLogsToggle = EnableLogsToggleCreator();

// Add elements to root
root.Add(mockModeContainer);
root.Add(insertCoinContainer);
root.Add(enableLogsToggle);
root.Add(launchPlayerButton);
root.Add(docsLink);

Expand Down Expand Up @@ -170,6 +172,52 @@ private static VisualElement DocumentationLinkCreator()

return docLink;
}

private VisualElement EnableLogsToggleCreator()
{
// Create a horizontal container
VisualElement enableLogsContainer = new VisualElement();
enableLogsContainer.style.flexDirection = FlexDirection.Row; // Arrange items horizontally

// Create the label for Enable Logs
var enableLogsLabel = new Label("Enable Logs");
enableLogsLabel.AddToClassList("label"); // Add consistent styling

// Create the tooltip button
var debugToggleToolTip = new Button(() => { })
{
text = "?",
tooltip = "Enable or disable logging for debugging purposes."
};
debugToggleToolTip.AddToClassList("tooltip-button");

// Create the toggle
var enableLogsToggle = new Toggle();
enableLogsToggle.AddToClassList("toggle"); // Apply consistent styling to the toggle

// Manually bind the property if BindProperty isn't supported
var enableLogsProperty = serializedObject.FindProperty("enableLogs");

// Set the initial value
enableLogsToggle.value = enableLogsProperty.boolValue;

// Register value changed callback
enableLogsToggle.RegisterValueChangedCallback(evt =>
{
enableLogsProperty.boolValue = evt.newValue;
serializedObject.ApplyModifiedProperties();
});

// Add the elements to the container in the desired order
enableLogsContainer.Add(enableLogsLabel); // Add label first
enableLogsContainer.Add(debugToggleToolTip); // Add tooltip button next
enableLogsContainer.Add(enableLogsToggle); // Add toggle last

return enableLogsContainer;
}



}
}
#endif
8 changes: 8 additions & 0 deletions Assets/PlayroomKit/Editor/PlayroomkitDevManagerEditor.uss
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,12 @@
align-self: center;

color: aqua;
}

.toggle {
height: 25px;
font-size: 14px;
-unity-text-align: middle-center;
margin-left: 32px;
margin-bottom: 32px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,17 @@ PrefabInstance:
propertyPath: insertCoinCaller
value:
objectReference: {fileID: 330732768}
- target: {fileID: 8899696337967424923, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: browser
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8899696337967424923, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: webDriverDirectory
value: Assets\
objectReference: {fileID: 0}
- target: {fileID: 8987662522597341863, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: mockMode
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8987662522597341863, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: insertCoinCaller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ PrefabInstance:
propertyPath: mockMode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8987662522597341863, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: enableLogs
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8987662522597341863, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: insertCoinCaller
value:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void Update()
{
Debug.Log("Space Down");
_playroomKit.RpcCall("one", "69420", PlayroomKit.RpcMode.ALL);
_playroomKit.RpcCall("two", "2", PlayroomKit.RpcMode.ALL);
// _playroomKit.RpcCall("two", "2", PlayroomKit.RpcMode.ALL);
}

var myPlayer = _playroomKit.MyPlayer();
Expand All @@ -77,7 +77,6 @@ private void Update()
if (playerGameObjects[i] != null)
{
playerGameObjects[i].GetComponent<Transform>().SetPositionAndRotation(pos, rotate);

playerGameObjects[i].GetComponent<Renderer>().material.color = color;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ private void AddPlayer(PlayroomKit.Player player)
}


[MonoPInvokeCallback(typeof(Action<string>))]
private void RemovePlayer(string playerID)
{
if (PlayerDict.TryGetValue(playerID, out var player))
Expand Down Expand Up @@ -239,15 +238,15 @@ public void HandleValueChange(int index)

public void RegisterRpcShoot()
{
_playroomKit.RpcRegister("ShootLaser", HandleScoreUpdate, "You shot a bullet!");
_playroomKit.RpcRegister("ShootLaser", HandleScoreUpdate);

Debug.Log("Shoot function registered");
logsText.text = "ShootLaser RPC registered";
}

private void HandleScoreUpdate(string data, string caller)
{
var player = _playroomKit.GetPlayer(caller);
Debug.Log($"Caller: {caller}, Player Name: {player?.GetProfile().name}, Data: {data}");
Debug.LogWarning("Handle Score Called");

if (PlayerDict.TryGetValue(caller, out var playerObj))
{
Expand All @@ -274,6 +273,7 @@ public void ShootLaser()
var myPlayer = _playroomKit.MyPlayer();
var index = players.IndexOf(myPlayer);
score = playerGameObjects[index].GetComponent<Laser>().ShootLaser(score);

_playroomKit.RpcCall("ShootLaser", score, PlayroomKit.RpcMode.ALL,
() =>
{
Expand Down
144 changes: 74 additions & 70 deletions Assets/PlayroomKit/Examples/package-showcase/showcase.unity
Original file line number Diff line number Diff line change
Expand Up @@ -6771,6 +6771,79 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1826344565}
m_CullTransparentMesh: 1
--- !u!1001 &1855243287
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1824217503633254899, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_Name
value: PlayroomMockManager
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalPosition.x
value: -0.3
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8899696337967424923, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: webDriverDirectory
value: Assets\
objectReference: {fileID: 0}
- target: {fileID: 8987662522597341863, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: mockMode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8987662522597341863, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: enableLogs
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8987662522597341863, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: insertCoinCaller
value:
objectReference: {fileID: 893908560}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
--- !u!1 &1883683081
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -7715,75 +7788,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2143370850}
m_CullTransparentMesh: 1
--- !u!1001 &2854658873105489201
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1824217503633254899, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_Name
value: PlayroomMockManager
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalPosition.x
value: -0.3
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4611920177403363027, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8899696337967424923, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: webDriverDirectory
value: Assets\
objectReference: {fileID: 0}
- target: {fileID: 8987662522597341863, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: mockMode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8987662522597341863, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
propertyPath: insertCoinCaller
value:
objectReference: {fileID: 893908560}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
Expand All @@ -7795,4 +7799,4 @@ SceneRoots:
- {fileID: 417229588}
- {fileID: 1643951926}
- {fileID: 181053975}
- {fileID: 2854658873105489201}
- {fileID: 1855243287}
3 changes: 0 additions & 3 deletions Assets/PlayroomKit/PlayroomKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,14 @@ public PlayroomKit()
_rpc = new RPC(this);
#elif UNITY_EDITOR


switch (CurrentMockMode)
{
case MockModeSelector.Local:
Debug.Log("Starting playroom in Local Mock Mode");
_playroomService = new LocalMockPlayroomService();
_rpc = new RPCLocal();
break;

case MockModeSelector.Browser:
Debug.Log("Starting playroom in Browser Mock Mode");
_playroomService = new BrowserMockService();
_rpc = new BrowserMockRPC();
break;
Expand Down
15 changes: 1 addition & 14 deletions Assets/PlayroomKit/Prefabs/PlayroomMockManager.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ GameObject:
m_Component:
- component: {fileID: 4611920177403363027}
- component: {fileID: 8987662522597341863}
- component: {fileID: 7325353642485059119}
m_Layer: 0
m_Name: PlayroomMockManager
m_TagString: EditorOnly
Expand Down Expand Up @@ -49,19 +48,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
mockMode: 1
insertCoinCaller: {fileID: 0}
--- !u!114 &7325353642485059119
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1824217503633254899}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 37df37ffbaed24d5f858db19670affdf, type: 3}
m_Name:
m_EditorClassIdentifier:
logToggle: {fileID: 0}
enableLogs: 0
--- !u!1 &5935941862803782869
GameObject:
m_ObjectHideFlags: 0
Expand Down
Loading

0 comments on commit 38311e1

Please sign in to comment.