Browse Source

More UI work

Josh_Dev_branch
Joshua Reason 5 years ago
parent
commit
64be9103e8
26 changed files with 203 additions and 51 deletions
  1. +8
    -0
      Assets/Data.meta
  2. +8
    -0
      Assets/Data/Inventory.meta
  3. +3
    -0
      Assets/Data/Inventory/PlayerInventory.asset
  4. +8
    -0
      Assets/Data/Inventory/PlayerInventory.asset.meta
  5. +0
    -0
      Assets/Data/Logic Blocks.meta
  6. +3
    -0
      Assets/Data/Logic Blocks/ForLoop.asset
  7. +0
    -0
      Assets/Data/Logic Blocks/ForLoop.asset.meta
  8. +3
    -0
      Assets/Data/Logic Blocks/Jump.asset
  9. +0
    -0
      Assets/Data/Logic Blocks/Jump.asset.meta
  10. +3
    -0
      Assets/Data/Logic Blocks/Move x2.asset
  11. +0
    -0
      Assets/Data/Logic Blocks/Move x2.asset.meta
  12. +3
    -0
      Assets/Data/Logic Blocks/Move.asset
  13. +0
    -0
      Assets/Data/Logic Blocks/Move.asset.meta
  14. +3
    -0
      Assets/Data/Logic Blocks/Rotate Left.asset
  15. +0
    -0
      Assets/Data/Logic Blocks/Rotate Left.asset.meta
  16. +3
    -0
      Assets/Data/Logic Blocks/Rotate Right.asset
  17. +0
    -0
      Assets/Data/Logic Blocks/Rotate Right.asset.meta
  18. +42
    -37
      Assets/Scenes/UI_TestScene.unity
  19. +50
    -0
      Assets/Scripts/Inventory.cs
  20. +11
    -0
      Assets/Scripts/Inventory.cs.meta
  21. +9
    -2
      Assets/Scripts/UI/BagItem.cs
  22. +4
    -1
      Assets/Scripts/UI/Dragable.cs
  23. +18
    -0
      Assets/Scripts/UI/InventoryUI.cs
  24. +11
    -0
      Assets/Scripts/UI/InventoryUI.cs.meta
  25. +3
    -10
      Assets/Scripts/UI/LogicElementUI.cs
  26. +10
    -1
      Assets/Scripts/UI/LogicTrayUI.cs

+ 8
- 0
Assets/Data.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 74b59a15d9c2e30459e9b45b426c0972
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 8
- 0
Assets/Data/Inventory.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2b285f3ab1dbf58489314e4a2ae4d931
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 3
- 0
Assets/Data/Inventory/PlayerInventory.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0c95bbb6ed08b700412d51e115fe5989b61124432da37f0bf4b4d51dc54cd8f2
size 415

+ 8
- 0
Assets/Data/Inventory/PlayerInventory.asset.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b6fa892e4c159bf46a2c4cda19627e97
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

Assets/Logic Blocks.meta → Assets/Data/Logic Blocks.meta View File


+ 3
- 0
Assets/Data/Logic Blocks/ForLoop.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:815e838d40fc858ba3fca1d9f6ac75c76fdd5b6e1859a7145c142a7f636d3a5f
size 616

Assets/Logic Blocks/ForLoop.asset.meta → Assets/Data/Logic Blocks/ForLoop.asset.meta View File


+ 3
- 0
Assets/Data/Logic Blocks/Jump.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4b1a4c27ea4794695f72f8d3f5d345c28103a2b6cc53e67b8f24f0757617b5e7
size 449

Assets/Logic Blocks/Jump.asset.meta → Assets/Data/Logic Blocks/Jump.asset.meta View File


+ 3
- 0
Assets/Data/Logic Blocks/Move x2.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6cd2eb3de9510a6319b174a92b11d1966b6f1bf6258b95c60b88af35c2666499
size 437

Assets/Logic Blocks/Move x2.asset.meta → Assets/Data/Logic Blocks/Move x2.asset.meta View File


