Skip to content

Commit

Permalink
Brought back legacy controllers and marked them obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
orels1 committed Sep 6, 2020
1 parent bc908d5 commit 4f9e069
Show file tree
Hide file tree
Showing 26 changed files with 1,002 additions and 0 deletions.
90 changes: 90 additions & 0 deletions Legacy/Controllers/AreaTriggerController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#if UNITY_EDITOR

using System;
using System.Security.Permissions;
using UnityEngine;
using VRC.Udon;
using VRC.Udon.Common.Interfaces;

namespace UdonToolkit.Legacy {
[Obsolete("Controllers are Deprecated since v0.4.0, you can use the attributes directly in U# code now! Learn more: https://l.vrchat.sh/utV4Migrate")]
[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")]
public class AreaTriggerController : UTController {
[SectionHeader("General")]
[HelpBox("This behaviour requires a trigger collider to be attached to the object", "CheckCollider")]
[UdonPublic]
public bool active = true;

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

[HelpBox(
"It is impossible to distinguish between Local and Remote Players without putting the Area Trigger on a special layer that collides with either of those, keep that in mind when planning your triggers.",
"PlayerLayerWarnings")]
[HelpBox("It is not recommended to collide with Everything or the Default layer.", "CheckCollisionLayers")]
[UdonPublic]
public LayerMask collideWith;

public bool CheckCollisionLayers() {
var check = LayerMask.NameToLayer("Default");
return collideWith == (collideWith | (1 << check)) || collideWith.value == ~0;
}

public bool PlayerLayerWarnings() {
var player = LayerMask.NameToLayer("Player");
var playerLocal = LayerMask.NameToLayer("PlayerLocal");
var currL = gameObject.layer;
return (collideWith == (collideWith | (1 << player)) || collideWith == (collideWith | (1 << playerLocal))) &&
currL <= 22 && !(collideWith == (collideWith | (1 << player)) && collideWith == (collideWith | (1 << playerLocal)));
}

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

[UdonPublic] public NetworkEventTarget networkTarget;

public bool CheckNetworkedValidity() {
var player = LayerMask.NameToLayer("Player");
return collideWith == (collideWith | (1 << player)) && networked && networkTarget == NetworkEventTarget.All;
}

[ListView("Enter Events List")] [UdonPublic]
public UdonBehaviour[] enterTargets;

[ListView("Enter Events List")] [Popup(PopupAttribute.PopupSource.UdonBehaviour, "@enterTargets", true)] [UdonPublic]
public string[] enterEvents;

[ListView("Exit Events List")] [UdonPublic]
public UdonBehaviour[] exitTargets;

[ListView("Exit Events List")] [Popup(PopupAttribute.PopupSource.UdonBehaviour, "@exitTargets", true)] [UdonPublic]
public string[] exitEvents;

[Button("Activate")]
public void Activate() {
if (uB == null) return;
uB.SendCustomEvent("Activate");
}

[Button("Deactivate")]
public void Deactivate() {
if (uB == null) return;
uB.SendCustomEvent("Deactivate");
}

[Button("Toggle")]
public void Toggle() {
if (uB == null) return;
uB.SendCustomEvent("Toggle");
}
}
}

#endif
3 changes: 3 additions & 0 deletions Legacy/Controllers/AreaTriggerController.cs.meta

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

70 changes: 70 additions & 0 deletions Legacy/Controllers/FogAdjustmentController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#if UNITY_EDITOR
using System;
using UdonSharp;
using UnityEngine;


namespace UdonToolkit.Legacy {
[Obsolete("Controllers are Deprecated since v0.4.0, you can use the attributes directly in U# code now! Learn more: https://l.vrchat.sh/utV4Migrate")]
[CustomName("Fog Adjustment")]
[HelpURL("https://github.com/orels1/UdonToolkit/wiki/Misc-Behaviours#fog-adjustment")]
public class FogAdjustmentController : UTController {
[HideInInspector] public bool isLinear;
[SectionHeader("Defaults")] [UdonPublic]
public Color defaultFogColor;

[HideIf("@isLinear")][UdonPublic] public float defaultFogDensity;
[HideIf("@!isLinear")][UdonPublic]
public float defaultFogStart;
[HideIf("@!isLinear")][UdonPublic]
public float defaultFogEnd;

[SectionHeader("Active State")] [UdonPublic]
public Color activeFogColor;

[HideIf("@isLinear")][UdonPublic] public float activeFogDensity;
[HideIf("@!isLinear")][UdonPublic]
public float activeFogStart;
[HideIf("@!isLinear")][UdonPublic]
public float activeFogEnd;
[HelpBox("Transition time cannot be negative", "CheckValidTransition")]
[UdonPublic] [Tooltip("0 - Instant")] public float fogTransitionTime;

public bool CheckValidTransition() {
return fogTransitionTime < 0;
}

[SectionHeader("Extras")] [UdonPublic] public bool startActive;

[HelpBox("Will set the fog color and density from the Default or Active state on start", "@setInitialState")]
[UdonPublic]
public bool setInitialState;

public override void SetupController() {
isLinear = RenderSettings.fogMode == FogMode.Linear;
}

[Button("ActivateFog")]
public void ActivateFog() {
if (uB != null) {
uB.SendCustomEvent("ActivateFog");
}
}

[Button("DeactivateFog")]
public void DeactivateFog() {
if (uB != null) {
uB.SendCustomEvent("DeactivateFog");
}
}

[Button("Trigger")]
public void Trigger() {
if (uB != null) {
uB.SendCustomEvent("Trigger");
}
}
}
}

#endif
3 changes: 3 additions & 0 deletions Legacy/Controllers/FogAdjustmentController.cs.meta

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

72 changes: 72 additions & 0 deletions Legacy/Controllers/InteractTriggerController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#if UNITY_EDITOR

using System;
using UnityEditor;
using UnityEngine;
using VRC.Udon;
using VRC.Udon.Common.Interfaces;

namespace UdonToolkit.Legacy {
[Obsolete("Controllers are Deprecated since v0.4.0, you can use the attributes directly in U# code now! Learn more: https://l.vrchat.sh/utV4Migrate")]
[CustomName("Interact Trigger")]
[HelpURL("https://github.com/orels1/UdonToolkit/wiki/Misc-Behaviours#interact-trigger")]
public class InteractTriggerController : UTController {
[SectionHeader("General")] [UdonPublic]
public bool active = true;

[OnValueChanged("SetInteract")] [UTEditor]
public string interactionText = "Use";

public void SetInteract(object value) {
var val = ((SerializedProperty) value).stringValue;
if (uB == null) return;
uB.interactText = val;
}

[OnValueChanged("SetDistance")] [RangeSlider(0, 100)] [UTEditor]
public float proximity = 2f;

public void SetDistance(object value) {
var val = ((SerializedProperty) value).floatValue;
if (uB == null) return;
uB.proximity = val;
}

[SectionHeader("Udon Events")] [UdonPublic]
public bool networked;

[UdonPublic] public NetworkEventTarget networkTarget;

[ListView("Udon Events List")] [UdonPublic]
public UdonBehaviour[] udonTargets;

[ListView("Udon Events List")] [Popup(PopupAttribute.PopupSource.UdonBehaviour, "@udonTargets", true)] [UdonPublic]
public string[] udonEvents;

[Button("Interact")]
public void Interact() {
if (uB == null) return;
uB.Interact();
}

[Button("Activate")]
public void Activate() {
if (uB == null) return;
uB.SendCustomEvent("Activate");
}

[Button("Deactivate")]
public void Deactivate() {
if (uB == null) return;
uB.SendCustomEvent("Deactivate");
}

[Button("Toggle")]
public void Toggle() {
if (uB == null) return;
uB.SendCustomEvent("Toggle");
}
}
}

#endif
3 changes: 3 additions & 0 deletions Legacy/Controllers/InteractTriggerController.cs.meta

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

26 changes: 26 additions & 0 deletions Legacy/Controllers/LerpedFollowerController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#if UNITY_EDITOR

using System;
using UnityEngine;

namespace UdonToolkit.Legacy{
[Obsolete("Controllers are Deprecated since v0.4.0, you can use the attributes directly in U# code now! Learn more: https://l.vrchat.sh/utV4Migrate")]
[CustomName("Lerped Follower")]
[HelpMessage("This component makes the Target Transform follow the Source Transform with linear interpolation. " +
"Use this to make an object smoothly follow your target.")]
[HelpURL("https://github.com/orels1/UdonToolkit/wiki/Misc-Behaviours#lerped-follower")]
public class LerpedFollowerController : UTController {
[SectionHeader("General")] [UdonPublic]
public Transform sourceTransform;
[UdonPublic] public Transform targetTransform;
[HelpBox("Target will instantly match the Source position", "@!lerpPosition")]
[UdonPublic] public bool lerpPosition = true;
[HelpBox("Target will instantly match the Source rotation", "@!lerpRotation")]
[UdonPublic] public bool lerpRotation = true;
[UdonPublic] public float lerpSpeed = 10f;
[HelpBox("This option disables rotation transfer.")]
[UdonPublic] public bool ignoreRotation;
}
}

#endif
3 changes: 3 additions & 0 deletions Legacy/Controllers/LerpedFollowerController.cs.meta

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

32 changes: 32 additions & 0 deletions Legacy/Controllers/NetworkedTriggerController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#if UNITY_EDITOR
using System;
using UnityEngine;
using VRC.Udon;
using VRC.Udon.Common.Interfaces;

namespace UdonToolkit.Legacy {
[Obsolete("Controllers are Deprecated since v0.4.0, you can use the attributes directly in U# code now! Learn more: https://l.vrchat.sh/utV4Migrate")]
[CustomName("Networked Trigger")]
[HelpMessage(
"This component waits for a \"Trigger\" custom event, e.g. from a UI Button, and calls a network event on all the provided behaviours. " +
"You can disable this object safely to save a bit of performance - it will still work as expected.")]
[HelpURL("https://github.com/orels1/UdonToolkit/wiki/Misc-Behaviours#networked-trigger")]
public class NetworkedTriggerController : UTController {
[SectionHeader("General")] [UdonPublic]
public NetworkEventTarget eventTarget;

[ListView("Udon Events List")] [UdonPublic]
public UdonBehaviour[] udonTargets;

[ListView("Udon Events List")] [Popup(PopupAttribute.PopupSource.UdonBehaviour, "@udonTargets", true)] [UdonPublic]
public string[] udonEvents;

[Button("Trigger")]
public void Trigger() {
if (uB == null) return;
uB.SendCustomEvent("Trigger");
}

}
}
#endif
3 changes: 3 additions & 0 deletions Legacy/Controllers/NetworkedTriggerController.cs.meta

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

Loading

0 comments on commit 4f9e069

Please sign in to comment.