Skip to content

Commit

Permalink
Merge pull request #70 from SideQuestVR/dev-merge
Browse files Browse the repository at this point in the history
Dev merge
mikeskydev authored Nov 18, 2024
2 parents 6224098 + ebec7ad commit 15aac66
Showing 28 changed files with 2,097 additions and 416 deletions.
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Contribution Guidelines

[Back to documentation](/README.md?id=banter-sdk-contributions)

### Introduction

You can contribute by submitting your own components to be added to the Banter SDK so you can use them in your spaces. There are two types of components
55 changes: 55 additions & 0 deletions Editor/Components/BanterGrabHandleEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
using Banter.SDK;

namespace Banter.SDKEditor
{
[CustomEditor(typeof(BanterGrabHandle))]
public class BanterGrabHandleEditor : Editor
{
void OnEnable()
{
if (target is BanterGrabHandle)
{
var script = (BanterGrabHandle)target;
// script.gameObject.GetComponent<MeshFilter>().hideFlags = HideFlags.HideInInspector;
var path = AssetDatabase.GetAssetPath(script);
}
}
public override bool UseDefaultMargins() => false;
public override VisualElement CreateInspectorGUI()
{
var script = (BanterGrabHandle)target;
Editor editor = Editor.CreateEditor(script);
// script.gameObject.GetComponent<MeshFilter>().hideFlags = HideFlags.HideInInspector;
VisualElement myInspector = new VisualElement();

var _mainWindowStyleSheet = Resources.Load<StyleSheet>("BanterCustomInspector");
myInspector.styleSheets.Add(_mainWindowStyleSheet);

var title = new Label("PROPERTIES SEEN BY JS");
title.style.fontSize = 14;
myInspector.Add(title);
var seeFields = new Label("grabType, grabRadius, ");
seeFields.style.unityFontStyleAndWeight = FontStyle.Bold;
seeFields.style.flexWrap = Wrap.Wrap;
seeFields.style.whiteSpace = WhiteSpace.Normal;
seeFields.style.marginBottom = 10;
seeFields.style.marginTop = 10;
seeFields.style.color = Color.gray;
myInspector.Add(seeFields);

//#if BANTER_EDITOR
var foldout = new Foldout();
foldout.text = "Available Properties";
IMGUIContainer inspectorIMGUI = new IMGUIContainer(() => { editor.OnInspectorGUI(); });
foldout.value = false;
foldout.Add(inspectorIMGUI);
myInspector.Add(foldout);
//#endif

return myInspector;
}
}
}
11 changes: 11 additions & 0 deletions Editor/Components/BanterGrabHandleEditor.cs.meta

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

55 changes: 55 additions & 0 deletions Editor/Components/BanterHeldEventsEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
using Banter.SDK;

namespace Banter.SDKEditor
{
[CustomEditor(typeof(BanterHeldEvents))]
public class BanterHeldEventsEditor : Editor
{
void OnEnable()
{
if (target is BanterHeldEvents)
{
var script = (BanterHeldEvents)target;
// script.gameObject.GetComponent<MeshFilter>().hideFlags = HideFlags.HideInInspector;
var path = AssetDatabase.GetAssetPath(script);
}
}
public override bool UseDefaultMargins() => false;
public override VisualElement CreateInspectorGUI()
{
var script = (BanterHeldEvents)target;
Editor editor = Editor.CreateEditor(script);
// script.gameObject.GetComponent<MeshFilter>().hideFlags = HideFlags.HideInInspector;
VisualElement myInspector = new VisualElement();

var _mainWindowStyleSheet = Resources.Load<StyleSheet>("BanterCustomInspector");
myInspector.styleSheets.Add(_mainWindowStyleSheet);

var title = new Label("PROPERTIES SEEN BY JS");
title.style.fontSize = 14;
myInspector.Add(title);
var seeFields = new Label("sensitivity, fireRate, auto, blockThumbstick, blockPrimary, blockSecondary, blockThumbstickClick, ");
seeFields.style.unityFontStyleAndWeight = FontStyle.Bold;
seeFields.style.flexWrap = Wrap.Wrap;
seeFields.style.whiteSpace = WhiteSpace.Normal;
seeFields.style.marginBottom = 10;
seeFields.style.marginTop = 10;
seeFields.style.color = Color.gray;
myInspector.Add(seeFields);

//#if BANTER_EDITOR
var foldout = new Foldout();
foldout.text = "Available Properties";
IMGUIContainer inspectorIMGUI = new IMGUIContainer(() => { editor.OnInspectorGUI(); });
foldout.value = false;
foldout.Add(inspectorIMGUI);
myInspector.Add(foldout);
//#endif

return myInspector;
}
}
}
11 changes: 11 additions & 0 deletions Editor/Components/BanterHeldEventsEditor.cs.meta

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

