chrisgregan
10 years ago
24 changed files with 54 additions and 219 deletions
@ -1,50 +0,0 @@
|
||||
using UnityEditor; |
||||
using UnityEditorInternal; |
||||
using UnityEngine; |
||||
using System; |
||||
using System.Collections; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
|
||||
[CustomPropertyDrawer (typeof(TargetObject), true)] |
||||
public class TargetObjectDrawer : PropertyDrawer |
||||
{ |
||||
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) |
||||
{ |
||||
EditorGUI.BeginProperty(position, label, property); |
||||
|
||||
SerializedProperty targetTypeProp = property.FindPropertyRelative("targetType"); |
||||
SerializedProperty otherGameObjectProp = property.FindPropertyRelative("otherGameObject"); |
||||
|
||||
EditorGUI.PropertyField(position, targetTypeProp, new GUIContent("Game Object", "Select either the owner game object or another object in the scene.")); |
||||
|
||||
if (targetTypeProp.enumValueIndex == 0) |
||||
{ |
||||
otherGameObjectProp.objectReferenceValue = null; |
||||
} |
||||
else |
||||
{ |
||||
Rect objectFieldRect = position; |
||||
objectFieldRect.y += EditorGUIUtility.singleLineHeight; |
||||
objectFieldRect.height = EditorGUIUtility.singleLineHeight; |
||||
EditorGUI.PropertyField(objectFieldRect, otherGameObjectProp, new GUIContent(" ")); |
||||
} |
||||
|
||||
EditorGUI.EndProperty(); |
||||
} |
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) |
||||
{ |
||||
// Adjust property height if also showing an object reference field |
||||
float propHeight = base.GetPropertyHeight(property, label); |
||||
SerializedProperty targetTypeProp = property.FindPropertyRelative("targetType"); |
||||
if (targetTypeProp.enumValueIndex == 1) |
||||
{ |
||||
return propHeight * 2; |
||||
} |
||||
return propHeight; |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 88ec756e97d1b47d2bde7ef335130f58 |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
@ -1,33 +0,0 @@
|
||||
using UnityEngine; |
||||
using System.Collections; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
public enum TargetObjectType |
||||
{ |
||||
Owner, |
||||
Other |
||||
} |
||||
|
||||
[System.Serializable] |
||||
public class TargetObject |
||||
{ |
||||
public TargetObjectType targetType; |
||||
public GameObject otherGameObject; |
||||
|
||||
public virtual string GetSummary() |
||||
{ |
||||
if (targetType == TargetObjectType.Owner) |
||||
{ |
||||
return "Owner"; |
||||
} |
||||
else if (otherGameObject != null) |
||||
{ |
||||
return otherGameObject.name; |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 1695c9a1c253c446ebb3379cdfa33596 |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
Loading…
Reference in new issue