Update
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff8be46c4ec4e964281696c4d021723b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,27 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Editor.Inspectors.Objects.CharacterAssist
|
||||
{
|
||||
using Opsive.UltimateCharacterController.Objects.CharacterAssist;
|
||||
using UnityEditor;
|
||||
|
||||
/// <summary>
|
||||
/// Custom inspector for the HealthPickup component.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(HealthPickup))]
|
||||
public class HealthPickupInspector : ObjectPickupInspector
|
||||
{
|
||||
/// <summary>
|
||||
/// Draws the object pickup fields.
|
||||
/// </summary>
|
||||
protected override void DrawObjectPickupFields()
|
||||
{
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_HealthAmount"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_AlwaysPickup"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbaea50abf9df4849b4aaa1fd3f8d1ae
|
||||
timeCreated: 1501619173
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,426 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Editor.Inspectors.Objects.CharacterAssist
|
||||
{
|
||||
using Opsive.Shared.Inventory;
|
||||
using Opsive.UltimateCharacterController.Editor.Inspectors.StateSystem;
|
||||
using Opsive.UltimateCharacterController.Editor.Inspectors.Utility;
|
||||
using Opsive.UltimateCharacterController.Items;
|
||||
using Opsive.UltimateCharacterController.Objects.CharacterAssist;
|
||||
using Opsive.UltimateCharacterController.StateSystem;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom inspector for the ItemPickupBase component.
|
||||
/// </summary>
|
||||
public abstract class ItemPickupBaseInspector : ObjectPickupInspector
|
||||
{
|
||||
protected const int c_SlotRowHeight = 22;
|
||||
private const int c_SlotRowPadding = 4;
|
||||
private const string c_EditorPrefsSelectedPickupSetIndexKey = "Opsive.UltimateCharacterController.Editor.Inspectors.ItemPickup.SelectedPickupSetIndex";
|
||||
private const string c_EditorPrefsSelectedPickupSetStateIndexKey = "Opsive.UltimateCharacterController.Editor.Inspectors.ItemPickup.SelectedPickupSetStateIndex";
|
||||
private string SelectedPickupSetIndexKey { get { return c_EditorPrefsSelectedPickupSetIndexKey + "." + target.GetType() + "." + target.name; } }
|
||||
|
||||
private ItemPickupBase m_ItemPickup;
|
||||
private ReorderableList m_ReorderablePickupSet;
|
||||
private ReorderableList m_ReorderablePickupSetStateList;
|
||||
private int m_SlotCount = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Determine the slot count.
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
m_ItemPickup = target as ItemPickupBase;
|
||||
if (m_ItemPickup == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_ItemPickup.ItemPickupSet == null) {
|
||||
m_ItemPickup.ItemPickupSet = new ItemPickupBase.PickupSet[0];
|
||||
} else if (m_ItemPickup.ItemPickupSet.Length > 0) {
|
||||
m_SlotCount = m_ItemPickup.ItemPickupSet[0].ItemSet.Slots.Length;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the object pickup fields.
|
||||
/// </summary>
|
||||
protected override void DrawObjectPickupFields()
|
||||
{
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_AlwaysPickup"));
|
||||
|
||||
if (Foldout("Item Pickup Set")) {
|
||||
EditorGUI.indentLevel++;
|
||||
// Only the character can determine the slot count. Because the ItemPickup isn't attached to a character the slot count
|
||||
// needs to be manually specified. OnEnable will determine the slot count of any existing ItemSets so this only needs to be done
|
||||
// when there is a change or no PickupSets specified.
|
||||
var slotCount = EditorGUILayout.IntField("Slot Count", m_SlotCount);
|
||||
if (m_SlotCount != slotCount) {
|
||||
m_SlotCount = slotCount;
|
||||
var pickupSet = m_ItemPickup.ItemPickupSet;
|
||||
for (int i = 0; i < pickupSet.Length; ++i) {
|
||||
UpdateSlotCount(pickupSet, i);
|
||||
}
|
||||
}
|
||||
DrawItemPickupSetHeaderFields();
|
||||
var itemListProperty = PropertyFromName("m_ItemPickupSet");
|
||||
if (itemListProperty.arraySize == 0) {
|
||||
EditorGUILayout.HelpBox("No Pickup Set specified. The character must have a Pickup Set specified in order to equip the item.", MessageType.Info);
|
||||
}
|
||||
|
||||
if (m_ReorderablePickupSet == null) {
|
||||
m_ReorderablePickupSet = new ReorderableList(serializedObject, itemListProperty, true, false, true, true);
|
||||
m_ReorderablePickupSet.drawHeaderCallback = (Rect rect) =>
|
||||
{
|
||||
GUI.Label(rect, "Pickup Sets (select row to edit)");
|
||||
};
|
||||
m_ReorderablePickupSet.drawElementCallback = OnPickupSetElementDraw;
|
||||
m_ReorderablePickupSet.onAddCallback += OnPickupSetListAdd;
|
||||
m_ReorderablePickupSet.onSelectCallback = (ReorderableList list) =>
|
||||
{
|
||||
EditorPrefs.SetInt(SelectedPickupSetIndexKey, list.index);
|
||||
// The pickup set's state list should start out fresh so a reference doesn't have to be cached for each pickup set.
|
||||
m_ReorderablePickupSetStateList = null;
|
||||
};
|
||||
m_ReorderablePickupSet.onRemoveCallback = OnPickupSetListRemove;
|
||||
}
|
||||
if (m_ItemPickup.ItemPickupSet.Length > 0) {
|
||||
m_ReorderablePickupSet.elementHeight = (c_SlotRowHeight + c_SlotRowPadding) * (m_SlotCount + 2) + 21;
|
||||
} else {
|
||||
m_ReorderablePickupSet.elementHeight = c_SlotRowHeight;
|
||||
}
|
||||
var listRect = GUILayoutUtility.GetRect(0, m_ReorderablePickupSet.GetHeight());
|
||||
listRect.x += EditorGUI.indentLevel * InspectorUtility.IndentWidth;
|
||||
listRect.xMax -= EditorGUI.indentLevel * InspectorUtility.IndentWidth;
|
||||
if (EditorPrefs.GetInt(SelectedPickupSetIndexKey, -1) != -1) {
|
||||
m_ReorderablePickupSet.index = EditorPrefs.GetInt(SelectedPickupSetIndexKey, -1);
|
||||
}
|
||||
m_ReorderablePickupSet.DoList(listRect);
|
||||
|
||||
if (m_ReorderablePickupSet.index != -1 && m_ReorderablePickupSet.index < m_ItemPickup.ItemPickupSet.Length) {
|
||||
GUI.enabled = !Application.isPlaying;
|
||||
DrawSelectedPickupSet(m_ItemPickup.ItemPickupSet[m_ReorderablePickupSet.index], m_ReorderablePickupSet.index);
|
||||
GUI.enabled = true;
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
DrawItemIdentifierInspector();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the header fields for the ItemPickupSet.
|
||||
/// </summary>
|
||||
protected virtual void DrawItemPickupSetHeaderFields() { }
|
||||
|
||||
/// <summary>
|
||||
/// Draws the inspector for the ItemIdentifier list.
|
||||
/// </summary>
|
||||
protected virtual void DrawItemIdentifierInspector() { }
|
||||
|
||||
/// <summary>
|
||||
/// Draws the PickupSet ReordableList element.
|
||||
/// </summary>
|
||||
private void OnPickupSetElementDraw(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
GUI.enabled = !Application.isPlaying;
|
||||
|
||||
var pickupSet = m_ItemPickup.ItemPickupSet;
|
||||
|
||||
// The number of slots may have changed since the ItemIdentifier was added.
|
||||
UpdateSlotCount(pickupSet, index);
|
||||
|
||||
// Draw a row background.
|
||||
var rowRect = rect;
|
||||
rowRect.y += c_SlotRowPadding / 2;
|
||||
rowRect.height -= c_SlotRowPadding;
|
||||
GUI.Label(rowRect, "", InspectorStyles.FieldStyle);
|
||||
|
||||
// Draw the ItemSet title.
|
||||
var elementTitleRect = rowRect;
|
||||
elementTitleRect.y += 2;
|
||||
elementTitleRect.height = 19;
|
||||
GUI.Label(elementTitleRect, "PickupSet " + index, InspectorStyles.CenterBoldLabel);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
// Each slot should have its own lighter background.
|
||||
var slotRect = rowRect;
|
||||
slotRect.x += 4;
|
||||
slotRect.width -= 8;
|
||||
slotRect.height = c_SlotRowHeight;
|
||||
for (int i = 0; i < m_SlotCount + 2; ++i) {
|
||||
slotRect.y = elementTitleRect.yMax + i * c_SlotRowHeight + 2;
|
||||
var color = GUI.color;
|
||||
GUI.color -= new Color(0.15f, 0.15f, 0.15f, 0);
|
||||
GUI.Label(slotRect, "", InspectorStyles.ItemStyle);
|
||||
GUI.color = color;
|
||||
|
||||
var labelRect = slotRect;
|
||||
labelRect.x += 2;
|
||||
labelRect.y += 4;
|
||||
|
||||
var objRect = slotRect;
|
||||
objRect.x += 46;
|
||||
objRect.width -= 52;
|
||||
objRect.y += (objRect.height - 16) / 2 + 1;
|
||||
objRect.height = 16;
|
||||
if (i == 0) { // Draw the item field.
|
||||
GUI.Label(labelRect, "Item");
|
||||
pickupSet[index].Item = EditorGUI.ObjectField(objRect, pickupSet[index].Item, typeof(GameObject), false) as GameObject;
|
||||
} else if (i == 1) {
|
||||
GUI.Label(labelRect, "Category");
|
||||
GUI.enabled = pickupSet[index].Item == null && !Application.isPlaying;
|
||||
DrawAvailableCategories(pickupSet[index], objRect);
|
||||
GUI.enabled = !Application.isPlaying;
|
||||
} else { // Draw the slot field.
|
||||
GUI.Label(labelRect, "Slot " + (i - 2));
|
||||
pickupSet[index].ItemSet.Slots[i - 2] = EditorGUI.ObjectField(objRect, pickupSet[index].ItemSet.Slots[i - 2], typeof(ItemDefinitionBase), false) as ItemDefinitionBase;
|
||||
|
||||
// Automatically fill in the ItemDefinition for the specified item.
|
||||
if (pickupSet[index].Item != null) {
|
||||
var item = pickupSet[index].Item.GetComponent<Item>();
|
||||
if (item != null && item.SlotID < pickupSet[index].ItemSet.Slots.Length && pickupSet[index].ItemSet.Slots[item.SlotID] != item.ItemDefinition) {
|
||||
pickupSet[index].ItemSet.Slots[item.SlotID] = item.ItemDefinition;
|
||||
EditorUtility.SetDirty(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_ItemPickup.ItemPickupSet = pickupSet;
|
||||
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
InspectorUtility.SetDirty(target);
|
||||
}
|
||||
GUI.enabled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the field that displays the available categories.
|
||||
/// </summary>
|
||||
/// <param name="pickupSet">The PickupSet that should be drawn.</param>
|
||||
/// <param name="objRect">The location the categories should draw.</param>
|
||||
protected abstract void DrawAvailableCategories(ItemPickupBase.PickupSet pickupSet, Rect objRect);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the PickupSet element at the specified index to the current SlotCount.
|
||||
/// </summary>
|
||||
private void UpdateSlotCount(ItemPickupBase.PickupSet[] pickupSet, int index)
|
||||
{
|
||||
if (pickupSet[index].ItemSet.Slots == null || pickupSet[index].ItemSet.Slots.Length != m_SlotCount) {
|
||||
var slots = pickupSet[index].ItemSet.Slots;
|
||||
System.Array.Resize<ItemDefinitionBase>(ref slots, m_SlotCount);
|
||||
pickupSet[index].ItemSet.Slots = slots;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new PickupSet element.
|
||||
/// </summary>
|
||||
private void OnPickupSetListAdd(ReorderableList reorderableList)
|
||||
{
|
||||
var index = reorderableList.count;
|
||||
var list = new List<ItemPickupBase.PickupSet>(m_ItemPickup.ItemPickupSet);
|
||||
list.Add(new ItemPickupBase.PickupSet());
|
||||
m_ItemPickup.ItemPickupSet = list.ToArray();
|
||||
reorderableList.index = index;
|
||||
m_ItemPickup.ItemPickupSet[index].ItemSet.Slots = new ItemDefinitionBase[m_SlotCount];
|
||||
EditorPrefs.SetInt(SelectedPickupSetIndexKey, reorderableList.index);
|
||||
|
||||
// The last element should start enabled if it is the first element.
|
||||
if (index == 0) {
|
||||
m_ItemPickup.ItemPickupSet[index].ItemSet.Enabled = true;
|
||||
}
|
||||
InspectorUtility.SetDirty(target);
|
||||
// The pickup set's state list should start out fresh so a reference doesn't have to be cached for each pickup set.
|
||||
m_ReorderablePickupSetStateList = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The ReordableList remove button has been pressed. Remove the selected PickupSet.
|
||||
/// </summary>
|
||||
private void OnPickupSetListRemove(ReorderableList reorderableList)
|
||||
{
|
||||
var itemPickupSetProperty = PropertyFromName("m_ItemPickupSet");
|
||||
itemPickupSetProperty.DeleteArrayElementAtIndex(reorderableList.index);
|
||||
|
||||
// Update the index to point to no longer point to the now deleted pickup set.
|
||||
reorderableList.index = reorderableList.index - 1;
|
||||
if (reorderableList.index == -1 && m_ItemPickup.ItemPickupSet.Length > 0) {
|
||||
reorderableList.index = 0;
|
||||
}
|
||||
EditorPrefs.SetInt(SelectedPickupSetIndexKey, reorderableList.index);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
// The pickup set's state list should start out fresh so a reference doesn't have to be cached for each pickup set.
|
||||
m_ReorderablePickupSetStateList = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the specified item set.
|
||||
/// </summary>
|
||||
private void DrawSelectedPickupSet(ItemPickupBase.PickupSet pickupSet, int index)
|
||||
{
|
||||
GUILayout.Label("Pickup Set " + index, InspectorStyles.CenterBoldLabel);
|
||||
|
||||
pickupSet.Item = (GameObject)EditorGUILayout.ObjectField("Item", pickupSet.Item, typeof(GameObject), false);
|
||||
if (pickupSet.Item != null) {
|
||||
// Automatically fill in the ItemDefinition for the specified item.
|
||||
var item = pickupSet.Item.GetComponent<Item>();
|
||||
if (item != null && item.SlotID < pickupSet.ItemSet.Slots.Length && pickupSet.ItemSet.Slots[item.SlotID] != item.ItemDefinition) {
|
||||
pickupSet.ItemSet.Slots[item.SlotID] = item.ItemDefinition;
|
||||
EditorUtility.SetDirty(target);
|
||||
}
|
||||
}
|
||||
|
||||
GUI.enabled = pickupSet.Item == null && !Application.isPlaying;
|
||||
DrawAvailableCategories(pickupSet, new Rect());
|
||||
GUI.enabled = !Application.isPlaying;
|
||||
|
||||
pickupSet.ItemSet.State = EditorGUILayout.TextField(new GUIContent("State", "Optionally specify a state that the character should switch to when the Item Set is active."), pickupSet.ItemSet.State);
|
||||
// Draws all of the slots ItemIdentifiers.
|
||||
for (int i = 0; i < m_SlotCount; ++i) {
|
||||
pickupSet.ItemSet.Slots[i] = (ItemDefinitionBase)EditorGUILayout.ObjectField("Slot " + i, pickupSet.ItemSet.Slots[i], typeof(ItemDefinitionBase), false);
|
||||
}
|
||||
pickupSet.Default = EditorGUILayout.Toggle(new GUIContent("Default", "True if the ItemSet is the default Item Set."), pickupSet.Default);
|
||||
pickupSet.ItemSet.Enabled = EditorGUILayout.Toggle(new GUIContent("Enabled", "True if the ItemSet can be equipped."), pickupSet.ItemSet.Enabled);
|
||||
pickupSet.ItemSet.CanSwitchTo = EditorGUILayout.Toggle(new GUIContent("Can Switch To", "True if the ItemSet can be switched to by the EquipNext/EquipPrevious abilities."), pickupSet.ItemSet.CanSwitchTo);
|
||||
pickupSet.ItemSet.DisabledIndex = EditorGUILayout.IntField(new GUIContent("Disabled Index", "The ItemSet that should be activated if the current ItemSet is disabled."), pickupSet.ItemSet.DisabledIndex);
|
||||
|
||||
if (InspectorUtility.Foldout(pickupSet, new GUIContent("States"), false)) {
|
||||
// The MovementType class derives from system.object at the base level and reorderable lists can only operate on Unity objects. To get around this restriction
|
||||
// create a dummy array within a Unity object that corresponds to the number of elements within the ability's state list. When the reorderable list is drawn
|
||||
// the ability object will be used so it's like the dummy object never existed.
|
||||
var gameObject = new GameObject();
|
||||
var stateIndexHelper = gameObject.AddComponent<StateInspectorHelper>();
|
||||
stateIndexHelper.StateIndexData = new int[pickupSet.ItemSet.States.Length];
|
||||
for (int i = 0; i < stateIndexHelper.StateIndexData.Length; ++i) {
|
||||
stateIndexHelper.StateIndexData[i] = i;
|
||||
}
|
||||
var stateIndexSerializedObject = new SerializedObject(stateIndexHelper);
|
||||
m_ReorderablePickupSetStateList = StateInspector.DrawStates(m_ReorderablePickupSetStateList, serializedObject,
|
||||
stateIndexSerializedObject.FindProperty("m_StateIndexData"),
|
||||
GetSelectedPickupSetStateIndexKey(index), OnPickupSetStateListDraw, OnPickupSetStateListAdd,
|
||||
OnPickupSetStateListReorder, OnPickupSetStateListRemove);
|
||||
DestroyImmediate(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the state index key for the specified pickup set type.
|
||||
/// </summary>
|
||||
private string GetSelectedPickupSetStateIndexKey(int itemSetIndex)
|
||||
{
|
||||
return c_EditorPrefsSelectedPickupSetStateIndexKey + "." + target.GetType() + "." + target.name + "." + " " + itemSetIndex;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws all of the added states.
|
||||
/// </summary>
|
||||
private void OnPickupSetStateListDraw(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var pickupSet = m_ItemPickup.ItemPickupSet[EditorPrefs.GetInt(SelectedPickupSetIndexKey, -1)];
|
||||
|
||||
// The index may be out of range if the component was copied.
|
||||
if (index >= pickupSet.ItemSet.States.Length) {
|
||||
m_ReorderablePickupSetStateList.index = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
StateInspector.OnStateListDraw(pickupSet.ItemSet, pickupSet.ItemSet.States, rect, index);
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
InspectorUtility.RecordUndoDirtyObject(target, "Change Value");
|
||||
StateInspector.UpdateDefaultStateValues(pickupSet.ItemSet.States);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new state element to the list.
|
||||
/// </summary>
|
||||
private void OnPickupSetStateListAdd(ReorderableList list)
|
||||
{
|
||||
StateInspector.OnStateListAdd(AddExistingPickupSetPreset, CreatePickupSetPreset);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a new element to the state list which uses an existing preset.
|
||||
/// </summary>
|
||||
private void AddExistingPickupSetPreset()
|
||||
{
|
||||
var pickupSet = m_ItemPickup.ItemPickupSet[EditorPrefs.GetInt(SelectedPickupSetIndexKey, -1)];
|
||||
var states = StateInspector.AddExistingPreset(pickupSet.ItemSet.GetType(), pickupSet.ItemSet.States, m_ReorderablePickupSetStateList,
|
||||
GetSelectedPickupSetStateIndexKey(EditorPrefs.GetInt(SelectedPickupSetIndexKey, -1)));
|
||||
if (pickupSet.ItemSet.States.Length != states.Length) {
|
||||
InspectorUtility.SynchronizePropertyCount(states, m_ReorderablePickupSetStateList.serializedProperty);
|
||||
InspectorUtility.RecordUndoDirtyObject(target, "Change Value");
|
||||
pickupSet.ItemSet.States = states;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new preset and adds it to a new state in the list.
|
||||
/// </summary>
|
||||
private void CreatePickupSetPreset()
|
||||
{
|
||||
var pickupSet = m_ItemPickup.ItemPickupSet[EditorPrefs.GetInt(SelectedPickupSetIndexKey, -1)];
|
||||
var states = StateInspector.CreatePreset(pickupSet.ItemSet, pickupSet.ItemSet.States, m_ReorderablePickupSetStateList,
|
||||
GetSelectedPickupSetStateIndexKey(EditorPrefs.GetInt(SelectedPickupSetIndexKey, -1)));
|
||||
if (pickupSet.ItemSet.States.Length != states.Length) {
|
||||
InspectorUtility.SynchronizePropertyCount(states, m_ReorderablePickupSetStateList.serializedProperty);
|
||||
InspectorUtility.RecordUndoDirtyObject(target, "Change Value");
|
||||
pickupSet.ItemSet.States = states;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The list has been reordered. Ensure the reorder is valid.
|
||||
/// </summary>
|
||||
private void OnPickupSetStateListReorder(ReorderableList list)
|
||||
{
|
||||
var pickupSet = m_ItemPickup.ItemPickupSet[EditorPrefs.GetInt(SelectedPickupSetIndexKey, -1)];
|
||||
|
||||
// Use the dummy array in order to determine what element the selected index was swapped with.
|
||||
var copiedStates = new UltimateCharacterController.StateSystem.State[pickupSet.ItemSet.States.Length];
|
||||
System.Array.Copy(pickupSet.ItemSet.States, copiedStates, pickupSet.ItemSet.States.Length);
|
||||
for (int i = 0; i < pickupSet.ItemSet.States.Length; ++i) {
|
||||
var element = list.serializedProperty.GetArrayElementAtIndex(i);
|
||||
if (element.intValue != i) {
|
||||
pickupSet.ItemSet.States[i] = copiedStates[element.intValue];
|
||||
element.intValue = i;
|
||||
}
|
||||
}
|
||||
|
||||
var states = StateInspector.OnStateListReorder(pickupSet.ItemSet.States);
|
||||
if (pickupSet.ItemSet.States.Length != states.Length) {
|
||||
InspectorUtility.SynchronizePropertyCount(states, m_ReorderablePickupSetStateList.serializedProperty);
|
||||
InspectorUtility.RecordUndoDirtyObject(target, "Change Value");
|
||||
pickupSet.ItemSet.States = states;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The ReordableList remove button has been pressed. Remove the selected state.
|
||||
/// </summary>
|
||||
private void OnPickupSetStateListRemove(ReorderableList list)
|
||||
{
|
||||
var pickupSet = m_ItemPickup.ItemPickupSet[EditorPrefs.GetInt(SelectedPickupSetIndexKey, -1)];
|
||||
var states = StateInspector.OnStateListRemove(pickupSet.ItemSet.States, GetSelectedPickupSetStateIndexKey(EditorPrefs.GetInt(SelectedPickupSetIndexKey, -1)), list);
|
||||
if (pickupSet.ItemSet.States.Length != states.Length) {
|
||||
InspectorUtility.SynchronizePropertyCount(states, m_ReorderablePickupSetStateList.serializedProperty);
|
||||
InspectorUtility.RecordUndoDirtyObject(target, "Change Value");
|
||||
pickupSet.ItemSet.States = states;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 466210d1209bae34e8da9993fd7905d1
|
||||
timeCreated: 1501619173
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,117 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Editor.Inspectors.Objects.CharacterAssist
|
||||
{
|
||||
using Opsive.UltimateCharacterController.Editor.Inspectors.Inventory;
|
||||
using Opsive.UltimateCharacterController.Editor.Inspectors.Utility;
|
||||
using Opsive.UltimateCharacterController.Editor.Managers;
|
||||
using Opsive.UltimateCharacterController.Inventory;
|
||||
using Opsive.UltimateCharacterController.Objects.CharacterAssist;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom inspector for the ItemPickup component.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(ItemPickup), true)]
|
||||
public class ItemPickupInspector : ItemPickupBaseInspector
|
||||
{
|
||||
private ItemCollection m_ItemCollection;
|
||||
private ReorderableList m_ReordableItemAmount;
|
||||
|
||||
/// <summary>
|
||||
/// Finds the Item Collection.
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
m_ItemCollection = ManagerUtility.FindItemCollection(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the header fields for the ItemPickupSet.
|
||||
/// </summary>
|
||||
protected override void DrawItemPickupSetHeaderFields()
|
||||
{
|
||||
m_ItemCollection = EditorGUILayout.ObjectField("Item Collection", m_ItemCollection, typeof(ItemCollection), false) as ItemCollection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the inspector for the ItemIdentifier list.
|
||||
/// </summary>
|
||||
protected override void DrawItemIdentifierInspector()
|
||||
{
|
||||
if (Foldout("Item Definition Amounts")) {
|
||||
EditorGUI.indentLevel++;
|
||||
if (m_ReordableItemAmount == null) {
|
||||
var itemListProperty = PropertyFromName("m_ItemDefinitionAmounts");
|
||||
m_ReordableItemAmount = new ReorderableList(serializedObject, itemListProperty, true, true, true, true);
|
||||
m_ReordableItemAmount.drawHeaderCallback = OnItemIdentifierAmountHeaderDraw;
|
||||
m_ReordableItemAmount.drawElementCallback = OnItemIdentifierAmountElementDraw;
|
||||
m_ReordableItemAmount.elementHeight = c_SlotRowHeight;
|
||||
}
|
||||
var listRect = GUILayoutUtility.GetRect(0, m_ReordableItemAmount.GetHeight());
|
||||
listRect.x += EditorGUI.indentLevel * InspectorUtility.IndentWidth;
|
||||
listRect.xMax -= EditorGUI.indentLevel * InspectorUtility.IndentWidth;
|
||||
m_ReordableItemAmount.DoList(listRect);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the field that displays the available categories.
|
||||
/// </summary>
|
||||
/// <param name="pickupSet">The PickupSet that should be drawn.</param>
|
||||
/// <param name="objRect">The location the categories should draw.</param>
|
||||
protected override void DrawAvailableCategories(ItemPickupBase.PickupSet pickupSet, Rect objRect)
|
||||
{
|
||||
var categoryNames = new string[((m_ItemCollection != null && m_ItemCollection.Categories != null) ? m_ItemCollection.Categories.Length : 0) + 1];
|
||||
categoryNames[0] = "(Not Specified)";
|
||||
var selected = 0;
|
||||
if (categoryNames.Length > 1 && GUI.enabled) {
|
||||
for (int i = 0; i < m_ItemCollection.Categories.Length; ++i) {
|
||||
categoryNames[i + 1] = m_ItemCollection.Categories[i].name;
|
||||
if (pickupSet.CategoryID == m_ItemCollection.Categories[i].ID) {
|
||||
selected = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
int newSelected;
|
||||
if (objRect.width == 0) {
|
||||
newSelected = EditorGUILayout.Popup("Category", selected != -1 ? selected : 0, categoryNames);
|
||||
} else {
|
||||
newSelected = EditorGUI.Popup(objRect, selected != -1 ? selected : 0, categoryNames);
|
||||
}
|
||||
if (selected != newSelected) {
|
||||
if (newSelected == 0) {
|
||||
pickupSet.CategoryID = 0;
|
||||
} else {
|
||||
pickupSet.CategoryID = m_ItemCollection.Categories[newSelected - 1].ID;
|
||||
}
|
||||
GUI.changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the ItemIdentifierAmount ReordableList header.
|
||||
/// </summary>
|
||||
private void OnItemIdentifierAmountHeaderDraw(Rect rect)
|
||||
{
|
||||
ItemDefinitionAmountInspector.OnItemDefinitionAmountHeaderDraw(rect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the ItemIdentifierAmount ReordableList element.
|
||||
/// </summary>
|
||||
private void OnItemIdentifierAmountElementDraw(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
ItemDefinitionAmountInspector.OnItemDefinitionAmountElementDraw(PropertyFromName("m_ItemDefinitionAmounts"), rect, index, isActive, isFocused);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d8a6b8c8c66592468739f60a842311a
|
||||
timeCreated: 1501619173
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,60 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Editor.Inspectors.Objects.CharacterAssist
|
||||
{
|
||||
using Opsive.UltimateCharacterController.Objects.CharacterAssist;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Shows the gizmo for the start location.
|
||||
/// </summary>
|
||||
public class MoveTowardsLocationGizmo
|
||||
{
|
||||
/// <summary>
|
||||
/// Draws the gizmo.
|
||||
/// </summary>
|
||||
[DrawGizmo(GizmoType.Selected | GizmoType.Active)]
|
||||
private static void DrawMoveTowardsLocationGizmo(MoveTowardsLocation startLocation, GizmoType gizmoType)
|
||||
{
|
||||
var transform = startLocation.transform;
|
||||
Handles.matrix = Gizmos.matrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.lossyScale);
|
||||
|
||||
// Wire lines will indicate the valid starting positions.
|
||||
Gizmos.color = new Color(1, 0.6f, 0, 0.7f);
|
||||
Gizmos.DrawWireCube(startLocation.Offset, startLocation.Size);
|
||||
|
||||
// Draw an arc indicating the direction that the character can face.
|
||||
Handles.matrix = Gizmos.matrix = Matrix4x4.TRS(transform.TransformPoint(startLocation.Offset), transform.rotation * Quaternion.Euler(0, startLocation.YawOffset, 0), transform.lossyScale);
|
||||
Handles.color = new Color(0, 1, 0, 0.7f);
|
||||
var radius = Mathf.Min(0.5f, Mathf.Max(Mathf.Abs(startLocation.Offset.z), 0.2f));
|
||||
Handles.DrawWireDisc(Vector3.zero, Vector3.up, radius);
|
||||
Handles.color = new Color(0, 1, 0, 0.2f);
|
||||
Handles.DrawSolidArc(Vector3.zero, Vector3.up, Quaternion.AngleAxis(startLocation.Angle / 2 - startLocation.Angle, Vector3.up) * Vector3.forward,
|
||||
startLocation.Angle, radius);
|
||||
|
||||
// Draw arrows pointing in the direction that the character can face.
|
||||
radius /= 2;
|
||||
Handles.color = new Color(0, 1, 0, 0.7f);
|
||||
Handles.DrawLine(Vector3.zero, (Vector3.forward * 2f) * radius);
|
||||
Handles.DrawLine((Vector3.forward * 2) * radius, ((Vector3.forward * 1.5f * radius) + (Vector3.left * 0.5f) * radius));
|
||||
Handles.DrawLine((Vector3.forward * 2) * radius, ((Vector3.forward * 1.5f * radius) + (Vector3.right * 0.5f) * radius));
|
||||
if (startLocation.Angle >= 180) {
|
||||
Handles.DrawLine((Vector3.left * 2) * radius, (Vector3.right * 2) * radius);
|
||||
Handles.DrawLine((Vector3.left * 2) * radius, ((Vector3.left * 1.5f * radius) + (Vector3.forward * 0.5f) * radius));
|
||||
Handles.DrawLine((Vector3.left * 2) * radius, ((Vector3.left * 1.5f * radius) + (Vector3.back * 0.5f) * radius));
|
||||
Handles.DrawLine((Vector3.right * 2) * radius, ((Vector3.right * 1.5f * radius) + (Vector3.forward * 0.5f) * radius));
|
||||
Handles.DrawLine((Vector3.right * 2) * radius, ((Vector3.right * 1.5f * radius) + (Vector3.back * 0.5f) * radius));
|
||||
if (startLocation.Angle == 360) {
|
||||
Handles.DrawLine(Vector3.zero, (Vector3.back * 2f) * radius);
|
||||
Handles.DrawLine((Vector3.back * 2) * radius, ((Vector3.back * 1.5f * radius) + (Vector3.left * 0.5f) * radius));
|
||||
Handles.DrawLine((Vector3.back * 2) * radius, ((Vector3.back * 1.5f * radius) + (Vector3.right * 0.5f) * radius));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84365464db89ebd498d7868a03103b81
|
||||
timeCreated: 1501619173
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,93 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Editor.Inspectors.Objects.CharacterAssist
|
||||
{
|
||||
using Opsive.UltimateCharacterController.Editor.Inspectors.Audio;
|
||||
using Opsive.UltimateCharacterController.Editor.Inspectors.Utility;
|
||||
using Opsive.UltimateCharacterController.Objects.CharacterAssist;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom inspector for the ObjectPickup component.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(ObjectPickup), true)]
|
||||
public class ObjectPickupInspector : InspectorBase
|
||||
{
|
||||
private ObjectPickup m_ObjectPickup;
|
||||
private ReorderableList m_ReorderablePickupAudioClipsList;
|
||||
|
||||
/// <summary>
|
||||
/// The inspector has been enabled.
|
||||
/// </summary>
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
m_ObjectPickup = target as ObjectPickup;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
DrawObjectPickupFields();
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_TriggerEnableDelay"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_PickupOnTriggerEnter"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_RotationSpeed"));
|
||||
if (Foldout("UI")) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_PickupMessageText"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_PickupMessageIcon"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
if (Foldout("Audio")) {
|
||||
EditorGUI.indentLevel++;
|
||||
m_ReorderablePickupAudioClipsList = AudioClipSetInspector.DrawAudioClipSet(m_ObjectPickup.PickupAudioClipSet, PropertyFromName("m_PickupAudioClipSet"), m_ReorderablePickupAudioClipsList, OnPickupAudioClipDraw, OnPickupAudioClipListAdd, OnPickupAudioClipListRemove);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
InspectorUtility.RecordUndoDirtyObject(target, "Value Change");
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the object pickup fields.
|
||||
/// </summary>
|
||||
protected virtual void DrawObjectPickupFields() { }
|
||||
|
||||
/// <summary>
|
||||
/// Draws the AudioClip element.
|
||||
/// </summary>
|
||||
private void OnPickupAudioClipDraw(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
AudioClipSetInspector.OnAudioClipDraw(m_ReorderablePickupAudioClipsList, rect, index, m_ObjectPickup.PickupAudioClipSet, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new AudioClip element to the AudioClipSet.
|
||||
/// </summary>
|
||||
private void OnPickupAudioClipListAdd(ReorderableList list)
|
||||
{
|
||||
AudioClipSetInspector.OnAudioClipListAdd(list, m_ObjectPickup.PickupAudioClipSet, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the AudioClip element at the list index.
|
||||
/// </summary>
|
||||
private void OnPickupAudioClipListRemove(ReorderableList list)
|
||||
{
|
||||
AudioClipSetInspector.OnAudioClipListRemove(list, m_ObjectPickup.PickupAudioClipSet, null);
|
||||
m_ObjectPickup.PickupAudioClipSet.AudioClips = (AudioClip[])list.list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee475726c976d624f8dfb272773a6826
|
||||
timeCreated: 1501619173
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,40 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Editor.Inspectors.Objects
|
||||
{
|
||||
using Opsive.UltimateCharacterController.Editor.Inspectors.Utility;
|
||||
using Opsive.UltimateCharacterController.Objects;
|
||||
using UnityEditor;
|
||||
|
||||
/// <summary>
|
||||
/// Custom inspector for the Destructible component.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(Destructible))]
|
||||
public class DestructibleInspector : TrajectoryObjectInspector
|
||||
{
|
||||
/// <summary>
|
||||
/// Draws the inspector fields for the object.
|
||||
/// </summary>
|
||||
protected override void DrawObjectFields()
|
||||
{
|
||||
base.DrawObjectFields();
|
||||
|
||||
if (Foldout("Destruction")) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_DestroyOnCollision"));
|
||||
if (PropertyFromName("m_DestroyOnCollision").boolValue) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_DestructionDelay"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_SpawnedObjectsOnDestruction"), true);
|
||||
InspectorUtility.UnityEventPropertyField(PropertyFromName("m_OnImpactEvent"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67e5e50c9c94b0747b51b9a5c28fc361
|
||||
timeCreated: 1501619173
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,90 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Editor.Inspectors.Objects
|
||||
{
|
||||
using Opsive.UltimateCharacterController.Editor.Inspectors.Audio;
|
||||
using Opsive.UltimateCharacterController.Editor.Inspectors.Utility;
|
||||
using Opsive.UltimateCharacterController.Objects;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom inspector for the Explosion component.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(Explosion))]
|
||||
public class ExplosionInspector : InspectorBase
|
||||
{
|
||||
private Explosion m_Explosion;
|
||||
private ReorderableList m_ReorderableExplosionAudioClipsList;
|
||||
|
||||
/// <summary>
|
||||
/// The inspector has been enabled.
|
||||
/// </summary>
|
||||
public void OnEnable()
|
||||
{
|
||||
m_Explosion = target as Explosion;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_ExplodeOnEnable"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_Radius"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_DamageAmount"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_ImpactForce"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_ImpactForceFrames"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_ImpactLayers"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_LineOfSight"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_Lifespan"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_MaxCollisionCount"));
|
||||
if (Foldout("Audio")) {
|
||||
EditorGUI.indentLevel++;
|
||||
m_ReorderableExplosionAudioClipsList = AudioClipSetInspector.DrawAudioClipSet(m_Explosion.ExplosionAudioClipSet, PropertyFromName("m_ExplosionAudioClipSet"), m_ReorderableExplosionAudioClipsList, OnExplosionAudioClipDraw, OnExplosionAudioClipListAdd, OnExplosionAudioClipListRemove);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
InspectorUtility.UnityEventPropertyField(PropertyFromName("m_OnImpactEvent"));
|
||||
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
InspectorUtility.RecordUndoDirtyObject(target, "Value Change");
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
InspectorUtility.SetDirty(target);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the AudioClip element.
|
||||
/// </summary>
|
||||
private void OnExplosionAudioClipDraw(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
AudioClipSetInspector.OnAudioClipDraw(m_ReorderableExplosionAudioClipsList, rect, index, m_Explosion.ExplosionAudioClipSet, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new AudioClip element to the AudioClipSet.
|
||||
/// </summary>
|
||||
private void OnExplosionAudioClipListAdd(ReorderableList list)
|
||||
{
|
||||
AudioClipSetInspector.OnAudioClipListAdd(list, m_Explosion.ExplosionAudioClipSet, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the AudioClip element at the list index.
|
||||
/// </summary>
|
||||
private void OnExplosionAudioClipListRemove(ReorderableList list)
|
||||
{
|
||||
AudioClipSetInspector.OnAudioClipListRemove(list, m_Explosion.ExplosionAudioClipSet, null);
|
||||
m_Explosion.ExplosionAudioClipSet.AudioClips = (AudioClip[])list.list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3cfb0d1f31e69c24383f452dcba9f252
|
||||
timeCreated: 1501619173
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,33 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Editor.Inspectors.Objects
|
||||
{
|
||||
using Opsive.UltimateCharacterController.Objects;
|
||||
using UnityEditor;
|
||||
|
||||
/// <summary>
|
||||
/// Custom inspector for the Grenade component.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(Grenade), true)]
|
||||
public class GrenadeInspector : DestructibleInspector
|
||||
{
|
||||
/// <summary>
|
||||
/// Draws the inspector fields for the object.
|
||||
/// </summary>
|
||||
protected override void DrawObjectFields()
|
||||
{
|
||||
base.DrawObjectFields();
|
||||
|
||||
if (Foldout("Grenade")) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_Lifespan"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_Pin"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b3e9488fc682464a8886b25c80afb96
|
||||
timeCreated: 1501619173
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11821af12f2f95845a49654d5f274edc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,33 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Editor.Inspectors.Objects.ItemAssist
|
||||
{
|
||||
using Opsive.UltimateCharacterController.Objects.ItemAssist;
|
||||
using UnityEditor;
|
||||
|
||||
/// <summary>
|
||||
/// Custom inspector for the Shell component.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(Shell))]
|
||||
public class ShellInspector : TrajectoryObjectInspector
|
||||
{
|
||||
/// <summary>
|
||||
/// Draws the inspector fields for the object.
|
||||
/// </summary>
|
||||
protected override void DrawObjectFields()
|
||||
{
|
||||
base.DrawObjectFields();
|
||||
|
||||
if (Foldout("Shell")) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_Lifespan"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_Persistence"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0f294740f18f7b4487f5fe14b68a0cb
|
||||
timeCreated: 1501619173
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,36 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Editor.Inspectors.Objects
|
||||
{
|
||||
using Opsive.UltimateCharacterController.Objects.ItemAssist;
|
||||
using UnityEditor;
|
||||
|
||||
/// <summary>
|
||||
/// Custom inspector for the MagicProjectile component.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(MagicProjectile), true)]
|
||||
public class MagicProjectileInspector : TrajectoryObjectInspector
|
||||
{
|
||||
/// <summary>
|
||||
/// Draws the inspector fields for the object.
|
||||
/// </summary>
|
||||
protected override void DrawObjectFields()
|
||||
{
|
||||
base.DrawObjectFields();
|
||||
|
||||
if (Foldout("Magic Projectile")) {
|
||||
EditorGUI.indentLevel++;
|
||||
var destroyOnCollisionProperty = PropertyFromName("m_DestroyOnCollision");
|
||||
EditorGUILayout.PropertyField(destroyOnCollisionProperty);
|
||||
if (destroyOnCollisionProperty.boolValue) {
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_WaitForParticleStop"));
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6211f7e4ed989964a87b7fe2e6784482
|
||||
timeCreated: 1501619173
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,257 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Editor.Inspectors.Objects
|
||||
{
|
||||
using Opsive.UltimateCharacterController.Editor.Inspectors.StateSystem;
|
||||
using Opsive.UltimateCharacterController.Editor.Inspectors.Utility;
|
||||
using Opsive.UltimateCharacterController.Objects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom inspector for the MovingPlatform component.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(MovingPlatform), true)]
|
||||
public class MovingPlatformInspector : StateBehaviorInspector
|
||||
{
|
||||
private const int c_DelayWidth = 50;
|
||||
private const int c_StateWidth = 110;
|
||||
|
||||
private ReorderableList m_WaypointReorderableList;
|
||||
private MovingPlatform m_Platform;
|
||||
private static GUIStyle s_DebugLabelStyle;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the inspector.
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
m_Platform = target as MovingPlatform;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the actions to draw before the State list is drawn.
|
||||
/// </summary>
|
||||
/// <returns>The actions to draw before the State list is drawn.</returns>
|
||||
protected override Action GetDrawCallback()
|
||||
{
|
||||
var baseCallback = base.GetDrawCallback();
|
||||
|
||||
baseCallback += () =>
|
||||
{
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_UpdateLocation"));
|
||||
if (Foldout("Path")) {
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
if (m_WaypointReorderableList == null) {
|
||||
if (m_Platform.Waypoints == null) {
|
||||
m_Platform.Waypoints = new MovingPlatform.Waypoint[0];
|
||||
}
|
||||
m_WaypointReorderableList = new ReorderableList(m_Platform.Waypoints, typeof(MovingPlatform.Waypoint), true, true, true, true);
|
||||
m_WaypointReorderableList.drawHeaderCallback = OnAnimatorWaypointStateListHeaderDraw;
|
||||
m_WaypointReorderableList.drawElementCallback = OnAnimatorWaypointStateElementDraw;
|
||||
m_WaypointReorderableList.onAddCallback = OnWaypointStateListAdd;
|
||||
m_WaypointReorderableList.onRemoveCallback = OnWaypointStateListRemove;
|
||||
}
|
||||
|
||||
// ReorderableLists do not like indentation.
|
||||
var indentLevel = EditorGUI.indentLevel;
|
||||
while (EditorGUI.indentLevel > 0) {
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
var listRect = GUILayoutUtility.GetRect(0, m_WaypointReorderableList.GetHeight());
|
||||
// Indent the list so it lines up with the rest of the content.
|
||||
listRect.x += InspectorUtility.IndentWidth * indentLevel;
|
||||
listRect.xMax -= InspectorUtility.IndentWidth * indentLevel;
|
||||
m_WaypointReorderableList.DoList(listRect);
|
||||
while (EditorGUI.indentLevel < indentLevel) {
|
||||
EditorGUI.indentLevel++;
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_Direction"));
|
||||
var movementType = PropertyFromName("m_MovementType");
|
||||
EditorGUILayout.PropertyField(movementType);
|
||||
if (movementType.enumValueIndex == (int)MovingPlatform.PathMovementType.Target) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_TargetWaypoint"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
if (Foldout("Movement")) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_MovementSpeed"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_MovementInterpolation"));
|
||||
var rotationInterpolation = PropertyFromName("m_RotationInterpolation");
|
||||
EditorGUILayout.PropertyField(rotationInterpolation);
|
||||
if (rotationInterpolation.enumValueIndex == (int)MovingPlatform.RotateInterpolationMode.CustomEaseOut) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_RotationEaseAmount"));
|
||||
EditorGUI.indentLevel--;
|
||||
} else if (rotationInterpolation.enumValueIndex == (int)MovingPlatform.RotateInterpolationMode.CustomRotate) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_CustomRotationSpeed"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_MaxRotationDeltaAngle"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
if (Foldout("Interaction")) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_CharacterTriggerState"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_EnableOnInteract"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_ChangeDirectionsOnInteract"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
if (Foldout("Editor")) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_GizmoColor"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_DrawDebugLabels"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
};
|
||||
return baseCallback;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the header for the WaypointState list.
|
||||
/// </summary>
|
||||
private void OnAnimatorWaypointStateListHeaderDraw(Rect rect)
|
||||
{
|
||||
EditorGUI.LabelField(new Rect(rect.x + 12, rect.y, rect.width - c_DelayWidth - c_StateWidth, EditorGUIUtility.singleLineHeight), "Transform");
|
||||
EditorGUI.LabelField(new Rect(rect.x + (rect.width - c_DelayWidth - c_StateWidth), rect.y, c_DelayWidth, EditorGUIUtility.singleLineHeight), "Delay");
|
||||
EditorGUI.LabelField(new Rect(rect.x + (rect.width - c_StateWidth) + 4, rect.y, c_StateWidth - 4, EditorGUIUtility.singleLineHeight), "State");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the WaypointState element.
|
||||
/// </summary>
|
||||
private void OnAnimatorWaypointStateElementDraw(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
m_Platform.Waypoints[index].Transform = (Transform)EditorGUI.ObjectField(new Rect(rect.x, rect.y + 1, (rect.width - c_DelayWidth - c_StateWidth - 2), EditorGUIUtility.singleLineHeight),
|
||||
m_Platform.Waypoints[index].Transform, typeof(Transform), true);
|
||||
m_Platform.Waypoints[index].Delay = EditorGUI.FloatField(new Rect(rect.x + (rect.width - c_DelayWidth - c_StateWidth), rect.y + 1, c_DelayWidth,
|
||||
EditorGUIUtility.singleLineHeight), m_Platform.Waypoints[index].Delay);
|
||||
m_Platform.Waypoints[index].State = EditorGUI.TextField(new Rect(rect.x + (rect.width - c_StateWidth) + 4, rect.y + 1, c_StateWidth - 4,
|
||||
EditorGUIUtility.singleLineHeight), m_Platform.Waypoints[index].State);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new WaypointState element to the list.
|
||||
/// </summary>
|
||||
public void OnWaypointStateListAdd(ReorderableList list)
|
||||
{
|
||||
var waypoints = m_Platform.Waypoints;
|
||||
if (waypoints == null) {
|
||||
waypoints = new MovingPlatform.Waypoint[1];
|
||||
} else {
|
||||
Array.Resize(ref waypoints, waypoints.Length + 1);
|
||||
}
|
||||
list.list = m_Platform.Waypoints = waypoints;
|
||||
if (target != null) {
|
||||
InspectorUtility.RecordUndoDirtyObject(target, "Change Value");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the WaypointState element at the list index.
|
||||
/// </summary>
|
||||
public void OnWaypointStateListRemove(ReorderableList list)
|
||||
{
|
||||
// Convert to a list and remove the waypoint. A new list needs to be assigned because a new allocation occurred.
|
||||
var waypointStateList = new List<MovingPlatform.Waypoint>(m_Platform.Waypoints);
|
||||
waypointStateList.RemoveAt(list.index);
|
||||
list.list = m_Platform.Waypoints = waypointStateList.ToArray();
|
||||
list.index = list.index - 1;
|
||||
if (target != null) {
|
||||
InspectorUtility.RecordUndoDirtyObject(target, "Change Value");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the moving platform gizmo.
|
||||
/// </summary>
|
||||
[DrawGizmo(GizmoType.Selected | GizmoType.NonSelected)]
|
||||
static void DrawMovingPlatformGizmo(MovingPlatform movingPlatform, GizmoType gizmoType)
|
||||
{
|
||||
if (movingPlatform.Waypoints == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Mesh mesh = null;
|
||||
var meshFilter = movingPlatform.GetComponent<MeshFilter>();
|
||||
if (meshFilter != null) {
|
||||
mesh = meshFilter.sharedMesh;
|
||||
}
|
||||
for (int i = 0; i < movingPlatform.Waypoints.Length; ++i) {
|
||||
if (movingPlatform.Waypoints[i].Transform == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Gizmos.color = movingPlatform.GizmoColor;
|
||||
// Draw the mesh if it exists.
|
||||
if (mesh != null) {
|
||||
Gizmos.DrawMesh(mesh, movingPlatform.Waypoints[i].Transform.position, movingPlatform.Waypoints[i].Transform.rotation, movingPlatform.transform.localScale);
|
||||
}
|
||||
Gizmos.DrawWireSphere(movingPlatform.Waypoints[i].Transform.position, 0.5f);
|
||||
|
||||
if (movingPlatform.DrawDebugLabels) {
|
||||
if (s_DebugLabelStyle == null) {
|
||||
s_DebugLabelStyle = new GUIStyle(EditorStyles.label);
|
||||
s_DebugLabelStyle.fontSize = 16;
|
||||
s_DebugLabelStyle.normal.textColor = InspectorUtility.GetContrastColor(movingPlatform.GizmoColor);
|
||||
}
|
||||
// Draw the delay in the center of the platform.
|
||||
Handles.Label(movingPlatform.Waypoints[i].Transform.position, movingPlatform.Waypoints[i].Delay.ToString(), s_DebugLabelStyle);
|
||||
}
|
||||
|
||||
// Draw a line connecting the platforms.
|
||||
if (i > 0 && movingPlatform.Waypoints[i - 1].Transform != null && movingPlatform.MovementType != MovingPlatform.PathMovementType.Target) {
|
||||
Gizmos.color = InspectorUtility.GetContrastColor(movingPlatform.GizmoColor);
|
||||
Gizmos.DrawLine(movingPlatform.Waypoints[i - 1].Transform.position, movingPlatform.Waypoints[i].Transform.position);
|
||||
|
||||
if (movingPlatform.DrawDebugLabels) {
|
||||
// Draw a distance in the center of the line.
|
||||
var distance = decimal.Round((decimal)Vector3.Distance(movingPlatform.Waypoints[i - 1].Transform.position, movingPlatform.Waypoints[i].Transform.position), 3);
|
||||
Handles.Label((movingPlatform.Waypoints[i - 1].Transform.position + movingPlatform.Waypoints[i].Transform.position) / 2, distance.ToString(), s_DebugLabelStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Complete the path drawing.
|
||||
if (movingPlatform.MovementType == MovingPlatform.PathMovementType.Loop && movingPlatform.Waypoints.Length > 0 && movingPlatform.Waypoints[0].Transform != null &&
|
||||
movingPlatform.Waypoints[movingPlatform.Waypoints.Length - 1].Transform != null) {
|
||||
Gizmos.color = InspectorUtility.GetContrastColor(movingPlatform.GizmoColor);
|
||||
Gizmos.DrawLine(movingPlatform.Waypoints[0].Transform.position, movingPlatform.Waypoints[movingPlatform.Waypoints.Length - 1].Transform.position);
|
||||
|
||||
if (movingPlatform.DrawDebugLabels) {
|
||||
// Draw a distance in the center of the line.
|
||||
var distance = decimal.Round((decimal)Vector3.Distance(movingPlatform.Waypoints[0].Transform.position, movingPlatform.Waypoints[movingPlatform.Waypoints.Length - 1].Transform.position), 3);
|
||||
Handles.Label((movingPlatform.Waypoints[0].Transform.position + movingPlatform.Waypoints[movingPlatform.Waypoints.Length - 1].Transform.position) / 2, distance.ToString(), s_DebugLabelStyle);
|
||||
}
|
||||
} else if (movingPlatform.MovementType == MovingPlatform.PathMovementType.Target && movingPlatform.TargetWaypoint < movingPlatform.Waypoints.Length && movingPlatform.Waypoints[movingPlatform.TargetWaypoint].Transform != null) {
|
||||
Gizmos.color = InspectorUtility.GetContrastColor(movingPlatform.GizmoColor);
|
||||
Gizmos.DrawLine(movingPlatform.transform.position, movingPlatform.Waypoints[movingPlatform.TargetWaypoint].Transform.position);
|
||||
}
|
||||
|
||||
// Draw the current waypoint the platform is moving towards.
|
||||
if (Application.isPlaying && movingPlatform.enabled && movingPlatform.Waypoints.Length > 0) {
|
||||
Gizmos.color = Color.green;
|
||||
Gizmos.DrawLine(movingPlatform.transform.position, movingPlatform.Waypoints[movingPlatform.NextWaypoint].Transform.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9cdab0256437e7e4a8a3dff22f99c86a
|
||||
timeCreated: 1510101702
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,32 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Editor.Inspectors.Objects
|
||||
{
|
||||
using Opsive.UltimateCharacterController.Objects;
|
||||
using UnityEditor;
|
||||
|
||||
/// <summary>
|
||||
/// Custom inspector for the Projectile component.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(Projectile), true)]
|
||||
public class ProjectileInspector : DestructibleInspector
|
||||
{
|
||||
/// <summary>
|
||||
/// Draws the inspector fields for the object.
|
||||
/// </summary>
|
||||
protected override void DrawObjectFields()
|
||||
{
|
||||
base.DrawObjectFields();
|
||||
|
||||
if (Foldout("Projectile")) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_Lifespan"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebca2d66b73be25438de0d34b44c0559
|
||||
timeCreated: 1501619173
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,130 +0,0 @@
|
||||
/// ---------------------------------------------
|
||||
/// Ultimate Character Controller
|
||||
/// Copyright (c) Opsive. All Rights Reserved.
|
||||
/// https://www.opsive.com
|
||||
/// ---------------------------------------------
|
||||
|
||||
namespace Opsive.UltimateCharacterController.Editor.Inspectors.Objects
|
||||
{
|
||||
using Opsive.UltimateCharacterController.Editor.Inspectors.Audio;
|
||||
using Opsive.UltimateCharacterController.Editor.Inspectors.Utility;
|
||||
using Opsive.UltimateCharacterController.Objects;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Custom inspector for the TrajectoryObject component.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(TrajectoryObject), true)]
|
||||
public class TrajectoryObjectInspector : InspectorBase
|
||||
{
|
||||
private TrajectoryObject m_TrajectoryObject;
|
||||
private ReorderableList m_ReorderableActiveAudioClipsList;
|
||||
|
||||
/// <summary>
|
||||
/// The inspector has been enabled.
|
||||
/// </summary>
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
m_TrajectoryObject = target as TrajectoryObject;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_InitializeOnEnable"));
|
||||
|
||||
if (Foldout("Physics")) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_Mass"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_StartVelocityMultiplier"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_GravityMagnitude"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_Speed"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_RotationSpeed"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_Damping"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_RotationDamping"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_RotateInMoveDirection"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_SettleThreshold"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_SidewaysSettleThreshold"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_StartSidewaysVelocityMagnitude"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_MaxCollisionCount"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
if (Foldout("Impact")) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_ImpactLayers"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_SurfaceImpact"));
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_ForceMultiplier"));
|
||||
var collisionModeProperty = PropertyFromName("m_CollisionMode");
|
||||
EditorGUILayout.PropertyField(collisionModeProperty);
|
||||
if (collisionModeProperty.enumValueIndex != (int)TrajectoryObject.CollisionMode.Collide &&
|
||||
collisionModeProperty.enumValueIndex != (int)TrajectoryObject.CollisionMode.Ignore) {
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_ReflectMultiplier"));
|
||||
} else if (collisionModeProperty.enumValueIndex == (int)TrajectoryObject.CollisionMode.Collide) {
|
||||
if (target is Destructible) {
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_StickyLayers"), true);
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
if (Foldout("Audio")) {
|
||||
EditorGUI.indentLevel++;
|
||||
m_ReorderableActiveAudioClipsList = AudioClipSetInspector.DrawAudioClipSet(m_TrajectoryObject.ActiveAudioClipSet, PropertyFromName("m_ActiveAudioClipSet"), m_ReorderableActiveAudioClipsList, OnActiveAudioClipDraw, OnActiveAudioClipListAdd, OnActiveAudioClipListRemove);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
DrawObjectFields();
|
||||
|
||||
if (Foldout("Curve")) {
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(PropertyFromName("m_MaxPositionCount"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
InspectorUtility.RecordUndoDirtyObject(target, "Value Change");
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Draws the AudioClip element.
|
||||
/// </summary>
|
||||
private void OnActiveAudioClipDraw(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
AudioClipSetInspector.OnAudioClipDraw(m_ReorderableActiveAudioClipsList, rect, index, m_TrajectoryObject.ActiveAudioClipSet, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new AudioClip element to the AudioClipSet.
|
||||
/// </summary>
|
||||
private void OnActiveAudioClipListAdd(ReorderableList list)
|
||||
{
|
||||
AudioClipSetInspector.OnAudioClipListAdd(list, m_TrajectoryObject.ActiveAudioClipSet, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the AudioClip element at the list index.
|
||||
/// </summary>
|
||||
private void OnActiveAudioClipListRemove(ReorderableList list)
|
||||
{
|
||||
AudioClipSetInspector.OnAudioClipListRemove(list, m_TrajectoryObject.ActiveAudioClipSet, null);
|
||||
m_TrajectoryObject.ActiveAudioClipSet.AudioClips = (AudioClip[])list.list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the inspector fields for the child object.
|
||||
/// </summary>
|
||||
protected virtual void DrawObjectFields() { }
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c4068f279a59b34d8a948976d4a3f3f
|
||||
timeCreated: 1501619173
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user