浏览代码

Pickup Item display + base behaviour

/main
Thomas ICHÉ 6 年前
当前提交
9b7faf3f
共有 5 个文件被更改,包括 65 次插入0 次删除
  1. 13
      Runtime/Pickup/PickupItem.cs
  2. 8
      Editor/Pickup.meta
  3. 33
      Editor/Pickup/PickupItemEditor.cs
  4. 11
      Editor/Pickup/PickupItemEditor.cs.meta

13
Runtime/Pickup/PickupItem.cs


namespace GameplayIngredients.Pickup
{
[RequireComponent(typeof(Collider))]
private void OnTriggerEnter(Collider other)
{
var owner = other.gameObject.GetComponent<PickupOwnerBase>();
if(owner != null)
{
if(owner.PickUp(this))
{
Destroy(this.gameObject);
}
}
}
}
}

8
Editor/Pickup.meta


fileFormatVersion: 2
guid: 0bde61e4f2da9974483510627b7babec
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

33
Editor/Pickup/PickupItemEditor.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
using GameplayIngredients.Pickup;
namespace GameplayIngredients.Editor
{
[CustomEditor(typeof(PickupItem))]
public class PickupItemEditor : UnityEditor.Editor
{
ReorderableList m_RList;
private void OnEnable()
{
m_RList = new ReorderableList(((PickupItem)serializedObject.targetObject).effects, typeof(PickupEffectBase), false, true, false, false);
m_RList.drawElementCallback = DrawElement;
}
void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
{
GUI.Label(rect,string.Format("#{0} - {1}", index+1, ObjectNames.NicifyVariableName(((PickupItem)serializedObject.targetObject).effects[index].GetType().Name)));
}
public override void OnInspectorGUI()
{
GUILayout.Space(8);
m_RList.DoLayoutList();
}
}
}

11
Editor/Pickup/PickupItemEditor.cs.meta


fileFormatVersion: 2
guid: b2d5d799cf5e557479da3a5dc71cd59f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存