コード例 #1
0
    public override void OnInspectorGUI()
    {
        SABoneCollider boneCollider = (SABoneCollider)target;

        if (boneCollider.edittingBoneColliderProperty == null)
        {
            if (boneCollider.boneColliderProperty != null)
            {
                boneCollider.edittingBoneColliderProperty = boneCollider.boneColliderProperty.Copy();
            }
        }
        SABoneColliderProperty boneColliderProperty = boneCollider.edittingBoneColliderProperty;

        if (boneColliderProperty != null)
        {
            SplitProperty splitProperty = boneColliderProperty.splitProperty;
            if (splitProperty != null)
            {
                GUILayout.Label("Split", EditorStyles.boldLabel);
                SABoneColliderEditorCommon.SplitInspectorGUI(splitProperty);
            }

            EditorGUILayout.Separator();
            GUILayout.Label("Reducer", EditorStyles.boldLabel);
            SAColliderBuilderEditorCommon.ReducerInspectorGUI(boneColliderProperty.reducerProperty,
                                                              ReducerOption.Advanced | ReducerOption.ColliderToChild);

            GUI.enabled = boneColliderProperty.reducerProperty.shapeType != ShapeType.None;
            EditorGUILayout.Separator();
            GUILayout.Label("Collider", EditorStyles.boldLabel);
            SAColliderBuilderEditorCommon.ColliderInspectorGUI(boneColliderProperty.colliderProperty, ColliderOption.CreateAsset);
            EditorGUILayout.Separator();
            GUILayout.Label("Rigidbody", EditorStyles.boldLabel);
            SAColliderBuilderEditorCommon.RigidbodyInspectorGUI(boneColliderProperty.rigidbodyProperty);
            GUI.enabled = true;
        }

        EditorGUILayout.Separator();

        if (boneColliderProperty != null)
        {
            BoneProperty boneProperty = boneColliderProperty.boneProperty;
            if (boneProperty != null)
            {
                boneProperty.recursivery = EditorGUILayout.Toggle("Recursivery", boneProperty.recursivery);
            }
        }

        boneCollider.cleanupModified = EditorGUILayout.Toggle("Cleanup Modified", boneCollider.cleanupModified);
        boneCollider.isDebug         = EditorGUILayout.Toggle("Is Debug", boneCollider.isDebug);

        EditorGUILayout.Separator();

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Set Default"))
        {
            if (boneCollider.defaultBoneColliderProperty != null)
            {
                float beginTime = Time.realtimeSinceStartup;
                boneCollider.boneColliderProperty         = boneCollider.defaultBoneColliderProperty.Copy();
                boneCollider.edittingBoneColliderProperty = null;
                Process(boneCollider);
                boneCollider.cleanupModified = false;
                boneCollider.isDebug         = false;
                SABoneColliderEditorCommon.UnmarkManualProcessingToParent(boneCollider);
                boneCollider.ResetModifyName();
                float endTime = Time.realtimeSinceStartup;
                Debug.Log("Processed.[" + (endTime - beginTime) + " sec]");
            }
        }
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Revert"))
        {
            boneCollider.edittingBoneColliderProperty = null;
        }
        if (GUILayout.Button("Cleanup"))
        {
            if (boneCollider.edittingBoneColliderProperty != null)
            {
                boneCollider.boneColliderProperty         = boneCollider.edittingBoneColliderProperty;
                boneCollider.edittingBoneColliderProperty = null;
                Cleanup(boneCollider);
                boneCollider.cleanupModified = false;
                boneCollider.isDebug         = false;
                Debug.Log("Cleanuped.");
            }
        }
        if (GUILayout.Button("Process"))
        {
            if (boneCollider.edittingBoneColliderProperty != null)
            {
                boneCollider.boneColliderProperty         = boneCollider.edittingBoneColliderProperty;
                boneCollider.edittingBoneColliderProperty = null;
                float beginTime = Time.realtimeSinceStartup;
                Process(boneCollider);
                boneCollider.cleanupModified = false;
                float endTime = Time.realtimeSinceStartup;
                Debug.Log("Processed.[" + (endTime - beginTime) + " sec]");
            }
        }
        EditorGUILayout.EndHorizontal();
    }