Skip to content

Commit

Permalink
Merge pull request #110 from SideQuestVR/dev
Browse files Browse the repository at this point in the history
2.9.0
  • Loading branch information
Ladypoly authored Jan 30, 2025
2 parents 74584ee + 1ee1022 commit faac922
Show file tree
Hide file tree
Showing 146 changed files with 30,214 additions and 21,433 deletions.
2 changes: 1 addition & 1 deletion Editor/Components/BanterSyncedObjectEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override VisualElement CreateInspectorGUI()
var title = new Label("PROPERTIES SEEN BY JS");
title.style.fontSize = 14;
myInspector.Add(title);
var seeFields = new Label("syncPosition, syncRotation, takeOwnershipOnCollision, takeOwnershipOnGrab, kinematicIfNotOwned, doIOwn, ");
var seeFields = new Label("syncPosition, syncRotation, takeOwnershipOnCollision, takeOwnershipOnGrab, kinematicIfNotOwned, ");
seeFields.style.unityFontStyleAndWeight = FontStyle.Bold;
seeFields.style.flexWrap = Wrap.Wrap;
seeFields.style.whiteSpace = WhiteSpace.Normal;
Expand Down
4 changes: 2 additions & 2 deletions Editor/Scripts/VisualScripting/VsNodeGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,10 @@ private static string SetJSONArrayValueHelper(this string target, string arrayCo
typeof(UnityEngine.AI.ObstacleAvoidanceType),
typeof(UnityEngine.AI.OffMeshLinkType),

// Banter
// Banter classes that aren't MonoBehaviours
// See AotPreBuilder._allowedBanterTypes for the MBs
typeof(Banter.SDK.BanterUser),
typeof(Banter.SDK.BanterAttachment),
typeof(Banter.SDK.BanterAttachedObject),
};
}
}
Expand Down
1,377 changes: 1,016 additions & 361 deletions Editor/Scripts/VisualScripting/VsStubsAllowed.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Editor/banter-link/inject.txt

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Runtime/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System.Runtime.CompilerServices;

// Anything in the SDK marked internal can't be seen by main project without this line
// Currently pointed at codegen variables to avoid requirement, but may need in future so keeping around.

