public override void OnInspectorGUI() { serializedEntitiy.Update(); EditorGUILayout.PropertyField(type); PhysicsEntityType t = (PhysicsEntityType)type.enumValueIndex; if (t != initType) { initType = t; physicsEntity.Type = t; } if (t == PhysicsEntityType.Barrier) { //Debug.Log("serializedEntitiyInspector type:" + type.enumValueIndex); EditorGUILayout.PropertyField(tid); } else if (t == PhysicsEntityType.Car) { EditorGUILayout.PropertyField(goHead); } serializedEntitiy.ApplyModifiedProperties(); }
void OnEnable() { Debug.Log("serializedEntitiyInspector OnEnable"); serializedEntitiy = new SerializedObject(target); physicsEntity = target as PhysicsEntity; type = serializedEntitiy.FindProperty("_type"); initType = (PhysicsEntityType)type.enumValueIndex; goHead = serializedEntitiy.FindProperty("goHead"); tid = serializedEntitiy.FindProperty("tid"); }
void ChangeMaterials(PhysicsEntityType type) { mr = transform.GetComponentsInChildren <MeshRenderer>(); int num = 0; num = (int)type; for (int i = 0; i < mr.Length; i++) { if (num < materials.Length) { // mr[i].material = materials[0]; mr[i].material = materials[num]; } // else } }
public GameObject CreatePhysicsGameObject(string name, PhysicsEntityType type) { GameObject obj = CreateWithSelection(); if (obj == null) { return(null); } obj.name = name; obj.tag = PhysicsType.PhysicsEntity.ToString(); PhysicsEntity entityBhv = obj.AddComponent <PhysicsEntity>(); entityBhv.Type = type; return(obj); }