44 changes: 44 additions & 0 deletions Editor/Components/BanterWorldObjectEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
using Banter.SDK;

namespace Banter.SDKEditor
{
[CustomEditor(typeof(BanterWorldObject))]
public class BanterWorldObjectEditor : Editor
{
void OnEnable()
{
if (target is BanterWorldObject)
{
var script = (BanterWorldObject)target;
// script.gameObject.GetComponent<MeshFilter>().hideFlags = HideFlags.HideInInspector;
var path = AssetDatabase.GetAssetPath(script);
}
}
public override bool UseDefaultMargins() => false;
public override VisualElement CreateInspectorGUI()
{
var script = (BanterWorldObject)target;
Editor editor = Editor.CreateEditor(script);
// script.gameObject.GetComponent<MeshFilter>().hideFlags = HideFlags.HideInInspector;
VisualElement myInspector = new VisualElement();

var _mainWindowStyleSheet = Resources.Load<StyleSheet>("BanterCustomInspector");
myInspector.styleSheets.Add(_mainWindowStyleSheet);


//#if BANTER_EDITOR
var foldout = new Foldout();
foldout.text = "Available Properties";
IMGUIContainer inspectorIMGUI = new IMGUIContainer(() => { editor.OnInspectorGUI(); });
foldout.value = false;
foldout.Add(inspectorIMGUI);
myInspector.Add(foldout);
//#endif

return myInspector;
}
}
}
11 changes: 11 additions & 0 deletions Editor/Components/BanterWorldObjectEditor.cs.meta

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

6 changes: 3 additions & 3 deletions Editor/InitialiseOnLoad.cs
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ public static void SetupLayersAndTags()
if (ulayer == null || ulayer.stringValue != layer.Value)
{
isMissing = true;
missingLayers.Add("L" + layer.Key + ": " + layer.Value);
missingLayers.Add(layer.Value);
}
}

@@ -124,11 +124,11 @@ public static void SetupLayersAndTags()
if (utag == null || utag.stringValue != tag.Value)
{
isMissing = true;
missingTags.Add("T" + tag.Key + ": " + tag.Value);
missingTags.Add(tag.Value);
}
}

