示例#1
0
        public override void OnInspectorGUI()
        {
            MagicaMeshCloth scr = target as MagicaMeshCloth;

            // データ状態
            EditorInspectorUtility.DispVersionStatus(scr);
            EditorInspectorUtility.DispDataStatus(scr);

            serializedObject.Update();

            // データ検証
            if (EditorApplication.isPlaying == false)
            {
                VerifyData();
            }

            // モニターボタン
            EditorInspectorUtility.MonitorButtonInspector();

            // メイン
            MainInspector();

            // コライダー
            ColliderInspector();

            // パラメータ
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorPresetUtility.DrawPresetButton(scr, scr.Params);
            {
                var cparam = serializedObject.FindProperty("clothParams");
                if (EditorInspectorUtility.RadiusInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.Radius);
                }
                if (EditorInspectorUtility.MassInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.Mass);
                }
                if (EditorInspectorUtility.GravityInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.Gravity);
                }
                if (EditorInspectorUtility.ExternalForceInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.ExternalForce);
                }
                if (EditorInspectorUtility.DragInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.Drag);
                }
                if (EditorInspectorUtility.MaxVelocityInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.MaxVelocity);
                }
                if (EditorInspectorUtility.WorldInfluenceInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.WorldInfluence);
                }
                if (EditorInspectorUtility.DistanceDisableInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.DistanceDisable);
                }
                if (EditorInspectorUtility.ClampDistanceInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.ClampDistance);
                }
                if (EditorInspectorUtility.ClampPositionInspector(cparam, false))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.ClampPosition);
                }
                if (EditorInspectorUtility.ClampRotationInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.ClampRotation);
                }
                if (EditorInspectorUtility.RestoreDistanceInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.RestoreDistance);
                }
                if (EditorInspectorUtility.RestoreRotationInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.RestoreRotation);
                }
                if (EditorInspectorUtility.TriangleBendInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.TriangleBend);
                }
                //if (EditorInspectorUtility.VolumeInspector(cparam))
                //    scr.Params.SetChangeParam(ClothParams.ParamType.Volume);
                if (EditorInspectorUtility.CollisionInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.ColliderCollision);
                }
                if (EditorInspectorUtility.PenetrationInspector(serializedObject, cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.Penetration);
                }
                //if (EditorInspectorUtility.BaseSkinningInspector(serializedObject, cparam))
                //    scr.Params.SetChangeParam(ClothParams.ParamType.BaseSkinning);
                if (EditorInspectorUtility.RotationInterpolationInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.RotationInterpolation);
                }
            }
            serializedObject.ApplyModifiedProperties();

            // データ作成
            if (EditorApplication.isPlaying == false)
            {
                EditorGUI.BeginDisabledGroup(CheckCreate() == false);

                EditorGUILayout.Space();
                EditorGUILayout.Space();

                GUI.backgroundColor = Color.red;
                if (GUILayout.Button("Create"))
                {
                    Undo.RecordObject(scr, "CreateMeshCloth");
                    CreateData();
                }
                GUI.backgroundColor = Color.white;

                EditorGUI.EndDisabledGroup();
            }
            else
            {
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                GUI.backgroundColor = Color.blue;
                if (GUILayout.Button("Reset Position"))
                {
                    scr.ResetCloth();
                }
                GUI.backgroundColor = Color.white;
            }
            EditorGUILayout.Space();
        }
        public override void OnInspectorGUI()
        {
            MagicaMeshSpring scr = target as MagicaMeshSpring;

            // データ状態
            EditorInspectorUtility.DispVersionStatus(scr);
            EditorInspectorUtility.DispDataStatus(scr);

            serializedObject.Update();
            Undo.RecordObject(scr, "CreateMeshSpring");

            // データ検証
            if (EditorApplication.isPlaying == false)
            {
                VerifyData();
            }

            // モニターボタン
            EditorInspectorUtility.MonitorButtonInspector();

            EditorGUI.BeginChangeCheck();

            // メイン
            MainInspector();

            // パラメータ
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorPresetUtility.DrawPresetButton(scr, scr.Params);
            {
                var cparam = serializedObject.FindProperty("clothParams");
                if (EditorInspectorUtility.GravityInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.Gravity);
                }
                if (EditorInspectorUtility.ExternalForceInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.ExternalForce);
                }
                if (EditorInspectorUtility.DragInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.Drag);
                }
                if (EditorInspectorUtility.MaxVelocityInspector(cparam))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.MaxVelocity);
                }
                if (EditorInspectorUtility.WorldInfluenceInspector(cparam, scr.HasChangedParam(ClothParams.ParamType.WorldInfluence)))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.WorldInfluence);
                }
                if (EditorInspectorUtility.DistanceDisableInspector(cparam, scr.HasChangedParam(ClothParams.ParamType.DistanceDisable)))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.DistanceDisable);
                }
                if (EditorInspectorUtility.ClampPositionInspector(cparam, true, scr.HasChangedParam(ClothParams.ParamType.ClampPosition)))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.ClampPosition);
                }
                if (EditorInspectorUtility.FullSpringInspector(cparam, scr.HasChangedParam(ClothParams.ParamType.Spring)))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.Spring);
                }
                if (EditorInspectorUtility.AdjustRotationInspector(cparam, scr.HasChangedParam(ClothParams.ParamType.AdjustRotation)))
                {
                    scr.Params.SetChangeParam(ClothParams.ParamType.AdjustRotation);
                }
            }
            serializedObject.ApplyModifiedProperties();

            // データ作成
            if (EditorApplication.isPlaying == false)
            {
                EditorGUI.BeginDisabledGroup(CheckCreate() == false);

                EditorGUILayout.Space();
                EditorGUILayout.Space();

                GUI.backgroundColor = Color.red;
                if (GUILayout.Button("Create"))
                {
                    Undo.RecordObject(scr, "CreateMeshSpringData");
                    CreateData();
                }
                GUI.backgroundColor = Color.white;

                EditorGUI.EndDisabledGroup();
            }
            else
            {
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                GUI.backgroundColor = Color.blue;
                if (GUILayout.Button("Reset Position"))
                {
                    scr.ResetCloth();
                }
                GUI.backgroundColor = Color.white;
            }
            EditorGUILayout.Space();

            if (EditorGUI.EndChangeCheck())
            {
                // Sceneビュー更新
                SceneView.RepaintAll();
            }
        }