// Main banter project is just using the generic assembly? TODO
// [assembly: InternalsVisibleTo("Assembly-CSharp")]
11 changes: 11 additions & 0 deletions Runtime/AssemblyInfo.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Runtime/Scripts/BanterLink/BanterLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ void ParseRequest(string msg, int id, string full)
{
scene.AiModel(GetMsgData(msg, APICommands.AI_MODEL), id);
}
else if (msg.StartsWith(APICommands.OBJECT_TEX_TO_BASE_64))
{
scene.ObjectTextureToBase64(GetMsgData(msg, APICommands.OBJECT_TEX_TO_BASE_64), id);
}
else if (msg.StartsWith(APICommands.BASE_64_TO_CDN))
{
scene.Base64ToCDN(GetMsgData(msg, APICommands.BASE_64_TO_CDN), id);
Expand Down
1 change: 1 addition & 0 deletions Runtime/Scripts/Models/APICommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class APICommands
public const string AI_IMAGE = "!aiimg!";
public const string AI_MODEL = "!aiglb!";
public const string BASE_64_TO_CDN = "!b64cdn!";
public const string OBJECT_TEX_TO_BASE_64 = "!objtob64!";
public const string SELECT_FILE = "!sltglb!";
public const string GRAVITY = "!gv!";
public const string TIME_SCALE = "!ts!";
Expand Down
31 changes: 15 additions & 16 deletions Runtime/Scripts/Scene/BanterComponent/BanterComponentBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
Expand All @@ -9,22 +8,22 @@ namespace Banter.SDK
[RequireComponent(typeof(BanterObjectId))]
public abstract class BanterComponentBase : MonoBehaviour
{
public abstract void Deserialise(List<object> values);
public abstract void SyncProperties(bool force, Action callback = null);
public abstract void WatchProperties(PropertyName[] properties);
public abstract void Init(List<object> constructorProperties = null);
public abstract void ReSetup();
public abstract void StartStuff();
public abstract void DestroyStuff();
public abstract object CallMethod(string methodName, List<object> parameters);
[HideInInspector] public UnityEvent<float> progress = new UnityEvent<float>();
[HideInInspector] public UnityEvent<bool, string> loaded = new UnityEvent<bool, string>();
[HideInInspector] public bool _loaded;
[HideInInspector] public float percentage;
[HideInInspector] public int oid;
[HideInInspector] public int cid;
internal abstract void Deserialise(List<object> values);
internal abstract void SyncProperties(bool force, Action callback = null);
internal abstract void WatchProperties(PropertyName[] properties);
internal abstract void Init(List<object> constructorProperties = null);
internal abstract void ReSetup();
internal abstract void StartStuff();
internal abstract void DestroyStuff();
internal abstract object CallMethod(string methodName, List<object> parameters);
[HideInInspector] internal UnityEvent<float> progress { get; private set; } = new UnityEvent<float>();
[HideInInspector] internal UnityEvent<bool, string> loaded { get; private set; } = new UnityEvent<bool, string>();
internal bool _loaded;
internal float percentage;
internal int oid;
internal int cid;

public void SetLoadedIfNot(bool success = true, string message = "Loaded ok.")
protected void SetLoadedIfNot(bool success = true, string message = "Loaded ok.")
{
if (!_loaded)
{
Expand Down
16 changes: 8 additions & 8 deletions Runtime/Scripts/Scene/BanterComponent/UnityComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,42 @@ namespace Banter.SDK
public class UnityComponentBase : BanterComponentBase
{

public override object CallMethod(string methodName, List<object> parameters)
internal override object CallMethod(string methodName, List<object> parameters)
{
throw new System.NotImplementedException();
}

public override void Deserialise(List<object> values)
internal override void Deserialise(List<object> values)
{
throw new System.NotImplementedException();
}

public override void StartStuff()
internal override void StartStuff()
{
// throw new NotImplementedException();
}

public override void DestroyStuff()
internal override void DestroyStuff()
{
// throw new NotImplementedException();
}

public override void Init(List<object> constructorProperties = null)
internal override void Init(List<object> constructorProperties = null)
{
throw new System.NotImplementedException();
}

public override void ReSetup()
internal override void ReSetup()
{
throw new System.NotImplementedException();
}

public override void SyncProperties(bool force, Action callback)
internal override void SyncProperties(bool force, Action callback)
{
throw new System.NotImplementedException();
}

public override void WatchProperties(PropertyName[] properties)
internal override void WatchProperties(PropertyName[] properties)
{
throw new System.NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ public enum PropertyName
takeOwnershipOnCollision,
takeOwnershipOnGrab,
kinematicIfNotOwned,
doIOwn,
text,
horizontalAlignment,
verticalAlignment,
Expand Down
44 changes: 28 additions & 16 deletions Runtime/Scripts/Scene/BanterScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,26 +230,10 @@ public void Destroy()
#region Player Events
public void Release(GameObject obj, HandSide side = HandSide.LEFT)
{
// var interaction = obj.GetComponent<BanterPlayerEvents>();
// if (interaction != null)
// {
// interaction.onRelease.Invoke(side);
// }
// #if BANTER_VISUAL_SCRIPTING
// EventBus.Trigger("OnGrab", new CustomEventArgs(obj.GetInstanceID().ToString(), new object[] { side }));
// #endif
link.OnRelease(obj, side);
}
public void Grab(GameObject obj, Vector3 point, HandSide side = HandSide.LEFT)
{
// var interaction = obj.GetComponent<BanterPlayerEvents>();
// if (interaction != null)
// {
// interaction.onGrab.Invoke(point, side);
// }
// #if BANTER_VISUAL_SCRIPTING
// EventBus.Trigger("OnGrab", new CustomEventArgs(obj.GetInstanceID().ToString(), new object[] { point, side }));
// #endif
link.OnGrab(obj, point, side);
}
public void Click(GameObject obj, Vector3 point, Vector3 normal)
Expand Down Expand Up @@ -364,6 +348,34 @@ public void Base64ToCDN(string msg, int reqId)
UnityMainThreadTaskScheduler.Default.Enqueue(() => events.OnBase64ToCDN.Invoke(parts[0], parts[1]));
link.Send(APICommands.REQUEST_ID + MessageDelimiters.REQUEST_ID + reqId + MessageDelimiters.PRIMARY + APICommands.BASE_64_TO_CDN);
}
public string GameObjectTextureToBase64(GameObject obj, int materialIndex)
{
var renderer = obj.gameObject.GetComponent<Renderer>();
try
{
return Convert.ToBase64String(((Texture2D)renderer.sharedMaterials[materialIndex].mainTexture).EncodeToPNG());
}
catch (Exception e)
{
Debug.LogError(e);
}
return null;
}
public void ObjectTextureToBase64(string msg, int reqId)
{
var parts = msg.Split(MessageDelimiters.PRIMARY);
var obj = GetObjectByBid(parts[0]);
var extra = "null";
if (obj.gameObject != null)
{
var b64 = GameObjectTextureToBase64(obj.gameObject, int.Parse(parts[1]));
if (b64 != null)
{
extra = b64;
}
}
link.Send(APICommands.REQUEST_ID + MessageDelimiters.REQUEST_ID + reqId + MessageDelimiters.PRIMARY + APICommands.OBJECT_TEX_TO_BASE_64 + MessageDelimiters.SECONDARY + extra);
}
public void SelectFile(string msg, int reqId)
{
UnityMainThreadTaskScheduler.Default.Enqueue(() => events.OnSelectFile.Invoke((SelectFileType)int.Parse(msg)));
Expand Down
2 changes: 0 additions & 2 deletions Runtime/Scripts/Scene/BanterSceneEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class BanterSceneEvents
public UnityEvent<BanterAttachment> OnAttachObject = new UnityEvent<BanterAttachment>();
public UnityEvent<BanterAttachment> OnDetachObject = new UnityEvent<BanterAttachment>();
public UnityEvent<BanterSynced, BanterObjectId> OnSyncedObject = new UnityEvent<BanterSynced, BanterObjectId>();
public UnityEvent<BanterSynced, BanterObjectId> OnDoIOwn = new UnityEvent<BanterSynced, BanterObjectId>();
public UnityEvent<BanterSynced, BanterObjectId> OnTakeOwnership = new UnityEvent<BanterSynced, BanterObjectId>();
public UnityEvent<string, string> OnPublicSpaceStateChanged = new UnityEvent<string, string>();
public UnityEvent<string, string> OnProtectedSpaceStateChanged = new UnityEvent<string, string>();
Expand Down Expand Up @@ -111,7 +110,6 @@ public void RemoveAllListeners()
OnSceneReset.RemoveAllListeners();
OnLoadUrl.RemoveAllListeners();
OnJsCallbackRecieved.RemoveAllListeners();
OnDoIOwn.RemoveAllListeners();
OnTakeOwnership.RemoveAllListeners();
OnPlayAvatar.RemoveAllListeners();
OnSyncedObject.RemoveAllListeners();
Expand Down
60 changes: 34 additions & 26 deletions Runtime/Scripts/Scene/Components/BanterAssetBundle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ Load an asset bundle into Banter which contains a scene or a collection of prefa
[WatchComponent]
public class BanterAssetBundle : BanterComponentBase
{
[See(initial = "")] public string windowsUrl = "";
[See(initial = "")] public string osxUrl = "";
[See(initial = "")] public string linuxUrl = "";
[See(initial = "")] public string androidUrl = "";
[See(initial = "")] public string iosUrl = "";
[See(initial = "")] public string vosUrl = "";
[See(initial = "false")] public bool isScene = false;
[See(initial = "false")] public bool legacyShaderFix = false;
[See(initial = "")][SerializeField] internal string windowsUrl = "";
[See(initial = "")][SerializeField] internal string osxUrl = "";
[See(initial = "")][SerializeField] internal string linuxUrl = "";
[See(initial = "")][SerializeField] internal string androidUrl = "";
[See(initial = "")][SerializeField] internal string iosUrl = "";
[See(initial = "")][SerializeField] internal string vosUrl = "";
[See(initial = "false")][SerializeField] internal bool isScene = false;
[See(initial = "false")][SerializeField] internal bool legacyShaderFix = false;
public AssetBundle assetBundle;
List<string> assetPaths;
bool isLoading = false;
public override void StartStuff()
internal override void StartStuff()
{
// _ = SetupBundle();
}
Expand Down Expand Up @@ -183,17 +183,16 @@ private async Task SetupSceneBundle()
{
Destroy(audioListener);
}
// if(!PlatformCompat.Instance.Is2DMode){
// var cam = transform.gameObject.GetComponent<Camera>();
// if(cam != null && cam.CompareTag("MainCamera")) {
// Destroy(cam.gameObject);
// }
// }
var canvas = transform.gameObject.GetComponent<Canvas>();
if (canvas != null)
{
if (canvas.renderMode == RenderMode.WorldSpace)
{
canvas.worldCamera = Camera.main;
}
}
}
}
// sceneParser.CurrentSceneName = sceneName;
// Debug.Log("[AssetBundleComponent] " + sceneParser.CurrentSceneName);
// item.isLoaded = true;
}
}
async Task _Unload()
Expand Down Expand Up @@ -226,12 +225,21 @@ public async Task Unload()
}
}

public override void DestroyStuff() { }
public void UpdateCallback(List<PropertyName> changedProperties)
internal override void DestroyStuff() { }
internal void UpdateCallback(List<PropertyName> changedProperties)
{
_ = SetupBundle();
}
// BANTER COMPILED CODE
public System.String WindowsUrl { get { return windowsUrl; } set { windowsUrl = value; UpdateCallback(new List<PropertyName> { PropertyName.windowsUrl }); } }
public System.String OsxUrl { get { return osxUrl; } set { osxUrl = value; UpdateCallback(new List<PropertyName> { PropertyName.osxUrl }); } }
public System.String LinuxUrl { get { return linuxUrl; } set { linuxUrl = value; UpdateCallback(new List<PropertyName> { PropertyName.linuxUrl }); } }
public System.String AndroidUrl { get { return androidUrl; } set { androidUrl = value; UpdateCallback(new List<PropertyName> { PropertyName.androidUrl }); } }
public System.String IosUrl { get { return iosUrl; } set { iosUrl = value; UpdateCallback(new List<PropertyName> { PropertyName.iosUrl }); } }
public System.String VosUrl { get { return vosUrl; } set { vosUrl = value; UpdateCallback(new List<PropertyName> { PropertyName.vosUrl }); } }
public System.Boolean IsScene { get { return isScene; } set { isScene = value; UpdateCallback(new List<PropertyName> { PropertyName.isScene }); } }
public System.Boolean LegacyShaderFix { get { return legacyShaderFix; } set { legacyShaderFix = value; UpdateCallback(new List<PropertyName> { PropertyName.legacyShaderFix }); } }

BanterScene scene;
bool alreadyStarted = false;
void Start()
Expand All @@ -240,13 +248,13 @@ void Start()
StartStuff();
}

