From 063df8b6a027b85df1cd0c3bd4f5978126e2b5bf Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 1 Nov 2018 15:35:13 +0900 Subject: [PATCH] Removed unused VRMBlendShapeManipulator --- Scripts/BlendShape/BlendShapeAvatar.cs | 10 +- Scripts/BlendShape/BlendShapeClip.cs | 44 ----- .../Editor/VRMBlendShapeManipulatorEditor.cs | 161 ------------------ .../VRMBlendShapeManipulatorEditor.cs.meta | 13 -- .../BlendShape/VRMBlendShapeManipulator.cs | 9 - .../VRMBlendShapeManipulator.cs.meta | 13 -- 6 files changed, 1 insertion(+), 249 deletions(-) delete mode 100644 Scripts/BlendShape/Editor/VRMBlendShapeManipulatorEditor.cs delete mode 100644 Scripts/BlendShape/Editor/VRMBlendShapeManipulatorEditor.cs.meta delete mode 100644 Scripts/BlendShape/VRMBlendShapeManipulator.cs delete mode 100644 Scripts/BlendShape/VRMBlendShapeManipulator.cs.meta diff --git a/Scripts/BlendShape/BlendShapeAvatar.cs b/Scripts/BlendShape/BlendShapeAvatar.cs index fe1779552..cc2cb36e6 100644 --- a/Scripts/BlendShape/BlendShapeAvatar.cs +++ b/Scripts/BlendShape/BlendShapeAvatar.cs @@ -23,7 +23,7 @@ namespace VRM } - foreach(var x in assetPath.Parent.ChildFiles) + foreach (var x in assetPath.Parent.ChildFiles) { var clip = UnityEditor.AssetDatabase.LoadAssetAtPath(x.Value); if (clip == null) continue; @@ -98,13 +98,5 @@ namespace VRM { return GetClip(new BlendShapeKey(name)); } - - public bool Apply(string name, Transform transform, float value) - { - var clip = GetClip(name); - if (clip == null) return false; - clip.Apply(transform, value); - return true; - } } } diff --git a/Scripts/BlendShape/BlendShapeClip.cs b/Scripts/BlendShape/BlendShapeClip.cs index 2fa3180f2..99b28f35c 100644 --- a/Scripts/BlendShape/BlendShapeClip.cs +++ b/Scripts/BlendShape/BlendShapeClip.cs @@ -58,50 +58,6 @@ namespace VRM return m_prefab; } } - - /// - /// Apply BlendShape for Preview - /// - /// - /// - public void Apply(Transform root, float value) - { - if (Values != null) - { - foreach (var x in Values) - { - var target = root.Find(x.RelativePath); - if (target != null) - { - var sr = target.GetComponent(); - if (sr != null) - { - sr.SetBlendShapeWeight(x.Index, x.Weight * value); - } - } - } - } - - /* - if (MaterialValues != null) - { - foreach (var x in MaterialValues) - { - var target = root.Find(x.RelativePath); - if (target != null) - { - var sr = target.GetComponent(); - if (sr != null) - { - var m = sr.sharedMaterials[x.Index]; - var color = x.BaseValue + (x.TargetValue - x.BaseValue) * value; - m.SetColor(x.ValueName, color); - } - } - } - } - */ - } #endif /// diff --git a/Scripts/BlendShape/Editor/VRMBlendShapeManipulatorEditor.cs b/Scripts/BlendShape/Editor/VRMBlendShapeManipulatorEditor.cs deleted file mode 100644 index a7f416eb8..000000000 --- a/Scripts/BlendShape/Editor/VRMBlendShapeManipulatorEditor.cs +++ /dev/null @@ -1,161 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using UnityEditor; -using UnityEngine; -using UniGLTF; -using System.IO; - -namespace VRM -{ - [CustomEditor(typeof(VRMBlendShapeManipulator))] - public class VRMBlendShapeManipulatorEditor : Editor - { - VRMBlendShapeManipulator m_target = null; - SkinnedMeshRenderer[] m_renderers; - - void OnEnable() - { - m_target = (VRMBlendShapeManipulator)target; - - m_renderers = m_target.transform - .Traverse() - .Select(x => x.GetComponent()) - .Where(x => x != null) - .ToArray() - ; - } - - static string EscapeFilePath(string src) - { - return src - .Replace(">", ">") - .Replace("<", "<") - ; - } - - public override void OnInspectorGUI() - { - if (GUILayout.Button("Clear")) - { - ClearBlendShape(); - } - - if (GUILayout.Button("Create BlendShapeClip")) - { - CreateBlendShapeClip(); - } - - var clip = (BlendShapeClip)EditorGUILayout.ObjectField("Load clip", null, typeof(BlendShapeClip), false); - if (clip != null) - { - ClearBlendShape(); - clip.Apply(m_target.transform, 1.0f); - } - - EditorGUILayout.Space(); - - // sliders - foreach (var renderer in m_renderers) - { - var mesh = renderer.sharedMesh; - if (mesh != null) - { - var relativePath = UniGLTF.UnityExtensions.RelativePathFrom(renderer.transform, m_target.transform); - EditorGUILayout.LabelField(m_target.name+"/"+relativePath); - - for (int i = 0; i < mesh.blendShapeCount; ++i) - { - var src = renderer.GetBlendShapeWeight(i); - var dst = EditorGUILayout.Slider(mesh.GetBlendShapeName(i), src, 0, 100.0f); - if (dst != src) - { - renderer.SetBlendShapeWeight(i, dst); - } - } - } - } - } - - private void CreateBlendShapeClip() - { - var maxWeight = 0.0f; - var maxWeightName = ""; - - // weightのついたblendShapeを集める - var blendShapes = m_renderers.SelectMany(x => - { - var mesh = x.sharedMesh; - - var relativePath = UniGLTF.UnityExtensions.RelativePathFrom(x.transform, m_target.transform); - - var list = new List(); - if (mesh != null) - { - for (int i = 0; i < mesh.blendShapeCount; ++i) - { - var weight = x.GetBlendShapeWeight(i); - if (weight == 0) - { - continue; - } - var name = mesh.GetBlendShapeName(i); - if (weight > maxWeight) - { - maxWeightName = name; - maxWeight = weight; - } - list.Add(new BlendShapeBinding - { - Index = i, - RelativePath = relativePath, - Weight = weight - }); - } - } - return list; - }) - .ToArray() - ; - - var assetPath = string.Format("Assets/{0}.{1}.asset", - m_target.name, - maxWeightName); -#if UNITY_2018_2_OR_NEWER - var prefab = PrefabUtility.GetCorrespondingObjectFromSource(m_target.gameObject); -#else - var prefab = PrefabUtility.GetPrefabParent(m_target.gameObject); -#endif - if (prefab != null) - { - var prefabPath = AssetDatabase.GetAssetPath(prefab); - assetPath = string.Format("{0}/{1}.{2}.asset", - Path.GetDirectoryName(prefabPath), - Path.GetFileNameWithoutExtension(prefabPath), - maxWeightName); - } - assetPath = EscapeFilePath(assetPath); - - var asset = ScriptableObject.CreateInstance(); - asset.Values = blendShapes.ToArray(); - Debug.LogFormat("create asset: {0}", assetPath); - AssetDatabase.CreateAsset(asset, assetPath); - - Selection.objects = new UnityEngine.Object[] { AssetDatabase.LoadAssetAtPath(assetPath, typeof(BlendShapeClip)) }; - } - - private void ClearBlendShape() - { - foreach (var renderer in m_renderers) - { - var mesh = renderer.sharedMesh; - if (mesh != null) - { - for (int i = 0; i < mesh.blendShapeCount; ++i) - { - renderer.SetBlendShapeWeight(i, 0); - } - } - } - } - } -} diff --git a/Scripts/BlendShape/Editor/VRMBlendShapeManipulatorEditor.cs.meta b/Scripts/BlendShape/Editor/VRMBlendShapeManipulatorEditor.cs.meta deleted file mode 100644 index 11288de69..000000000 --- a/Scripts/BlendShape/Editor/VRMBlendShapeManipulatorEditor.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e213c696e46ae2642b99797f2124a682 -timeCreated: 1517404644 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/BlendShape/VRMBlendShapeManipulator.cs b/Scripts/BlendShape/VRMBlendShapeManipulator.cs deleted file mode 100644 index 56a8cbe0d..000000000 --- a/Scripts/BlendShape/VRMBlendShapeManipulator.cs +++ /dev/null @@ -1,9 +0,0 @@ -using UnityEngine; - - -namespace VRM -{ - public class VRMBlendShapeManipulator : MonoBehaviour - { - } -} diff --git a/Scripts/BlendShape/VRMBlendShapeManipulator.cs.meta b/Scripts/BlendShape/VRMBlendShapeManipulator.cs.meta deleted file mode 100644 index e3fafa4cc..000000000 --- a/Scripts/BlendShape/VRMBlendShapeManipulator.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 4829a7f37bfef244289c32551215632d -timeCreated: 1517403264 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: