Exemplo n.º 1
0
 public void ConverterGUI(DynamicBoneConverter executionScript)
 {
     GUILayout.Label("Dynamic to VRM Spring", EditorStyles.boldLabel);
     fillCollidersGap  = EditorGUILayout.ToggleLeft("Make height with multiple colliders", fillCollidersGap);
     attachToSecondary = EditorGUILayout.ToggleLeft("Attach SpringBones to secondary object", attachToSecondary);
     if (GUILayout.Button("Convert and export JSON"))
     {
         executionScript.ConvertToSpringBone(fillCollidersGap, attachToSecondary);
     }
 }
Exemplo n.º 2
0
        public void DynamicBoneGUI(DynamicBoneConverter executionScript)
        {
            // Import / Export
            GUILayout.Label("Data", EditorStyles.boldLabel);

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("JSON");
            if (GUILayout.Button("Export"))
            {
                executionScript.ExportDynamicBonesToJson();
            }
            else if (GUILayout.Button("Import"))
            {
                executionScript.ImportDynamicBonesFromJson();
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Asset");
            if (GUILayout.Button("Q.Save"))
            {
                executionScript.ExportDynamicBonesToAsset();
            }
            else if (GUILayout.Button("Q.Load"))
            {
                executionScript.ImportDynamicBonesFromAsset();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Remove");
            if (GUILayout.Button("Remove all DynamicBones"))
            {
                if (EditorUtility.DisplayDialog("Remove DynamicBones", "Are you sure to remove all DynamicBones?", "OK", "Cancel"))
                {
                    executionScript.RemoveDynamicBones();
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        public void SpringBoneGUI(DynamicBoneConverter executionScript)
        {
            var toggleLeftLayout = new GUILayoutOption[] { GUILayout.Width(120) };

            // Import / Export
            GUILayout.Label("Data", EditorStyles.boldLabel);

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("JSON");
            if (GUILayout.Button("Export"))
            {
                executionScript.ExportSpringBonesToJson();
            }
            else if (GUILayout.Button("Import"))
            {
                executionScript.ImportSpringBonesFromJson();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Asset");
            if (GUILayout.Button("Q.Save"))
            {
                executionScript.ExportSpringBonesToAsset();
            }
            else if (GUILayout.Button("Q.Load"))
            {
                executionScript.ImportSpringBonesFromAsset();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Remove");
            if (GUILayout.Button("Remove all SpringBones"))
            {
                if (EditorUtility.DisplayDialog("Remove SpringBones", "Are you sure to remove all SpringBones?", "OK", "Cancel"))
                {
                    executionScript.RemoveSpringBones();
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            // Bulk application
            GUILayout.Label("Bulk Application", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            isOpenSpringBonesToConfigureSection = EditorGUILayout.Foldout(isOpenSpringBonesToConfigureSection, "SpringBones");
            if (isOpenSpringBonesToConfigureSection)
            {
                var springBones = executionScript.gameObject.GetComponentsInChildren <VRMSpringBone>();
                if (springBones != null)
                {
                    foreach (var bone in springBones)
                    {
                        springBonesToConfigure[bone] = EditorGUILayout.ToggleLeft(bone.name + ": " + string.Join(", ", bone.RootBones.Select(rb => rb.name)), springBonesToConfigure.ContainsKey(bone) && springBonesToConfigure[bone]);
                    }
                }
            }
            EditorGUI.indentLevel--;

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            sbApplyStiffness = EditorGUILayout.ToggleLeft("Stiffness Force", sbApplyStiffness, toggleLeftLayout);
            sbStiffness      = EditorGUILayout.Slider(sbStiffness, 0.0f, 4.0f);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            sbApplyGravity = EditorGUILayout.ToggleLeft("Gravity Power", sbApplyGravity, toggleLeftLayout);
            sbGravityPower = EditorGUILayout.Slider(sbGravityPower, 0.0f, 2.0f);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            sbApplyGravityDirection = EditorGUILayout.ToggleLeft("Gravity Direction", sbApplyGravityDirection, toggleLeftLayout);
            sbGravityDirection      = EditorGUILayout.Vector3Field(string.Empty, sbGravityDirection);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            sbApplyDragForce = EditorGUILayout.ToggleLeft("Drag Force", sbApplyDragForce, toggleLeftLayout);
            sbDragForce      = EditorGUILayout.Slider(sbDragForce, 0.0f, 1.0f);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            sbApplyRadius = EditorGUILayout.ToggleLeft("Hit Radius", sbApplyRadius, toggleLeftLayout);
            sbRadius      = EditorGUILayout.Slider(sbRadius, 0.0f, 0.5f);
            EditorGUILayout.EndHorizontal();

            // Apply
            foreach (var bone in springBonesToConfigure.Where(kv => kv.Value == true).Select(kv => kv.Key))
            {
                if (sbApplyStiffness)
                {
                    bone.m_stiffnessForce = sbStiffness;
                }
                if (sbApplyGravity)
                {
                    bone.m_gravityPower = sbGravityPower;
                }
                if (sbApplyGravityDirection)
                {
                    bone.m_gravityDir = sbGravityDirection;
                }
                if (sbApplyDragForce)
                {
                    bone.m_dragForce = sbDragForce;
                }
                if (sbApplyRadius)
                {
                    bone.m_hitRadius = sbRadius;
                }
            }
        }