+ 3
- 0
Assets/Data/Logic Blocks/Move.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8f30f384f120eeb69292d9ff04a9e267e536ef80a35c6a7820a032e88257d9e8
size 434

Assets/Logic Blocks/Move.asset.meta → Assets/Data/Logic Blocks/Move.asset.meta View File


+ 3
- 0
Assets/Data/Logic Blocks/Rotate Left.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:323f3c70cf40755730cb81a31da6a58931177674b836d0b5bbc8b9f88af4b447
size 456

Assets/Logic Blocks/Rotate Left.asset.meta → Assets/Data/Logic Blocks/Rotate Left.asset.meta View File


+ 3
- 0
Assets/Data/Logic Blocks/Rotate Right.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a6886b6e048617b3ecd1de69b35f0e598467d7d2444a59a26f58fcb16a988960
size 457

Assets/Logic Blocks/Rotate Right.asset.meta → Assets/Data/Logic Blocks/Rotate Right.asset.meta View File


+ 42
- 37
Assets/Scenes/UI_TestScene.unity View File

@ -380,7 +380,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d900b6d035606e046acdf763c041a7c9, type: 3}
m_Name:
m_EditorClassIdentifier:
logicElement: {fileID: 0}
logicElement: {fileID: 11400000, guid: 8f19e10be0ee35345a97f600791a8747, type: 2}
--- !u!1 &325775536
GameObject:
m_ObjectHideFlags: 0
@ -1612,7 +1612,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: 0.000037354246}
m_AnchoredPosition: {x: 0, y: 0.000038146973}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 1}
--- !u!114 &1011283039
@ -1847,7 +1847,7 @@ MonoBehaviour:
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Bits: 307
--- !u!114 &1152072199
MonoBehaviour:
m_ObjectHideFlags: 0
@ -1903,8 +1903,8 @@ RectTransform:
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 1822524397}
- {fileID: 1656111474}
- {fileID: 5884576982143469529}
- {fileID: 1656111474}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -2258,13 +2258,13 @@ RectTransform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1656111473}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 83}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 325775537}
- {fileID: 1843091044}
m_Father: {fileID: 1152072201}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
@ -3031,21 +3031,6 @@ PrefabInstance:
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 6169085588047038480, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: m_Color.g
value: 0.89918447
objectReference: {fileID: 0}
- target: {fileID: 6169085588047038480, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: m_Color.b
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6169085588047038480, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: m_Color.a
value: 0.8235294
objectReference: {fileID: 0}
- target: {fileID: 8025955820145340651, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: m_havePropertiesChanged
@ -3076,6 +3061,26 @@ PrefabInstance:
propertyPath: m_isInputParsingRequired
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1988277319744889208, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: m_Layer
value: 2
objectReference: {fileID: 0}
- target: {fileID: 6169085588047038480, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: m_Color.g
value: 0.89918447
objectReference: {fileID: 0}
- target: {fileID: 6169085588047038480, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: m_Color.b
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6169085588047038480, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: m_Color.a
value: 0.8235294
objectReference: {fileID: 0}
m_RemovedComponents:
- {fileID: 5230025352354844899, guid: f846db1cf36a645479ce131a2e0cf72f, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: f846db1cf36a645479ce131a2e0cf72f, type: 3}
@ -3237,7 +3242,7 @@ PrefabInstance:
- target: {fileID: 5884576982143469529, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: m_RootOrder
value: 2
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5884576982143469529, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
@ -3324,6 +3329,21 @@ PrefabInstance:
propertyPath: m_isInputParsingRequired
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6110492942520467780, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: m_havePropertiesChanged
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6110492942520467780, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: m_isInputParsingRequired
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5230025352354844899, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: dragOnSurfaces
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1307774795787687732, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: m_LocalRotation.y
@ -3364,21 +3384,6 @@ PrefabInstance:
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5230025352354844899, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: dragOnSurfaces
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6110492942520467780, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: m_havePropertiesChanged
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6110492942520467780, guid: f846db1cf36a645479ce131a2e0cf72f,
type: 3}
propertyPath: m_isInputParsingRequired
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f846db1cf36a645479ce131a2e0cf72f, type: 3}
--- !u!224 &5884576982143469529 stripped

+ 50
- 0
Assets/Scripts/Inventory.cs View File

@ -0,0 +1,50 @@
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "Major Project/Inventory", order = 150)]
public class Inventory : ScriptableObject
{
[SerializeField]
protected List<InventoryData> AllElements = new List<InventoryData>();
public void Add(LogicBlock element)
{
InventoryData data;
try
{
data = AllElements.First(p => p.element == element);
}
catch
{
data = new InventoryData() { element = element };
AllElements.Add(data);
}
data.Count++;
}
public void Remove(LogicBlock element) {
if (!AllElements.Exists(p => p.element == element))
return;
InventoryData data = AllElements.First(p => p.element == element);
if (!data.infinit)
data.Count--;
}
[System.Serializable]
public class InventoryData
{
public LogicBlock element;
public int Count;
public bool infinit = false;
}
}

+ 11
- 0
Assets/Scripts/Inventory.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ff7eab8b11178b24ca0b41861f79cadd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 2
Assets/Scripts/UI/BagItem.cs View File

@ -27,6 +27,12 @@ public class BagItem : Dragable
{
base.OnDrag(data);
DoTrayLogic(data);
string output = "";
foreach (GameObject hover in data.hovered)
output += hover.name + " ";
Debug.Log(output);
}
protected virtual void DoTrayLogic(PointerEventData data)
@ -48,7 +54,7 @@ public class BagItem : Dragable
}else if (isHovered)
{
isHovered = false;
tray.OnHoverEnd(this, rt);
tray.OnHoverEnd(this);
}
}
@ -60,7 +66,8 @@ public class BagItem : Dragable
if (isHovered)
{
isHovered = false;
//tray.OnHoverEnd(this, rt);
tray.InsertLogicElement(logicElement);
tray.OnHoverEnd(this);
}
}

