ItemContainer.cs now filling with files (not working)
This commit is contained in:
parent
7ccf683005
commit
865fa08102
2 changed files with 22 additions and 11 deletions
|
|
@ -31,10 +31,12 @@ public class HouseController : MonoBehaviour {
|
||||||
|
|
||||||
public void ToggleMenu() {
|
public void ToggleMenu() {
|
||||||
menu.gameObject.SetActive(!menu.gameObject.activeSelf);
|
menu.gameObject.SetActive(!menu.gameObject.activeSelf);
|
||||||
float newPosY;
|
|
||||||
if (Camera.main != null) {
|
|
||||||
|
|
||||||
|
|
||||||
|
if (Camera.main != null) {
|
||||||
Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
|
Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
|
||||||
|
float newPosX = pos.x;
|
||||||
|
float newPosY;
|
||||||
|
|
||||||
if (pos.y - 50 - ((RectTransform)menuPanel.transform).rect.height >= 0) { //check if bottom of panel is in screen
|
if (pos.y - 50 - ((RectTransform)menuPanel.transform).rect.height >= 0) { //check if bottom of panel is in screen
|
||||||
newPosY = pos.y - ((RectTransform)menuPanel.transform).rect.height;
|
newPosY = pos.y - ((RectTransform)menuPanel.transform).rect.height;
|
||||||
|
|
@ -42,9 +44,7 @@ public class HouseController : MonoBehaviour {
|
||||||
newPosY = pos.y + ((RectTransform)menuPanel.transform).rect.height;
|
newPosY = pos.y + ((RectTransform)menuPanel.transform).rect.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
menuPanel.transform.position = new Vector3(pos.x, newPosY);
|
menuPanel.transform.position = new Vector3(newPosX, newPosY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class ItemContainer : MonoBehaviour {
|
public class ItemContainer : MonoBehaviour {
|
||||||
|
|
@ -18,12 +19,22 @@ public class ItemContainer : MonoBehaviour {
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public Item[] allItems;
|
private List<Item> _allItems;
|
||||||
// Start is called before the first frame update
|
|
||||||
|
private void Start() {
|
||||||
|
string[] files =
|
||||||
|
Directory.GetFiles("Assets/Items", "*.cs", SearchOption.AllDirectories);
|
||||||
|
foreach (string file in files) {
|
||||||
|
_allItems.Add(Resources.Load<Item>("Assets/Items/" + file));
|
||||||
|
}
|
||||||
|
Debug.Log(files);
|
||||||
|
Debug.Log(_allItems);
|
||||||
|
}
|
||||||
|
|
||||||
public Item GetItemByName(String name) {
|
public Item GetItemByName(String name) {
|
||||||
for (int i = 0; i < allItems.Length; i++) {
|
for (int i = 0; i < _allItems.Count; i++) {
|
||||||
if (allItems[i].displayName == name) {
|
if (_allItems[i].displayName == name) {
|
||||||
return allItems[i];
|
return _allItems[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue