44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using UnityEngine;
|
|
using UnityEditor;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
[CustomEditor(typeof(AdvancedPhysicsMaterial))]
|
|
[CanEditMultipleObjects]
|
|
public class AdvancedPhysicsMaterialEditor : Editor {
|
|
public override void OnInspectorGUI(){
|
|
AdvancedPhysicsMaterial mat = (AdvancedPhysicsMaterial)target;
|
|
serializedObject.Update();
|
|
EditorGUIUtility.LookLikeInspector();
|
|
if (mat != null) {
|
|
|
|
EditorGUILayout.LabelField("Selection name: " + mat.name.ToString());
|
|
|
|
var mt = typeof(AdvancedPhysics.Matters);
|
|
var matters = mt.GetFields();
|
|
|
|
int selectedMatter = 0;
|
|
List<string> matterNames = new List<string>();
|
|
for(int i = 0; i < matters.Length; ++i){
|
|
var m = matters[i];
|
|
if(m.FieldType == typeof(AdvancedPhysics.Matter)){
|
|
matterNames.Add(m.Name);
|
|
}
|
|
if(mat.matter != null && (mat.matter == m.GetValue(null))){
|
|
//Debug.Log("LOL " + i);
|
|
selectedMatter = i;
|
|
}
|
|
}
|
|
EditorGUILayout.LabelField("Matter:");
|
|
selectedMatter = EditorGUILayout.Popup(selectedMatter, matterNames.ToArray());
|
|
mat.matter = (AdvancedPhysics.Matter)matters[selectedMatter].GetValue(null);
|
|
|
|
EditorGUILayout.LabelField("Volume (m^3): " + mat.Volume);
|
|
EditorGUILayout.LabelField("Mass (kg): " + mat.Mass);
|
|
mat.UpdateParameters();
|
|
}
|
|
|
|
}
|
|
|
|
}
|