+ 4
- 1
Assets/Scripts/UI/Dragable.cs View File

@ -20,12 +20,14 @@ public class Dragable : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag
m_DraggingIcon.transform.SetParent(canvas.transform, false);
m_DraggingIcon.transform.SetAsLastSibling();
m_DraggingIcon.layer = LayerMask.NameToLayer("Ignore Raycast");
var image = m_DraggingIcon.AddComponent<Image>();
image.sprite = GetComponent<Image>().sprite;
image.SetNativeSize();
m_DraggingPlane = canvas.transform as RectTransform;
SetDraggedPosition(eventData);
@ -50,7 +52,8 @@ public class Dragable : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDrag
public virtual void OnEndDrag(PointerEventData eventData)
{
Destroy(m_DraggingIcon);
m_DraggingIcon = null;
}
static public T FindInParents<T>(GameObject go) where T : Component

+ 18
- 0
Assets/Scripts/UI/InventoryUI.cs View File

@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InventoryUI : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

+ 11
- 0
Assets/Scripts/UI/InventoryUI.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 36cc4df775c8e8b46a89972d8008d56d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 3
- 10
Assets/Scripts/UI/LogicElementUI.cs View File

@ -4,15 +4,8 @@ using UnityEngine;
public class LogicElementUI : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
LogicBlock LogicElement;
}

+ 10
- 1
Assets/Scripts/UI/LogicTrayUI.cs View File

@ -28,12 +28,21 @@ public class LogicTrayUI : MonoBehaviour
UpdateDisplay();
}
public void OnHoverEnd(BagItem item, RectTransform rect)
public void OnHoverEnd(BagItem item)
{
insertIndex = -1;
UpdateDisplay();
}
public void InsertLogicElement(LogicBlock item)
{
if (insertIndex >= 0 && insertIndex <= list.Count)
{
list.Insert(insertIndex, item);
}
UpdateDisplay();
}
public void OnHoverUpdate(BagItem item, RectTransform rect)
{

Loading…
Cancel
Save