Beispiel #1
0
    public override void OnInspectorGUI()
    {
        SAMeshColliderBuilder meshColliderBuilder = (SAMeshColliderBuilder)target;

        if (meshColliderBuilder.edittingMeshColliderBuilderProperty == null)
        {
            if (meshColliderBuilder.meshColliderBuilderProperty != null)
            {
                meshColliderBuilder.edittingMeshColliderBuilderProperty = meshColliderBuilder.meshColliderBuilderProperty.Copy();
            }
        }
        SAMeshColliderBuilderProperty meshColliderBuilderProperty = meshColliderBuilder.edittingMeshColliderBuilderProperty;

        if (meshColliderBuilderProperty != null)
        {
            SplitProperty splitProperty = meshColliderBuilderProperty.splitProperty;
            if (splitProperty != null)
            {
                GUILayout.Label("Split", EditorStyles.boldLabel);
                // Split Material
                splitProperty.splitMaterialEnabled = EditorGUILayout.Toggle("Split Material", splitProperty.splitMaterialEnabled);
                // Split Primitive
                splitProperty.splitPrimitiveEnabled = EditorGUILayout.Toggle("Split Primitive", splitProperty.splitPrimitiveEnabled);
                // Split Polygon Normal
                EditorGUILayout.BeginHorizontal();
                splitProperty.splitPolygonNormalEnabled = EditorGUILayout.Toggle("Split Polygon Normal", splitProperty.splitPolygonNormalEnabled);
                GUI.enabled = splitProperty.splitPolygonNormalEnabled;
                splitProperty.splitPolygonNormalAngle = EditorGUILayout.Slider(splitProperty.splitPolygonNormalAngle, 0.0f, 180.0f);
                GUI.enabled = true;
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.Separator();
            GUILayout.Label("Reducer", EditorStyles.boldLabel);
            SAColliderBuilderEditorCommon.ReducerInspectorGUI(meshColliderBuilderProperty.reducerProperty, ReducerOption.None);

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

        EditorGUILayout.Separator();
        if (meshColliderBuilderProperty != null)
        {
            meshColliderBuilderProperty.modifyNameEnabled = EditorGUILayout.Toggle("Modify Name", meshColliderBuilderProperty.modifyNameEnabled);
        }
        meshColliderBuilder.cleanupModified = EditorGUILayout.Toggle("Cleanup Modified", meshColliderBuilder.cleanupModified);
        meshColliderBuilder.isDebug         = EditorGUILayout.Toggle("Is Debug", meshColliderBuilder.isDebug);

        EditorGUILayout.Separator();

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Revert"))
        {
            meshColliderBuilder.edittingMeshColliderBuilderProperty = null;
        }
        if (GUILayout.Button("Cleanup"))
        {
            if (meshColliderBuilder.edittingMeshColliderBuilderProperty != null)
            {
                meshColliderBuilder.meshColliderBuilderProperty         = meshColliderBuilder.edittingMeshColliderBuilderProperty;
                meshColliderBuilder.edittingMeshColliderBuilderProperty = null;
                Cleanup(meshColliderBuilder);
                meshColliderBuilder.cleanupModified = false;
                meshColliderBuilder.isDebug         = false;
                Debug.Log("Cleanuped.");
            }
        }
        if (GUILayout.Button("Process"))
        {
            if (meshColliderBuilder.edittingMeshColliderBuilderProperty != null)
            {
                meshColliderBuilder.meshColliderBuilderProperty         = meshColliderBuilder.edittingMeshColliderBuilderProperty;
                meshColliderBuilder.edittingMeshColliderBuilderProperty = null;
                float beginTime = Time.realtimeSinceStartup;
                Process(meshColliderBuilder);
                meshColliderBuilder.cleanupModified = false;
                meshColliderBuilder.isDebug         = false;
                float endTime = Time.realtimeSinceStartup;
                Debug.Log("Processed.[" + (endTime - beginTime) + " sec]");
            }
        }
        EditorGUILayout.EndHorizontal();
    }
    public override void OnInspectorGUI()
    {
        SABoneColliderBuilder boneColliderBuilder = (SABoneColliderBuilder)target;

        if (boneColliderBuilder.edittingBoneColliderBuilderProperty == null)
        {
            if (boneColliderBuilder.boneColliderBuilderProperty != null)
            {
                boneColliderBuilder.edittingBoneColliderBuilderProperty = boneColliderBuilder.boneColliderBuilderProperty.Copy();
            }
        }

        SABoneColliderBuilderProperty boneColliderBuilderProperty = boneColliderBuilder.edittingBoneColliderBuilderProperty;

        if (boneColliderBuilderProperty != null)
        {
            SplitProperty splitProperty = boneColliderBuilderProperty.splitProperty;

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

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

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

        EditorGUILayout.Separator();

        if (boneColliderBuilderProperty != null)
        {
            boneColliderBuilderProperty.modifyNameEnabled = EditorGUILayout.Toggle("Modify Name", boneColliderBuilderProperty.modifyNameEnabled);
        }

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

        EditorGUILayout.Separator();

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        if (GUILayout.Button("Revert"))
        {
            boneColliderBuilder.edittingBoneColliderBuilderProperty = null;
        }

        if (GUILayout.Button("Cleanup"))
        {
            if (boneColliderBuilder.edittingBoneColliderBuilderProperty != null)
            {
                boneColliderBuilder.boneColliderBuilderProperty         = boneColliderBuilder.edittingBoneColliderBuilderProperty;
                boneColliderBuilder.edittingBoneColliderBuilderProperty = null;
                Cleanup(boneColliderBuilder);
                boneColliderBuilder.cleanupModified = false;
                boneColliderBuilder.isDebug         = false;
                Debug.Log("Cleanuped.");
            }
        }

        if (GUILayout.Button("Process"))
        {
            if (boneColliderBuilder.edittingBoneColliderBuilderProperty != null)
            {
                boneColliderBuilder.boneColliderBuilderProperty         = boneColliderBuilder.edittingBoneColliderBuilderProperty;
                boneColliderBuilder.edittingBoneColliderBuilderProperty = null;
                float beginTime = Time.realtimeSinceStartup;
                Process(boneColliderBuilder);
                boneColliderBuilder.cleanupModified = false;
                boneColliderBuilder.isDebug         = false;
                float endTime = Time.realtimeSinceStartup;
                Debug.Log("Processed.[" + (endTime - beginTime) + " sec]");
            }
        }

        EditorGUILayout.EndHorizontal();
    }