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

[v1.0.0] Release #84

Merged
merged 41 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2953f9f
Udon Toolkit v1.0.0 Preview build
orels1 Feb 13, 2021
ed0cdf3
Switched UniversalAction.cs back to the old `string[]` popups for old…
orels1 Feb 13, 2021
64786d1
fixed float[], int[] Popups
orels1 Feb 13, 2021
e771706
fixed event buttons missing
orels1 Feb 13, 2021
e697eec
Fixed Drag & Drop layout issues
orels1 Feb 18, 2021
42b5451
Added missing attribute stubs to stop breaking builds
orels1 Feb 18, 2021
eed63ac
fixed a drag & drop issue
orels1 Feb 22, 2021
97c2d2f
v1.0 release candidate
orels1 Feb 24, 2021
952f44a
recompiled udon behaviours
orels1 Feb 24, 2021
cfb10f1
Implemented array utils and pagination, closes #67
orels1 Feb 25, 2021
a05cae3
de-duped removal index calculation
orels1 Feb 25, 2021
54bdd46
Added correct mesh for the streamer spot walls and updated the prefab
orels1 Feb 25, 2021
3d032e3
re-introduced custom ListView add methods w/ custom add labels, close…
orels1 Feb 25, 2021
5d46714
added undo button to all primitive fields, closes #21
orels1 Feb 26, 2021
6a4f019
linting fixes
orels1 Feb 26, 2021
efd1471
Updated the camera system to use threshold checks instead of triggers…
orels1 Mar 9, 2021
70b59d8
Updated help messages, cleaned up old properties and updated the demo…
orels1 Mar 9, 2021
1221a2c
Added the Assembly defs, closes #69
orels1 Mar 14, 2021
0e3572b
Added PlayerMovementModifier behaviour, closes #74
orels1 Mar 16, 2021
60bbaeb
updated demo scene meta
orels1 Mar 16, 2021
f5a921e
fixed some field handling errors
orels1 Mar 18, 2021
8aace1f
Added custom attributes sample
orels1 Mar 19, 2021
cf192bc
updated the UniversalAction to avoid upgrade issues
orels1 Mar 19, 2021
a7701c7
Fixed custom attribute examples, closes #77
orels1 Mar 30, 2021
662471a
Fixed the AreaTriggers not resetting the colliders count, fixes #76
orels1 Mar 30, 2021
f1befdc
fixed non-udonBehaviour editor issues
orels1 Mar 30, 2021
60f62e3
Improved AreaTrigger collision settings, fixes #79
orels1 Mar 30, 2021
ed582d5
- Moved to Resource.Load and relative pathing for systems, thanks to …
orels1 Mar 30, 2021
5d36044
removed stale Debug Logs
orels1 Mar 30, 2021
6f42394
added a check for the cache key (if the tab target field is hidden fr…
orels1 Mar 30, 2021
33163e8
Added support for SET/ADD/SUB modes for Float and Int animator fields…
orels1 Apr 7, 2021
8fee1de
Fixed an issue with uninitialized change mode arrays
orels1 Apr 7, 2021
c9b9dc0
- Improved undo reliability
orels1 Apr 14, 2021
653a0bd
Fixed AreaTriggers not performing active checks in PlayerTrigger events
orels1 Apr 16, 2021
30e3751
- Fixed SyncedTrigger.cs
orels1 May 5, 2021
8130447
- Fixed camera sRGB texture
orels1 Jun 29, 2021
97ef0da
- Fixed an issue with avatar colliders breaking area triggers
orels1 Jun 30, 2021
73968eb
Migrated SyncedTrigger to Manual sync
orels1 Jul 9, 2021
9f4f356
Migrated UniversalAction to use delayed events instead of an update loop
orels1 Jul 9, 2021
34c6f9a
enforced manual sync on the SyncedTrigger
orels1 Jul 9, 2021
cefa7b8
v1.0 release prep
orels1 Jul 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
44 changes: 0 additions & 44 deletions Attributes/UTDrawers.cs

This file was deleted.

3 changes: 0 additions & 3 deletions Attributes/UTDrawers.cs.meta

This file was deleted.

2 changes: 1 addition & 1 deletion Controllers.meta → Behaviours.meta

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

2 changes: 1 addition & 1 deletion Legacy/Controllers.meta → Behaviours/Experimental.meta

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

8 changes: 8 additions & 0 deletions Behaviours/Experimental/Program Assets.meta

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

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ MonoBehaviour:
udonAssembly:
assemblyError:
sourceCsScript: {fileID: 11500000, guid: 77779ca10e061984a818064be7eec7b6, type: 3}
behaviourSyncMode: 0
behaviourIDHeapVarName: __refl_const_intnl_udonTypeID
compileErrors: []
hasInteractEvent: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ MonoBehaviour:
udonAssembly:
assemblyError:
sourceCsScript: {fileID: 11500000, guid: 350aaf4438e84bd4d8ce33fbe9662fb9, type: 3}
behaviourSyncMode: 0
behaviourIDHeapVarName: __refl_const_intnl_udonTypeID
compileErrors: []
hasInteractEvent: 0
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
174 changes: 154 additions & 20 deletions Misc/AreaTrigger.cs → Behaviours/Misc/AreaTrigger.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
using System;
using UdonSharp;
using UnityEditor;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
using VRC.Udon.Common.Interfaces;

namespace UdonToolkit {
[OnBeforeEditor("CheckCollisionTab")]
[CustomName("Area Trigger")]
[HelpMessage("It is recommended to put Area Triggers on a MirrorReflection layer unless they need a custom layer.")]
[HelpURL("https://github.com/orels1/UdonToolkit/wiki/Misc-Behaviours#area-trigger")]
[HelpURL("https://ut.orels.sh/v/v1.x/behaviours/misc-behaviours#area-trigger")]
[UdonBehaviourSyncMode(BehaviourSyncMode.NoVariableSync)]
public class AreaTrigger : UdonSharpBehaviour {
[SectionHeader("General")]
[HelpBox("This behaviour requires a trigger collider to be attached to the object", "CheckCollider")]
[UTEditor]
public bool active = true;
public bool oneShot;

private bool CheckCollider() {
var col = gameObject.GetComponent<Collider>();
return col == null || !col.isTrigger;
}

[SectionHeader("Collision Settings")]
[Popup("@collideTargetOptions")]
[OnValueChanged("HandleCollisionTypeChange")]
public int collideTarget;

[NonSerialized] public string[] collideTargetOptions = new[] {
"Objects", "Players"
};

[HelpBox(
"Please use Collide With Local Players and Collide With Remote Players options instead of Player and PlayerLocal layers.",
"PlayerLayerWarnings")]
[HelpBox("It is not recommended to collide with Everything or the Default layer.", "CheckCollisionLayers")]
[HideIf("HideLayerList")]
[UTEditor]
[HideIf("HideCollisionLayers")]
public LayerMask collideWith;


[HideIf("HideCollisionPlayerTargets")]
public bool collideWithLocalPlayers;
[HideIf("HideCollisionPlayerTargets")]
public bool collideWithRemotePlayers;

private bool HideLayerList() {
return collideWithLocalPlayers || collideWithRemotePlayers;
}

#if !COMPILER_UDONSHARP && UNITY_EDITOR
private bool CheckCollisionLayers() {
var check = LayerMask.NameToLayer("Default");
Expand All @@ -46,12 +55,65 @@ private bool PlayerLayerWarnings() {
var playerLocal = LayerMask.NameToLayer("PlayerLocal");
return (collideWith == (collideWith | (1 << player)) || collideWith == (collideWith | (1 << playerLocal)));
}

public void CheckCollisionTab(SerializedObject obj) {
var collideTargetProp = obj.FindProperty("collideTarget");
var collideWithLocalsProp = obj.FindProperty("collideWithLocalPlayers");
var collideWithRemotesProp = obj.FindProperty("collideWithRemotePlayers");
if (collideWithLocalsProp.boolValue || collideWithRemotesProp.boolValue) {
collideTargetProp.intValue = 1;
}
}

private bool HideCollisionLayers() {
return collideTarget == 1;
}

private bool HideCollisionPlayerTargets() {
return collideTarget == 0;
}

public void HandleCollisionTypeChange(SerializedProperty prop) {
var obj = prop.serializedObject;
var collideWithLocalsProp = obj.FindProperty("collideWithLocalPlayers");
var collideWithRemotesProp = obj.FindProperty("collideWithRemotePlayers");
if (prop.intValue == 0) {
collideWithLocalsProp.boolValue = false;
collideWithRemotesProp.boolValue = false;
}
}

public void SelectAccessLevel(SerializedProperty value) {
if (!value.boolValue) return;
switch (value.name) {
case "masterOnly": {
value.serializedObject.FindProperty("ownerOnly").boolValue = false;
break;
}
case "ownerOnly": {
value.serializedObject.FindProperty("masterOnly").boolValue = false;
break;
}
}
}
#endif

[SectionHeader("Access")]
[Horizontal("Access")]
[Toggle]
[OnValueChanged("SelectAccessLevel")]
public bool masterOnly;
[Toggle]
[Horizontal("Access")]
[OnValueChanged("SelectAccessLevel")]
public bool ownerOnly;

[HelpBox("If any names are listed - only those users will be allowed to fire events, as well as the Master/Owner based on the options above")]
public string[] allowedUsers;

[SectionHeader("Udon Events")]
[HelpBox("Do not use Networked option with target All when colliding with Player layer, as it will cause oversync.",
"CheckNetworkedValidity")]
[UTEditor]
public bool networked;
public NetworkEventTarget networkTarget;

Expand All @@ -60,39 +122,44 @@ private bool CheckNetworkedValidity() {
return collideWith == (collideWith | (1 << player)) && networked && networkTarget == NetworkEventTarget.All;
}

[ListView("Enter Events List")] [UTEditor]
[ListView("Enter Events List")]
public UdonSharpBehaviour[] enterTargets;

[ListView("Enter Events List")]
[Popup("behaviour", "@enterTargets", true)]
[UTEditor]
public string[] enterEvents;

[ListView("Exit Events List")] [UTEditor]
[ListView("Exit Events List")]
public UdonSharpBehaviour[] exitTargets;

[ListView("Exit Events List")]
[Popup("behaviour", "@exitTargets", true)]
[UTEditor]
public string[] exitEvents;

private int playerLayer = 9;
private int playerLocalLayer = 10;
private int collidersIn;

[Button("Activate")]
private bool isOwner;
private bool used;

public void Activate() {
active = true;
collidersIn = 0;
}

[Button("Deactivate")]

public void Deactivate() {
active = false;
collidersIn = 0;
}

[Button("Toggle")]
public void Toggle() {
active = !active;
collidersIn = 0;
}

private void OnDisable() {
collidersIn = 0;
}

private bool shouldCollideWithPlayers;
Expand All @@ -101,7 +168,7 @@ public void Toggle() {

private void Start() {
if (collideWith == (collideWith | (1 << playerLayer)) ||
collideWith == (collideWith | (1 << playerLocalLayer))) {
collideWith == (collideWith | (1 << playerLocalLayer)) || collideTarget == 1) {
shouldCollideWithPlayers = true;
}

Expand All @@ -116,6 +183,7 @@ private void Start() {

private void OnTriggerEnter(Collider other) {
if (!active) return;
if (other == null) return;
if (collideWith == (collideWith | (1 << other.gameObject.layer))) {
if (collidersIn == 0) {
FireTriggers("enter");
Expand All @@ -125,9 +193,12 @@ private void OnTriggerEnter(Collider other) {
}

public override void OnPlayerTriggerEnter(VRCPlayerApi player) {
if (!active) return;
if (!collideWithLocalPlayers && !collideWithRemotePlayers && !shouldCollideWithPlayers) {
return;
}
if (player == null) return;
if (!Utilities.IsValid(player)) return;
var isLocal = player.isLocal;
if (isLocal && (collideWithLocalPlayers || shouldCollideWithLocals)) {
if (collidersIn == 0) {
Expand All @@ -148,6 +219,7 @@ public override void OnPlayerTriggerEnter(VRCPlayerApi player) {

private void OnTriggerExit(Collider other) {
if (!active) return;
if (other == null) return;
if (collideWith == (collideWith | (1 << other.gameObject.layer))) {
if (collidersIn == 1) {
FireTriggers("exit");
Expand All @@ -157,9 +229,12 @@ private void OnTriggerExit(Collider other) {
}

public override void OnPlayerTriggerExit(VRCPlayerApi player) {
if (!active) return;
if (!collideWithLocalPlayers && !collideWithRemotePlayers && !shouldCollideWithPlayers) {
return;
}
if (player == null) return;
if (!Utilities.IsValid(player)) return;
var isLocal = player.isLocal;
if (isLocal && (collideWithLocalPlayers || shouldCollideWithLocals)) {
if (collidersIn == 1) {
Expand All @@ -178,7 +253,66 @@ public override void OnPlayerTriggerExit(VRCPlayerApi player) {
}
}

private bool CheckAccess() {
var whitelist = allowedUsers.Length > 0;
if (masterOnly && !Networking.IsMaster && !whitelist) return false;
if (ownerOnly && !isOwner && !whitelist) return false;
if (whitelist) {
var allowed = false;
var playerName = Networking.LocalPlayer.displayName;
foreach (var user in allowedUsers) {
if (user == playerName) {
allowed = true;
break;
}
}

if (!allowed && ownerOnly && isOwner) {
allowed = true;
}

if (!allowed && masterOnly && Networking.IsMaster) {
allowed = true;
}

if (!allowed) return false;
}

return true;
}

public void TakeOwnership() {
if (isOwner) return;
Networking.SetOwner(Networking.LocalPlayer, gameObject);
isOwner = true;
}

public override void OnOwnershipTransferred(VRCPlayerApi player) {
isOwner = Networking.IsOwner(gameObject);
}

public override void OnPlayerLeft(VRCPlayerApi player) {
isOwner = Networking.IsOwner(gameObject);
}

public void ResetOneShot() {
used = false;
active = true;
collidersIn = 0;
}

private void FireTriggers(string type) {
if (!CheckAccess()) return;
if (oneShot) {
if (used) {
return;
}

active = false;
used = true;
enabled = false;
}

var udonTargets = type == "enter" ? enterTargets : exitTargets;
var udonEvents = type == "enter" ? enterEvents : exitEvents;
for (int i = 0; i < udonTargets.Length; i++) {
Expand All @@ -191,4 +325,4 @@ private void FireTriggers(string type) {
}
}
}
}
}
File renamed without changes.
Loading