Skip to content

Commit

Permalink
Add "Auto Play On Near" component,
Browse files Browse the repository at this point in the history
intended usage is for local players in exhibition booths,
which only auto plays when user goes nearby and stops when user go away.
Along side with auto play option in frontend handler,
which is for manually control when to auto play the play list.
  • Loading branch information
JLChnToZ committed Dec 1, 2023
1 parent cab0c5e commit 85a2028
Show file tree
Hide file tree
Showing 10 changed files with 687 additions and 86 deletions.
15 changes: 9 additions & 6 deletions Packages/idv.jlchntoz.vvmw/Editor/VVMW/FrontendHandlerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ public class FrontendHandlerEditor : VVMWEditorBase {
SerializedProperty defaultLoopProperty;
SerializedProperty defaultShuffleProperty;
SerializedProperty enableQueueListProperty;
SerializedProperty localPlayListIndexProperty;
SerializedProperty defaultPlayListIndexProperty;
SerializedProperty playListTitlesProperty;
SerializedProperty autoPlayProperty;
SerializedProperty targetsProperty;
ReorderableListUtils targetsPropertyList;
SerializedObject coreSerializedObject;
Expand All @@ -29,8 +30,9 @@ protected override void OnEnable() {
defaultLoopProperty = serializedObject.FindProperty("defaultLoop");
defaultShuffleProperty = serializedObject.FindProperty("defaultShuffle");
enableQueueListProperty = serializedObject.FindProperty("enableQueueList");
localPlayListIndexProperty = serializedObject.FindProperty("localPlayListIndex");
defaultPlayListIndexProperty = serializedObject.FindProperty("defaultPlayListIndex");
playListTitlesProperty = serializedObject.FindProperty("playListTitles");
autoPlayProperty = serializedObject.FindProperty("autoPlay");
targetsProperty = serializedObject.FindProperty("targets");
targetsPropertyList = new ReorderableListUtils(targetsProperty);
playListNames = null;
Expand Down Expand Up @@ -62,14 +64,14 @@ public override void OnInspectorGUI() {
if (GUILayout.Button("Edit Play Lists..."))
PlayListEditorWindow.StartEditPlayList(target as FrontendHandler);
var rect = GUILayoutUtility.GetRect(0, EditorGUIUtility.singleLineHeight);
tempContent.text = "Autoplay Play List";
tempContent.text = "Default Play List";
using (new EditorGUI.PropertyScope(rect, tempContent, playListTitlesProperty))
using (var changed = new EditorGUI.ChangeCheckScope()) {
rect = EditorGUI.PrefixLabel(rect, tempContent);
var index = EditorGUI.Popup(rect, localPlayListIndexProperty.intValue, playListNames);
if (changed.changed) localPlayListIndexProperty.intValue = index;
var index = EditorGUI.Popup(rect, defaultPlayListIndexProperty.intValue, playListNames);
if (changed.changed) defaultPlayListIndexProperty.intValue = index;
}
if (coreSerializedObject != null && localPlayListIndexProperty.intValue > 0) {
if (coreSerializedObject != null && defaultPlayListIndexProperty.intValue > 0) {
var url = coreSerializedObject.FindProperty("defaultUrl.url");
if (url != null && !string.IsNullOrEmpty(url.stringValue)) {
EditorGUILayout.HelpBox("You cannot set default URL in core and mark a play list to be autoplayed at the same time.", MessageType.Warning);
Expand All @@ -82,6 +84,7 @@ public override void OnInspectorGUI() {
}
}
}
EditorGUILayout.PropertyField(autoPlayProperty);
EditorGUILayout.Space();
var loopMode = LoopMode.None;
bool hasLoopOne = false;
Expand Down
14 changes: 8 additions & 6 deletions Packages/idv.jlchntoz.vvmw/Editor/VVMW/MenuUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,20 @@ static GameObject SpawnPrefab(string path, bool spawnOnRoot = false) {
LocatableAttributeDrawer.Locate(component, GetField(typeof(OverlayControl), "core"), true, true);
} else if (component is ResyncButtonConfigurator) {
LocatableAttributeDrawer.Locate(component, GetField(typeof(ResyncButtonConfigurator), "core"), true, true);
/*
} else if (component is AutoPlayOnNear) {
var core = LocatableAttributeDrawer.Locate(component, GetField(typeof(AutoPlayOnNear), "core"), true, true) as Core;
if (core != null) {
var handler = LocatableAttributeDrawer.Locate(component, GetField(typeof(AutoPlayOnNear), "handler"), true, true) as FrontendHandler;
if (handler != null) {
using (var so = new SerializedObject(handler)) {
so.FindProperty("autoPlay").boolValue = false;
so.ApplyModifiedProperties();
}
LocatableAttributeDrawer.Locate(handler, GetField(typeof(FrontendHandler), "core"), true, true);
var core = handler.core;
using (var so = new SerializedObject(core)) {
so.FindProperty("synced").boolValue = false;
so.ApplyModifiedProperties();
}
}
*/
}
}
Undo.RegisterCreatedObjectUndo(go, $"Create {go.name}");
Expand Down Expand Up @@ -143,9 +147,7 @@ static void CreateOverlayControls() {
[MenuItem(createMenuRoot + "Additional Controls/Global Resync Button", false, 49)]
static void CreateGlobalSyncButton() => SpawnPrefab(prefabRoot + "Global Sync Button.prefab");

/*
[MenuItem(createMenuRoot + "Additional Controls/Auto Play On Near (Local Only)", false, 49)]
static void CreateAutoPlayOnNear() => SpawnPrefab(prefabRoot + "Auto Play On Near.prefab");
*/
}
}
99 changes: 99 additions & 0 deletions Packages/idv.jlchntoz.vvmw/Prefabs/Auto Play On Near.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8413105371535903187
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 971465216864624757}
- component: {fileID: 4914670355308013922}
- component: {fileID: 8888357937694933989}
- component: {fileID: 5715821106896851058}
m_Layer: 0
m_Name: Auto Play On Near
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &971465216864624757
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8413105371535903187}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &4914670355308013922
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8413105371535903187}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 906511115f297fc4fbfc3031bd3a0e3b, type: 3}
m_Name:
m_EditorClassIdentifier:
serializationData:
SerializedFormat: 2
SerializedBytes:
ReferencedUnityObjects: []
SerializedBytesString:
Prefab: {fileID: 0}
PrefabModificationsReferencedUnityObjects: []
PrefabModifications: []
SerializationNodes: []
_udonSharpBackingUdonBehaviour: {fileID: 8888357937694933989}
core: {fileID: 0}
frontendHandler: {fileID: 0}
distance: 0
--- !u!114 &8888357937694933989
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8413105371535903187}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 45115577ef41a5b4ca741ed302693907, type: 3}
m_Name:
m_EditorClassIdentifier:
interactTextPlacement: {fileID: 0}
interactText: Use
interactTextGO: {fileID: 0}
proximity: 2
SynchronizePosition: 0
AllowCollisionOwnershipTransfer: 0
Reliable: 0
_syncMethod: 0
serializedProgramAsset: {fileID: 11400000, guid: ed07bb1182f688d40a1afbe48b3f12bf,
type: 2}
programSource: {fileID: 11400000, guid: d2f3122a78aa5044c9bdc293e95797ad, type: 2}
serializedPublicVariablesBytesString: Ai8AAAAAATIAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAFQAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AAAAAAAYBAAAAAAAAACcBBAAAAHQAeQBwAGUAAWgAAABTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEcAZQBuAGUAcgBpAGMALgBMAGkAcwB0AGAAMQBbAFsAVgBSAEMALgBVAGQAbwBuAC4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Objects: []
publicVariablesSerializationDataFormat: 0
--- !u!135 &5715821106896851058
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8413105371535903187}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Radius: 10
m_Center: {x: 0, y: 0, z: 0}

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

Loading

0 comments on commit 85a2028

Please sign in to comment.