public override void ReSetup()
internal override void ReSetup()
{
List<PropertyName> changedProperties = new List<PropertyName>() { PropertyName.windowsUrl, PropertyName.osxUrl, PropertyName.linuxUrl, PropertyName.androidUrl, PropertyName.iosUrl, PropertyName.vosUrl, PropertyName.isScene, PropertyName.legacyShaderFix, };
UpdateCallback(changedProperties);
}

public override void Init(List<object> constructorProperties = null)
internal override void Init(List<object> constructorProperties = null)
{
scene = BanterScene.Instance();
if (alreadyStarted) { return; }
Expand Down Expand Up @@ -278,12 +286,12 @@ void OnDestroy()
DestroyStuff();
}

public override object CallMethod(string methodName, List<object> parameters)
internal override object CallMethod(string methodName, List<object> parameters)
{
return null;
}

public override void Deserialise(List<object> values)
internal override void Deserialise(List<object> values)
{
List<PropertyName> changedProperties = new List<PropertyName>();
for (int i = 0; i < values.Count; i++)
Expand Down Expand Up @@ -364,7 +372,7 @@ public override void Deserialise(List<object> values)
if (values.Count > 0) { UpdateCallback(changedProperties); }
}

public override void SyncProperties(bool force = false, Action callback = null)
internal override void SyncProperties(bool force = false, Action callback = null)
{
var updates = new List<BanterComponentPropertyUpdate>();
if (force)
Expand Down Expand Up @@ -466,7 +474,7 @@ public override void SyncProperties(bool force = false, Action callback = null)
scene.SetFromUnityProperties(updates, callback);
}

public override void WatchProperties(PropertyName[] properties)
internal override void WatchProperties(PropertyName[] properties)
{
}
// END BANTER COMPILED CODE
Expand Down
Loading

0 comments on commit faac922

Please sign in to comment.