From 6eed98ff4e57326ebf7a41f0c180635a7bcac626 Mon Sep 17 00:00:00 2001 From: yum Date: Thu, 25 Apr 2024 15:52:24 -0700 Subject: Add LTCGI Also begin trying to fix fallback shaders. --- .../LTCGI_USharpVideoAdapterAutoSetup.cs_disabled | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Third_Party/at.pimaker.ltcgi/Adapters/Editor/LTCGI_USharpVideoAdapterAutoSetup.cs_disabled (limited to 'Third_Party/at.pimaker.ltcgi/Adapters/Editor/LTCGI_USharpVideoAdapterAutoSetup.cs_disabled') diff --git a/Third_Party/at.pimaker.ltcgi/Adapters/Editor/LTCGI_USharpVideoAdapterAutoSetup.cs_disabled b/Third_Party/at.pimaker.ltcgi/Adapters/Editor/LTCGI_USharpVideoAdapterAutoSetup.cs_disabled new file mode 100644 index 0000000..4a71ca3 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Adapters/Editor/LTCGI_USharpVideoAdapterAutoSetup.cs_disabled @@ -0,0 +1,92 @@ +#if UNITY_EDITOR && UDONSHARP +using System.Linq; +using UnityEditor; +using UnityEngine; +using UnityEngine.SceneManagement; +using UdonSharpEditor; +using UdonSharp.Video; + +namespace pi.LTCGI +{ + public class LTCGI_USharpVideoAdapterAutoSetup : ILTCGI_AutoSetup + { + private static readonly Vector2 DefaultScale = new Vector2(7.63f, 4.2925f); + + public LTCGI_USharpVideoAdapterAutoSetup() + { + } + + public GameObject AutoSetupEditor(LTCGI_Controller controller) + { + #pragma warning disable 618 + var usharpPlayers = SceneManager.GetActiveScene().GetRootGameObjects() + .SelectMany(sceneRoot => sceneRoot.GetUdonSharpComponentsInChildren()); + #pragma warning restore 618 + var first = true; + foreach (var player in usharpPlayers) + { + if (first) + { + EditorGUILayout.LabelField("Detected U# Video Players in scene:"); + first = false; + } + if (GUILayout.Button($"Auto-Configure '{VRC.Core.ExtensionMethods.GetHierarchyPath(player.gameObject.transform)}'")) + { + var adapter = new GameObject("LTCGI_USharpVideoAdapter"); + adapter.transform.parent = controller.transform; + adapter.transform.position = player.transform.position; + adapter.transform.rotation = player.transform.rotation; + + var script = adapter.AddUdonSharpComponent(); + #pragma warning disable 618 + script.UpdateProxy(); + #pragma warning restore 618 + script.VideoPlayer = player; + script.CRT = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("802e4542fd374664aa4d0858e525b454") /* LTCGI_BlitCRT.asset */); + + controller.VideoTexture = script.CRT; + + // attempt to read standby texture from player + #pragma warning disable 618 + var handler = player.GetUdonSharpComponentInChildren(); + #pragma warning restore 618 + if (handler != null) + { + script.StandbyTexture = handler.standbyTexture; + } + else + { + script.StandbyTexture = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("68718da77206620438ca14e29cefa6fb") /* black1px.png */); + } + #pragma warning disable 618 + script.ApplyProxyModifications(); + #pragma warning restore 618 + + var quad = GameObject.CreatePrimitive(PrimitiveType.Quad); + quad.transform.parent = adapter.transform; + quad.transform.localScale = DefaultScale * player.transform.lossyScale; + quad.transform.localEulerAngles = Vector3.zero; + quad.transform.localPosition = Vector3.zero; + quad.transform.GetComponent().enabled = false; + Component.DestroyImmediate(quad.transform.GetComponent()); + quad.name = "LTCGI Video Screen"; + + var ltcgi = quad.AddComponent(); + ltcgi.ColorMode = ColorMode.Texture; + ltcgi.Specular = true; + ltcgi.Diffuse = true; // LTC Diffuse by default + ltcgi.TextureIndex = 0; + + EditorUtility.DisplayDialog("Auto-Configure", "Auto-Configured LTCGI_USharpVideoAdapter. Please make sure the 'LTCGI Video Screen' object has the same position, rotation and scale in your scene as your actual video screen.", "OK"); + EditorGUIUtility.PingObject(quad); + + return adapter; + } + } + + return null; + } + } +} + +#endif \ No newline at end of file -- cgit v1.2.3