78 lines
2.4 KiB
C#
78 lines
2.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace SimpleInventorySystem
|
|
{
|
|
public class ContextMenuManagerUI : MonoBehaviour
|
|
{
|
|
public GameObject itemInspectMenu;
|
|
[HideInInspector] public ItemUI inspectItem;
|
|
public GameObject TacticalRigInspectionWindow;
|
|
|
|
private void Awake()
|
|
{
|
|
|
|
}
|
|
|
|
public void OpenContextMenu(ItemUI uiContext)
|
|
{
|
|
//ContextMenuUI.transform.SetParent(uiContext, false);
|
|
itemInspectMenu.SetActive(true);
|
|
itemInspectMenu.transform.position = uiContext.transform.position;
|
|
inspectItem = uiContext;
|
|
//ContextMenuUI.transform.localScale = new Vector3(1, 1, 1);
|
|
|
|
Button inspectButton = itemInspectMenu.transform.Find("Inspect").GetComponent<Button>();
|
|
Debug.Log("ContextMenuManager: " + inspectButton);
|
|
if (inspectButton != null)
|
|
{
|
|
inspectButton.onClick.AddListener(OpenInspectionWindow);
|
|
}
|
|
}
|
|
|
|
public void OpenInspectionWindow()
|
|
{
|
|
Debug.Log("Open");
|
|
if (inspectItem != null && inspectItem.ItemTag == ItemTags.TacticalRig && inspectItem.Equipped)
|
|
{
|
|
//Instantiate(TacticalRigInspectionWindow, InventorySystem.instance.inventoryUI.transform);
|
|
inspectItem.ContextWindows.Add(TacticalRigInspectionWindow);
|
|
TacticalRigInspectionWindow.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void CloseContextMenu()
|
|
{
|
|
if(inspectItem != null)
|
|
{
|
|
Button inspectButton = itemInspectMenu.transform.Find("Inspect").GetComponent<Button>();
|
|
if (inspectButton != null)
|
|
{
|
|
inspectButton.onClick.RemoveListener(OpenInspectionWindow);
|
|
}
|
|
}
|
|
inspectItem = null;
|
|
itemInspectMenu.SetActive(false);
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
itemInspectMenu.SetActive(false);
|
|
TacticalRigInspectionWindow.SetActive(false);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
if (Input.GetMouseButton(0))
|
|
{
|
|
//itemInspectMenu.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
} |