Skip to content

Commit 6455ae7

Browse files
committed
new item test + drawer finished
1 parent 0ab97ae commit 6455ae7

File tree

5 files changed

+40
-7
lines changed

5 files changed

+40
-7
lines changed

Editor/DropDrawer.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,23 @@ public class DropDrawer : PropertyDrawer
1212
{
1313
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
1414
{
15-
return base.GetPropertyHeight(property, label) + 150;
15+
return base.GetPropertyHeight(property, label) + 75;
1616
}
1717
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
1818
{
1919
EditorGUI.BeginProperty(position, label, property);
2020

21-
var item = new Rect(position.x + 50, position.y, 80, 20);
22-
var chance = new Rect(position.x + 50, position.y + 30, 50, 20);
21+
var title = new Rect(position.x, position.y - 8, 80, 20);
22+
var item = new Rect(position.x + 52, position.y + 10, 80, 20);
23+
var chance = new Rect(position.x + 50, position.y + 40, 50, 20);
2324
var itemName = new Rect(position.x, position.y + 10, 50, 20);
2425
var itemIcon = new Rect(position.x + 10, position.y + 30, 32, 32);
2526
var itemChance = new Rect(position.x, position.y + 60, 120, 20);
2627

2728
var indent = EditorGUI.indentLevel;
2829
EditorGUI.indentLevel = 0;
30+
31+
EditorGUI.LabelField(title, "DROP!");
2932

3033

3134
EditorGUI.PropertyField(item, property.FindPropertyRelative("item"), GUIContent.none);

Samples/EntityExamples.unity

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,11 @@ MonoBehaviour:
708708
m_Name:
709709
m_EditorClassIdentifier:
710710
itemDrop:
711-
item: {fileID: 11400000, guid: b27eeae83168bce49ba810731a0200b5, type: 2}
712-
chance: 4
711+
- item: {fileID: 11400000, guid: b27eeae83168bce49ba810731a0200b5, type: 2}
712+
chance: 0
713+
- item: {fileID: 11400000, guid: b27eeae83168bce49ba810731a0200b5, type: 2}
714+
chance: 0
715+
- item: {fileID: 0}
716+
chance: 0
713717
roll: 12
714718
entityToSpawn: {fileID: 4739109322253644523, guid: 0a001269a7880c74bb4ce4d03dd45397, type: 3}

Tests/Runtime/EntityExample.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using BigasTools.Rpg;
77
public class EntityExample : MonoBehaviour
88
{
9-
[SerializeField] Drop itemDrop;
9+
[SerializeField] Drop[] itemDrop;
1010
[SerializeField] int roll = 4;
1111
[SerializeField] Entity entityToSpawn;
1212
List<Entity> entitysOnExample = new List<Entity>();
@@ -17,7 +17,7 @@ private void Update() {
1717
e.onDispose += () =>{
1818
entitysOnExample.Remove(e);
1919
};
20-
LootTable.GetDrop(itemDrop, roll);
20+
LootTable.GetDrop(itemDrop[0], roll);
2121
entitysOnExample.Add(e);
2222
}
2323
if(BGameInput.Instance.GetKeyPress("Example")){

Tests/Runtime/ItemTest 1.asset

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: 8fafe0fcb32c6904593545c59b3e1c2e, type: 3}
13+
m_Name: ItemTest 1
14+
m_EditorClassIdentifier:
15+
itemName: Hammer
16+
description: Base Description
17+
quantity: 1
18+
sprite: {fileID: 21300000, guid: de6a423cd6dff9d4b95f3d9d6b3c94aa, type: 3}

Tests/Runtime/ItemTest 1.asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)