if (isMissing && EditorUtility.DisplayDialog("Missing Banter Layers/Tags", "Do you want to setup Banter layers and tags automatically?\nThese are required when using Banter specific features.\n Please back up your project first!" + (missingLayers.Count > 0 ? "\nLayers:\n" : "") + string.Join("\n", missingLayers) + (missingTags.Count > 0 ? "\nTags:\n" : "") + string.Join("\n", missingTags), "Yes", "No"))
if (isMissing && EditorUtility.DisplayDialog("Missing Banter Layers/Tags", "Do you want to setup Banter layers and tags automatically?\nThese are required when using Banter specific features.\n Please back up your project first!" + (missingLayers.Count > 0 ? "\n\nLayers:\n" : "") + string.Join(", ", missingLayers) + (missingTags.Count > 0 ? "\n\nTags:\n" : "") + string.Join(", ", missingTags), "Yes", "No"))
{
foreach (var layer in layersToAdd)
{
839 changes: 839 additions & 0 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.

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,10 @@

Here you will find all the information you need to start building spaces and avatars in Banter. You should also [join our discord server](https://discord.gg/bantaverse) to interact with others interested in building spaces in Banter.

## Avatar Creation

We have a new avatar system out in beta, including an extension for blender to make building avatars as easy as possible.

<details><summary>Click Here For More Info</summary>

Get your avatar ready for the Bantaverse. This plugin will help you set up your avatars with the correct LOD levels, prepare materials, and upload directly to your Banter account.
@@ -115,7 +119,7 @@ For more guides and tutorials, please see some of these third party resources.
Since our SDK is going to be open source, there are two ways that new functionality can be added.
The first way is that we add functionality when we need it in Banter, which makes sense. The second is if
a creator wants to add functionality to Banter. In that case we have a process for accepting contributions.
To find out more, check out our [Contribution Guidelines](/CONTRIBUTING) page.
To find out more, check out our [Contribution Guidelines](/CONTRIBUTING.md) page.
<!--
## Avatar Creation
4 changes: 2 additions & 2 deletions Runtime/Objects/Loading/LoadingCage.mat
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DisolveGuide:
m_Texture: {fileID: 2800000, guid: 912443672bb71bc43a5669da1a66accd, type: 3}
m_Texture: {fileID: 2800000, guid: cda43b350f1657e428c83522b9b98cb4, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
@@ -76,7 +76,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ThumbDisolveGuide:
m_Texture: {fileID: 2800000, guid: 912443672bb71bc43a5669da1a66accd, type: 3}
m_Texture: {fileID: 2800000, guid: cda43b350f1657e428c83522b9b98cb4, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ThumbMask:
847 changes: 452 additions & 395 deletions Runtime/Resources/Prefabs/BanterPlayer.prefab

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions Runtime/Scripts/Character/BanterPlayerEvents.cs
Original file line number Diff line number Diff line change
@@ -7,23 +7,27 @@

public class BanterPlayerEvents : MonoBehaviour
{
[Foldout("Click")]
[Foldout("Click", true)]
public UnityEvent<Vector3, Vector3> onClick;

[Foldout("Grab", true)]

[Foldout("Grabbing", true)]
public UnityEvent<Vector3, HandSide> onGrab;
public UnityEvent<HandSide> onRelease;

[Foldout("Trigger", true)]
public float triggerThreshold = 0.5f;
public UnityEvent<HandSide> onTrigger;
public UnityEvent<HandSide> onTriggerPress;
public UnityEvent<float, HandSide> onTrigger;

[Foldout("Thumbstick", true)]
public UnityEvent<Vector2, HandSide> onThumbstick;
public UnityEvent<HandSide> onThumbstickClickDown;
public UnityEvent<HandSide> onThumbstickClickUp;

// [Foldout("Keyboard Keys", true)]
// public UnityEvent<KeyCode> onKeyPress;
// public UnityEvent<KeyCode> onKeyDown;
// public UnityEvent<KeyCode> onKeyUp;

// [Foldout("Controller Buttons", true)]
// public UnityEvent<ButtonType> onButtonPress;
// public UnityEvent<ButtonType> onButtonRelease;
[Foldout("Primary/Secondary", true)]
public UnityEvent<HandSide> onPrimaryDown;
public UnityEvent<HandSide> onPrimaryup;
public UnityEvent<HandSide> onSecondaryDown;
public UnityEvent<HandSide> onSecondaryUp;
}
Original file line number Diff line number Diff line change
@@ -29,6 +29,10 @@ public static BanterComponentBase CreateComponent(GameObject gameObject, Compone
return gameObject.AddComponent<BanterGeometry>();
case ComponentType.BanterGLTF:
return gameObject.AddComponent<BanterGLTF>();
case ComponentType.BanterGrabHandle:
return gameObject.AddComponent<BanterGrabHandle>();
case ComponentType.BanterHeldEvents:
return gameObject.AddComponent<BanterHeldEvents>();
case ComponentType.BanterInvertedMesh:
return gameObject.AddComponent<BanterInvertedMesh>();
case ComponentType.BanterKitItem:
@@ -57,6 +61,8 @@ public static BanterComponentBase CreateComponent(GameObject gameObject, Compone
return gameObject.AddComponent<BanterTransform>();
case ComponentType.BanterVideoPlayer:
return gameObject.AddComponent<BanterVideoPlayer>();
case ComponentType.BanterWorldObject:
return gameObject.AddComponent<BanterWorldObject>();
default:
return null;
}
3 changes: 3 additions & 0 deletions Runtime/Scripts/Scene/BanterComponent/BanterComponentNames.cs
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@ public enum ComponentType
ConfigurableJoint,
BanterGeometry,
BanterGLTF,
BanterGrabHandle,
BanterHeldEvents,
BanterInvertedMesh,
BanterKitItem,
BanterMaterial,
@@ -27,5 +29,6 @@ public enum ComponentType
BanterText,
Transform,
BanterVideoPlayer,
BanterWorldObject,
}
}
Original file line number Diff line number Diff line change
@@ -84,6 +84,15 @@ public enum PropertyName
slippery,
climbable,
legacyRotate,
grabType,
grabRadius,
sensitivity,
fireRate,
auto,
blockThumbstick,
blockPrimary,
blockSecondary,
blockThumbstickClick,
path,
shaderName,
texture,
2 changes: 2 additions & 0 deletions Runtime/Scripts/Scene/BanterScene.cs
Original file line number Diff line number Diff line change
@@ -1255,6 +1255,8 @@ public async Task ResetScene()
{
events.OnSceneReset.Invoke();
});
// This seems to be a bug in 2022, hard crash without this line.
GameObject.FindObjectsOfType<Cloth>().ToList().ForEach(x => GameObject.Destroy(x));
await Resources.UnloadUnusedAssets();
}
catch (Exception e)
4 changes: 4 additions & 0 deletions Runtime/Scripts/Scene/BanterSceneEvents.cs
Original file line number Diff line number Diff line change
@@ -44,6 +44,10 @@ public class BanterSceneEvents
public UnityEvent OnSceneReset = new UnityEvent();
public UnityEvent<string> OnLoadUrl = new UnityEvent<string>();
public UnityEvent<string, string> OnJsCallbackRecieved = new UnityEvent<string, string>();
public UnityEvent<BanterHeldEvents> OnHeldEvents = new UnityEvent<BanterHeldEvents>();
public UnityEvent<BanterGrabHandle> OnGrabHandle = new UnityEvent<BanterGrabHandle>();
public UnityEvent<BanterWorldObject> OnWorldObject = new UnityEvent<BanterWorldObject>();
public UnityEvent<BanterWorldObject> OnWorldObjectCollectColliders = new UnityEvent<BanterWorldObject>();

#region Legacy stuff

2 changes: 1 addition & 1 deletion Runtime/Scripts/Scene/Components/BanterAttachedObject.cs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ public class BanterAttachedObject : BanterComponentBase
{
[See(initial = "")] public string uid;
[See(initial = "0,0,0")] public Vector3 attachmentPosition;
[See(initial = "0,0,0,1")] public Quaternion attachmentRotation;
[See(initial = "0,0,0,1")] public Quaternion attachmentRotation = Quaternion.identity;
[See(initial = "0")] public AttachmentType attachmentType;
[See(initial = "0")] public AvatarAttachmentType avatarAttachmentType;
[See(initial = "0")] public AvatarBoneName avatarAttachmentPoint;
150 changes: 150 additions & 0 deletions Runtime/Scripts/Scene/Components/BanterGrabHandle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum BanterGrabType
{
Point,
Cylinder,
Ball,
Soft
}
namespace Banter.SDK
{

[RequireComponent(typeof(BanterObjectId))]
[WatchComponent]
public class BanterGrabHandle : BanterComponentBase
{
[See(initial = "0")] public BanterGrabType grabType;
[See(initial = "0.01")] public float grabRadius = 0.01f;
public override void DestroyStuff()
{
// throw new NotImplementedException();
}

public override void StartStuff()
{
scene.events.OnGrabHandle.Invoke(this);
// throw new NotImplementedException();
}

public void UpdateCallback(List<PropertyName> changedProperties)
{
// SetupPhysicMaterial(changedProperties);
}
// BANTER COMPILED CODE
BanterScene scene;
bool alreadyStarted = false;
void Start()
{
Init();
StartStuff();
}

public override void ReSetup()
{
List<PropertyName> changedProperties = new List<PropertyName>() { PropertyName.grabType, PropertyName.grabRadius, };
UpdateCallback(changedProperties);
}

public override void Init(List<object> constructorProperties = null)
{
scene = BanterScene.Instance();
if (alreadyStarted) { return; }
alreadyStarted = true;
scene.RegisterBanterMonoscript(gameObject.GetInstanceID(), GetInstanceID(), ComponentType.BanterGrabHandle);


oid = gameObject.GetInstanceID();
cid = GetInstanceID();

if (constructorProperties != null)
{
Deserialise(constructorProperties);
}

SyncProperties(true);

}

void Awake()
{
BanterScene.Instance().RegisterComponentOnMainThread(gameObject, this);
}

void OnDestroy()
{
scene.UnregisterComponentOnMainThread(gameObject, this);

DestroyStuff();
}

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

public override void Deserialise(List<object> values)
{
List<PropertyName> changedProperties = new List<PropertyName>();
for (int i = 0; i < values.Count; i++)
{
if (values[i] is BanterInt)
{
var valgrabType = (BanterInt)values[i];
if (valgrabType.n == PropertyName.grabType)
{
grabType = (BanterGrabType)valgrabType.x;
changedProperties.Add(PropertyName.grabType);
}
}
if (values[i] is BanterFloat)
{
var valgrabRadius = (BanterFloat)values[i];
if (valgrabRadius.n == PropertyName.grabRadius)
{
grabRadius = valgrabRadius.x;
changedProperties.Add(PropertyName.grabRadius);
}
}
}
if (values.Count > 0) { UpdateCallback(changedProperties); }
}

public override void SyncProperties(bool force = false, Action callback = null)
{
var updates = new List<BanterComponentPropertyUpdate>();
if (force)
{
updates.Add(new BanterComponentPropertyUpdate()
{
name = PropertyName.grabType,
type = PropertyType.Int,
value = grabType,
componentType = ComponentType.BanterGrabHandle,
oid = oid,
cid = cid
});
}
if (force)
{
updates.Add(new BanterComponentPropertyUpdate()
{
name = PropertyName.grabRadius,
type = PropertyType.Float,
value = grabRadius,
componentType = ComponentType.BanterGrabHandle,
oid = oid,
cid = cid
});
}
scene.SetFromUnityProperties(updates, callback);
}

public override void WatchProperties(PropertyName[] properties)
{
}
// END BANTER COMPILED CODE
}
}
11 changes: 11 additions & 0 deletions Runtime/Scripts/Scene/Components/BanterGrabHandle.cs.meta
261 changes: 261 additions & 0 deletions Runtime/Scripts/Scene/Components/BanterHeldEvents.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Pixeye.Unity;
using UnityEngine;
using UnityEngine.Events;

namespace Banter.SDK
{

[RequireComponent(typeof(BanterObjectId))]
[WatchComponent]
public class BanterHeldEvents : BanterComponentBase
{

[See(initial = "0.5")] public float sensitivity = 0.5f;
[See(initial = "0.1")] public float fireRate = 0.1f;
[See(initial = "false")] public bool auto = false;
[See(initial = "false")] public bool blockThumbstick = false;
[See(initial = "false")] public bool blockPrimary = false;
[See(initial = "false")] public bool blockSecondary = false;
[See(initial = "false")] public bool blockThumbstickClick = false;

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


public override void StartStuff()
{
if (!gameObject.GetComponent<BanterPlayerEvents>())
gameObject.AddComponent<BanterPlayerEvents>();

scene.events.OnHeldEvents.Invoke(this);
}

public void UpdateCallback(List<PropertyName> changedProperties)
{
// SetupPhysicMaterial(changedProperties);
}
// BANTER COMPILED CODE
BanterScene scene;
bool alreadyStarted = false;
void Start()
{
Init();
StartStuff();
}

public override void ReSetup()
{
List<PropertyName> changedProperties = new List<PropertyName>() { PropertyName.sensitivity, PropertyName.fireRate, PropertyName.auto, PropertyName.blockThumbstick, PropertyName.blockPrimary, PropertyName.blockSecondary, PropertyName.blockThumbstickClick, };
UpdateCallback(changedProperties);
}

public override void Init(List<object> constructorProperties = null)
{
scene = BanterScene.Instance();
if (alreadyStarted) { return; }
alreadyStarted = true;
scene.RegisterBanterMonoscript(gameObject.GetInstanceID(), GetInstanceID(), ComponentType.BanterHeldEvents);


oid = gameObject.GetInstanceID();
cid = GetInstanceID();

if (constructorProperties != null)
{
Deserialise(constructorProperties);
}

SyncProperties(true);

}

void Awake()
{
BanterScene.Instance().RegisterComponentOnMainThread(gameObject, this);
}

void OnDestroy()
{
scene.UnregisterComponentOnMainThread(gameObject, this);

DestroyStuff();
}

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

public override void Deserialise(List<object> values)
{
List<PropertyName> changedProperties = new List<PropertyName>();
for (int i = 0; i < values.Count; i++)
{
if (values[i] is BanterFloat)
{
var valsensitivity = (BanterFloat)values[i];
if (valsensitivity.n == PropertyName.sensitivity)
{
sensitivity = valsensitivity.x;
changedProperties.Add(PropertyName.sensitivity);
}
}
if (values[i] is BanterFloat)
{
var valfireRate = (BanterFloat)values[i];
if (valfireRate.n == PropertyName.fireRate)
{
fireRate = valfireRate.x;
changedProperties.Add(PropertyName.fireRate);
}
}
if (values[i] is BanterBool)
{
var valauto = (BanterBool)values[i];
if (valauto.n == PropertyName.auto)
{
auto = valauto.x;
changedProperties.Add(PropertyName.auto);
}
}
if (values[i] is BanterBool)
{
var valblockThumbstick = (BanterBool)values[i];
if (valblockThumbstick.n == PropertyName.blockThumbstick)
{
blockThumbstick = valblockThumbstick.x;
changedProperties.Add(PropertyName.blockThumbstick);
}
}
if (values[i] is BanterBool)
{
var valblockPrimary = (BanterBool)values[i];
if (valblockPrimary.n == PropertyName.blockPrimary)
{
blockPrimary = valblockPrimary.x;
changedProperties.Add(PropertyName.blockPrimary);
}
}
if (values[i] is BanterBool)
{
var valblockSecondary = (BanterBool)values[i];
if (valblockSecondary.n == PropertyName.blockSecondary)
{
blockSecondary = valblockSecondary.x;
changedProperties.Add(PropertyName.blockSecondary);
}
}
if (values[i] is BanterBool)
{
var valblockThumbstickClick = (BanterBool)values[i];
if (valblockThumbstickClick.n == PropertyName.blockThumbstickClick)
{
blockThumbstickClick = valblockThumbstickClick.x;
changedProperties.Add(PropertyName.blockThumbstickClick);
}
}
}
if (values.Count > 0) { UpdateCallback(changedProperties); }
}

public override void SyncProperties(bool force = false, Action callback = null)
{
var updates = new List<BanterComponentPropertyUpdate>();
if (force)
{
updates.Add(new BanterComponentPropertyUpdate()
{
name = PropertyName.sensitivity,
type = PropertyType.Float,
value = sensitivity,
componentType = ComponentType.BanterHeldEvents,
oid = oid,
cid = cid
});
}
if (force)
{
updates.Add(new BanterComponentPropertyUpdate()
{
name = PropertyName.fireRate,
type = PropertyType.Float,
value = fireRate,
componentType = ComponentType.BanterHeldEvents,
oid = oid,
cid = cid
});
}
if (force)
{
updates.Add(new BanterComponentPropertyUpdate()
{
name = PropertyName.auto,
type = PropertyType.Bool,
value = auto,
componentType = ComponentType.BanterHeldEvents,
oid = oid,
cid = cid
});
}
if (force)
{
updates.Add(new BanterComponentPropertyUpdate()
{
name = PropertyName.blockThumbstick,
type = PropertyType.Bool,
value = blockThumbstick,
componentType = ComponentType.BanterHeldEvents,
oid = oid,
cid = cid
});
}
if (force)
{
updates.Add(new BanterComponentPropertyUpdate()
{
name = PropertyName.blockPrimary,
type = PropertyType.Bool,
value = blockPrimary,
componentType = ComponentType.BanterHeldEvents,
oid = oid,
cid = cid
});
}
if (force)
{
updates.Add(new BanterComponentPropertyUpdate()
{
name = PropertyName.blockSecondary,
type = PropertyType.Bool,
value = blockSecondary,
componentType = ComponentType.BanterHeldEvents,
oid = oid,
cid = cid
});
}
if (force)
{
updates.Add(new BanterComponentPropertyUpdate()
{
name = PropertyName.blockThumbstickClick,
type = PropertyType.Bool,
value = blockThumbstickClick,
componentType = ComponentType.BanterHeldEvents,
oid = oid,
cid = cid
});
}
scene.SetFromUnityProperties(updates, callback);
}

public override void WatchProperties(PropertyName[] properties)
{
}
// END BANTER COMPILED CODE
}
}
11 changes: 11 additions & 0 deletions Runtime/Scripts/Scene/Components/BanterHeldEvents.cs.meta
2 changes: 1 addition & 1 deletion Runtime/Scripts/Scene/Components/BanterMirror.cs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ Add a mirror to the object.
public class BanterMirror : BanterComponentBase
{
[See(initial = "1024")] public int renderTextureSize = 1024;
[See(initial = "1024")] public int cameraClear = 1;
[See(initial = "1")] public int cameraClear = 1;
[See(initial = "'#000000'")] public string backgroundColor = "#000000";

VRPortalRenderer _renderer;
118 changes: 118 additions & 0 deletions Runtime/Scripts/Scene/Components/BanterWorldObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Banter.SDK
{

[RequireComponent(typeof(BanterObjectId))]
[WatchComponent]
public class BanterWorldObject : BanterComponentBase
{
[Method]
public void _CollectColliders()
{
scene.events.OnWorldObjectCollectColliders.Invoke(this);
}

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

public override void StartStuff()
{
scene.events.OnWorldObject.Invoke(this);
}

public void UpdateCallback(List<PropertyName> changedProperties)
{
// SetupPhysicMaterial(changedProperties);
}
// BANTER COMPILED CODE
BanterScene scene;
bool alreadyStarted = false;
void Start()
{
Init();
StartStuff();
}

public override void ReSetup()
{
List<PropertyName> changedProperties = new List<PropertyName>() { };
UpdateCallback(changedProperties);
}

public override void Init(List<object> constructorProperties = null)
{
scene = BanterScene.Instance();
if (alreadyStarted) { return; }
alreadyStarted = true;
scene.RegisterBanterMonoscript(gameObject.GetInstanceID(), GetInstanceID(), ComponentType.BanterWorldObject);


oid = gameObject.GetInstanceID();
cid = GetInstanceID();

if (constructorProperties != null)
{
Deserialise(constructorProperties);
}

SyncProperties(true);

}

void Awake()
{
BanterScene.Instance().RegisterComponentOnMainThread(gameObject, this);
}

void OnDestroy()
{
scene.UnregisterComponentOnMainThread(gameObject, this);

DestroyStuff();
}

void CollectColliders()
{
_CollectColliders();
}
public override object CallMethod(string methodName, List<object> parameters)
{

if (methodName == "CollectColliders" && parameters.Count == 0)
{
CollectColliders();
return null;
}
else
{
return null;
}
}

public override void Deserialise(List<object> values)
{
List<PropertyName> changedProperties = new List<PropertyName>();
for (int i = 0; i < values.Count; i++)
{
}
if (values.Count > 0) { UpdateCallback(changedProperties); }
}

public override void SyncProperties(bool force = false, Action callback = null)
{
var updates = new List<BanterComponentPropertyUpdate>();
scene.SetFromUnityProperties(updates, callback);
}

public override void WatchProperties(PropertyName[] properties)
{
}
// END BANTER COMPILED CODE
}
}
11 changes: 11 additions & 0 deletions Runtime/Scripts/Scene/Components/BanterWorldObject.cs.meta
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.sidequest.banter",
"version": "2.2.0",
"version": "2.2.1",
"displayName": "Banter SDK",
"description": "This Module contains the Banter SDK used for building spaces in the bantaverse.",
"unity": "2022.3",

0 comments on commit 15aac66

Please sign in to comment.