From d06ad83b227769d50be5217015fd43da73130685 Mon Sep 17 00:00:00 2001 From: yum Date: Wed, 26 Mar 2025 19:03:56 -0700 Subject: User can now specify MeshRenderer This should really be automatic, but I'm too lazy to do that rn. --- README.md | 5 +++-- Scripts/YOTSCore.cs | 57 ++++++++++++++++++++++++++--------------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index d8e26bd..068d86a 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,9 @@ Toggle options are documented in two places: * You can override this with the `synced` and `saved` flags. * YOTS will not stop you from over-filling menus. * Auto-splitting menus is not yet implemented. -* The generated VRChat parameter and animator parameters use the "name" field. - No namespacing is applied. +* The generated VRChat parameter and animator parameters are simply + "menuPath/name". For example, if you create a toggle called "Shirt" in the + menu "/Clothes", the parameter is called "/Clothes/Shirt". * The generated animator has exactly as many layers as the maximum length of any dependency chain in your dependency graph. * The generated animator's parameters and layers are simply appended to your diff --git a/Scripts/YOTSCore.cs b/Scripts/YOTSCore.cs index 842a0a1..8548265 100644 --- a/Scripts/YOTSCore.cs +++ b/Scripts/YOTSCore.cs @@ -18,11 +18,6 @@ namespace YOTS [SerializeField] public string name; - // The parameter name used internally. If not specified, it will be - // auto-generated from the menuPath and name. - [SerializeField] - public string parameterName; - // The type of toggle. // Accepted values: // "toggle" - A boolean toggle. Creates a boolean sync param. @@ -77,24 +72,11 @@ namespace YOTS // Get the effective parameter name, generating one if not specified public string GetParameterName() { - if (!string.IsNullOrEmpty(parameterName)) { - return parameterName; - } - - // Generate parameter name from menuPath and name - string fullPath = menuPath.TrimEnd('/') + "/" + name; - // Remove leading slash if present - if (fullPath.StartsWith("/")) { - fullPath = fullPath.Substring(1); - } - // Replace non-alphanumeric characters with underscores - string sanitized = System.Text.RegularExpressions.Regex.Replace( - fullPath, "[^a-zA-Z0-9]", "_"); - // Ensure it doesn't start with a number - if (char.IsDigit(sanitized[0])) { - sanitized = "_" + sanitized; + if (disableMenuEntry) { + return name; } - return sanitized; + + return menuPath.TrimEnd('/') + "/" + name; } } @@ -135,6 +117,9 @@ namespace YOTS [SerializeField] public float onValue = 1.0f; + + [SerializeField] + public string rendererType = "SkinnedMeshRenderer"; // Can be "SkinnedMeshRenderer" or "MeshRenderer" } [System.Serializable] @@ -182,6 +167,7 @@ namespace YOTS public string path; public string materialProperty; public float value; + public string rendererType = "SkinnedMeshRenderer"; // Default to SkinnedMeshRenderer for backward compatibility } // These classes describe the generated JSON output for the animator configuration. @@ -309,7 +295,14 @@ namespace YOTS AnimationCurve curve = AnimationCurve.Constant(0, 0, shaderToggle.value); EditorCurveBinding binding = new EditorCurveBinding(); binding.path = shaderToggle.path; - binding.type = typeof(SkinnedMeshRenderer); + + // Use the specified renderer type + if (shaderToggle.rendererType == "MeshRenderer") { + binding.type = typeof(MeshRenderer); + } else { + binding.type = typeof(SkinnedMeshRenderer); // Default or when explicitly specified + } + binding.propertyName = $"material.{shaderToggle.materialProperty}"; AnimationUtility.SetEditorCurve(newClip, binding, curve); } @@ -584,7 +577,8 @@ namespace YOTS onAnim.shaderToggles.Add(new GeneratedShaderToggle { path = st.path, materialProperty = st.materialProperty, - value = st.onValue + value = st.onValue, + rendererType = st.rendererType }); } // Handle multiple paths @@ -593,7 +587,8 @@ namespace YOTS onAnim.shaderToggles.Add(new GeneratedShaderToggle { path = path, materialProperty = st.materialProperty, - value = st.onValue + value = st.onValue, + rendererType = st.rendererType }); } } @@ -630,7 +625,8 @@ namespace YOTS offAnim.shaderToggles.Add(new GeneratedShaderToggle { path = st.path, materialProperty = st.materialProperty, - value = st.offValue + value = st.offValue, + rendererType = st.rendererType }); } // Handle multiple paths @@ -639,7 +635,8 @@ namespace YOTS offAnim.shaderToggles.Add(new GeneratedShaderToggle { path = path, materialProperty = st.materialProperty, - value = st.offValue + value = st.offValue, + rendererType = st.rendererType }); } } @@ -831,7 +828,8 @@ namespace YOTS .Select(st => new GeneratedShaderToggle { path = st.path, materialProperty = st.materialProperty, - value = GetOffValueForShader(st.path, st.materialProperty, pair.off.shaderToggles) + value = GetOffValueForShader(st.path, st.materialProperty, pair.off.shaderToggles), + rendererType = st.rendererType }) .ToList(); @@ -860,7 +858,8 @@ namespace YOTS .Select(st => new GeneratedShaderToggle { path = st.path, materialProperty = st.materialProperty, - value = GetOffValueForShader(st.path, st.materialProperty, pair.off.shaderToggles) + value = GetOffValueForShader(st.path, st.materialProperty, pair.off.shaderToggles), + rendererType = st.rendererType }) .ToList(); -- cgit v1.2.3