From ada700b5f27ca97bd92dc6418fa7b0dd68c05912 Mon Sep 17 00:00:00 2001 From: Jo-Anna Wall Date: Mon, 14 Sep 2020 07:55:45 -0400 Subject: [PATCH] Some log changes Removed unnecessary Debug.Log prints, and added a few Debug.LogError prints to help identify future problems. --- .../SnailMarker3AnimationCreatorEditor.cs | 70 ++++++++++++------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/Marker3.0/AnimationGenerator/Editor/SnailMarker3AnimationCreatorEditor.cs b/Marker3.0/AnimationGenerator/Editor/SnailMarker3AnimationCreatorEditor.cs index df336e7..f25605d 100644 --- a/Marker3.0/AnimationGenerator/Editor/SnailMarker3AnimationCreatorEditor.cs +++ b/Marker3.0/AnimationGenerator/Editor/SnailMarker3AnimationCreatorEditor.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; using System.Collections.Generic; using System.Linq; @@ -36,7 +36,6 @@ public enum VRCGesture { Neutral, Fist, HandOpen, FingerPoint, Victory, RockNRol public void OnEnable() { - Debug.Log("OnEnable"); errorStyle.normal.textColor = Color.red; obj = target as SnailMarker3AnimationCreator; @@ -51,17 +50,21 @@ public override void OnInspectorGUI() return; } - if(fxController == null || expressionParams == null || expressionMenu == null) { + if (fxController == null || expressionParams == null || expressionMenu == null) + { GUILayout.Label("Avatar is missing some 3.0 stuff."); - if(GUILayout.Button("Setup 3.0 defaults")) { + if (GUILayout.Button("Setup 3.0 defaults")) + { ensureDefaults(); } - } else { + } + else + { GUILayout.Label("Select a location for the marker:"); hand = (Hand)EditorGUILayout.EnumPopup("Hand:", hand); activateGesture = (VRCGesture)EditorGUILayout.EnumPopup("Activate Gesture:", activateGesture); resetGesture = (VRCGesture)EditorGUILayout.EnumPopup("Reset Gesture:", resetGesture); - + GUILayout.Label("Select a location for the marker:"); ShowMenuFoldout(avatarDescriptor.expressionsMenu, "Expressions Menu"); @@ -69,33 +72,41 @@ public override void OnInspectorGUI() } private HashSet expandedMenus = new HashSet(); - private void ShowMenuFoldout(VRCExpressionsMenu menu, string title) { - if(menu == null) return; + private void ShowMenuFoldout(VRCExpressionsMenu menu, string title) + { + if (menu == null) return; bool b = expandedMenus.Contains(menu); // Remove before we go any further, prevents infinite recursion on cyclic menus. expandedMenus.Remove(menu); - if(! EditorGUILayout.Foldout(b, title, true)) { + if (!EditorGUILayout.Foldout(b, title, true)) + { return; } EditorGUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Space(EditorGUI.indentLevel * 17); - if(menu.controls.Count < 8) { - if(GUILayout.Button("Add Marker Here", GUILayout.Width(130))){ + if (menu.controls.Count < 8) + { + if (GUILayout.Button("Add Marker Here", GUILayout.Width(130))) + { InstallMarker(ref menu); } - } else { - GUILayout.Label("No room.", GUILayout.Width(130)); + } + else + { + GUILayout.Label("No room.", GUILayout.Width(130)); } GUILayout.EndHorizontal(); EditorGUI.indentLevel++; - foreach(var child in menu.controls) { - if(child.type == ControlType.SubMenu) { + foreach (var child in menu.controls) + { + if (child.type == ControlType.SubMenu) + { ShowMenuFoldout(child.subMenu, child.name); } } @@ -105,10 +116,10 @@ private void ShowMenuFoldout(VRCExpressionsMenu menu, string title) { // Okay, it's safe to add the menu back. expandedMenus.Add(menu); } - + //menu in this case is the chosen menu or submenu, in wich to add the marker. private void InstallMarker(ref VRCExpressionsMenu menu) - { + { ConfigureAnimationController(); AddParameter(); AddMarkerToMenu(ref menu); @@ -118,7 +129,7 @@ private void InstallMarker(ref VRCExpressionsMenu menu) private void AddParameter() { - for(int i = 0; i < expressionParams.parameters.Length; i++) + for (int i = 0; i < expressionParams.parameters.Length; i++) { if (expressionParams.parameters[i].name == "ToggleMarker" || expressionParams.parameters[i].name.Trim().Length == 0) @@ -149,7 +160,7 @@ private void AddMarkerToMenu(ref VRCExpressionsMenu menu) Transform avatarTransform = null; VRCAvatarDescriptor avatarDescriptor = null; string animationPath; - + private bool findAvatarAndAnimationPath(Transform cur) { // Find the avatar root and record the animation path along the way. @@ -174,7 +185,6 @@ private bool findAvatarAndAnimationPath(Transform cur) if (avatarTransform != null) { animationPath = path; - Debug.Log("Animation path:" + animationPath); return true; } @@ -185,7 +195,7 @@ private void findComponents() { fxLayer = avatarDescriptor.baseAnimationLayers.Where(layer => layer.type == AnimLayerType.FX).First(); fxController = fxLayer.animatorController as AnimatorController; - + expressionMenu = avatarDescriptor.expressionsMenu; expressionParams = avatarDescriptor.expressionParameters; } @@ -193,7 +203,7 @@ private void findComponents() private void ensureDefaults() { var obj = new SerializedObject(avatarDescriptor); - + obj.FindProperty("customizeAnimationLayers").boolValue = true; obj.FindProperty("customExpressions").boolValue = true; @@ -215,14 +225,16 @@ private void ensureDefaults() layer.FindPropertyRelative("isDefault").boolValue = false; break; } - + var menu = obj.FindProperty("expressionsMenu"); - if(menu.objectReferenceValue == null) { + if (menu.objectReferenceValue == null) + { menu.objectReferenceValue = CreateAssetFromTemplate("DefaultMenu.asset"); } var parameters = obj.FindProperty("expressionParameters"); - if(parameters.objectReferenceValue == null) { + if (parameters.objectReferenceValue == null) + { parameters.objectReferenceValue = CreateAssetFromTemplate("DefaultParams.asset"); } @@ -274,11 +286,15 @@ private T CreateAssetFromTemplate(string name) where T : Object ensureGeneratedDirectory(); string assetPath = generatedAssetPath(name); string templatePath = templateAssetPath(name); - AssetDatabase.CopyAsset(templatePath, assetPath); + if (!AssetDatabase.CopyAsset(templatePath, assetPath)) + { + Debug.LogError("[Snail] Could not create asset: (" + assetPath + ") from: (" + templatePath + ")"); + } return AssetDatabase.LoadAssetAtPath(assetPath); } - private void ensureGeneratedDirectory() { + private void ensureGeneratedDirectory() + { if (!Directory.Exists(generatedFolderPath())) { Directory.CreateDirectory(generatedFolderPath());