更新obi到7.1
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Obi{
|
||||
|
||||
[CustomEditor(typeof(ObiColliderBase), true), CanEditMultipleObjects]
|
||||
public class ObiColliderEditor : Editor
|
||||
{
|
||||
namespace Obi
|
||||
{
|
||||
|
||||
[CustomEditor(typeof(ObiColliderBase), true), CanEditMultipleObjects]
|
||||
public class ObiColliderEditor : Editor
|
||||
{
|
||||
|
||||
ObiColliderBase collider;
|
||||
SerializedProperty collisionFilter;
|
||||
@@ -16,11 +17,42 @@ namespace Obi{
|
||||
collisionFilter = serializedObject.FindProperty("filter");
|
||||
}
|
||||
|
||||
protected void NonReadableMeshWarning(Mesh mesh)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
Texture2D icon = EditorGUIUtility.Load("icons/console.erroricon.png") as Texture2D;
|
||||
EditorGUILayout.LabelField(new GUIContent("The input mesh is not readable. Read/Write must be enabled in the mesh import settings.", icon), EditorStyles.wordWrappedMiniLabel);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button("Fix now", GUILayout.MaxWidth(100), GUILayout.MinHeight(32)))
|
||||
{
|
||||
string assetPath = AssetDatabase.GetAssetPath(mesh);
|
||||
ModelImporter modelImporter = AssetImporter.GetAtPath(assetPath) as ModelImporter;
|
||||
if (modelImporter != null)
|
||||
{
|
||||
modelImporter.isReadable = true;
|
||||
}
|
||||
modelImporter.SaveAndReimport();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
|
||||
serializedObject.UpdateIfRequiredOrScript();
|
||||
|
||||
foreach (ObiColliderBase t in targets)
|
||||
{
|
||||
ObiMeshShapeTracker meshTracker = t.Tracker as ObiMeshShapeTracker;
|
||||
if (meshTracker != null)
|
||||
{
|
||||
if (meshTracker.targetMesh != null && !meshTracker.targetMesh.isReadable)
|
||||
NonReadableMeshWarning(meshTracker.targetMesh);
|
||||
}
|
||||
}
|
||||
|
||||
var rect = EditorGUILayout.GetControlRect();
|
||||
var label = EditorGUI.BeginProperty(rect, new GUIContent("Collision category"), collisionFilter);
|
||||
@@ -56,8 +88,13 @@ namespace Obi{
|
||||
}
|
||||
EditorGUI.EndProperty();
|
||||
|
||||
DrawPropertiesExcluding(serializedObject, "m_Script", "CollisionMaterial", "filter", "Thickness", "Inverted");
|
||||
|
||||
DrawPropertiesExcluding(serializedObject, "m_Script", "CollisionMaterial", "filter", "Thickness");
|
||||
foreach (ObiColliderBase t in targets)
|
||||
{
|
||||
if (!t.gameObject.isStatic)
|
||||
t.ForceUpdate();
|
||||
}
|
||||
|
||||
// Apply changes to the serializedProperty
|
||||
if (GUI.changed)
|
||||
|
||||
Reference in New Issue
Block a user