using UnityEngine;
using UnityEngine.UI;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System;
using AC;
using System.Linq;
[RequireComponent (typeof (Hotspot))]
[AddComponentMenu("Adventure Creator/Hotspots/Override Item Prefix")]
public class OverrideItemPrefix : MonoBehaviour
{
private Hotspot _hotspot;
public string newPrefix;
private InventoryManager inventoryManager;
public InvItem InvItem;
private InvItem selectedItem;
private void Awake()
{
_hotspot = GetComponent<Hotspot>();
}
private void Update()
{
if (KickStarter.runtimeInventory.SelectedItem!=null)
{
selectedItem = KickStarter.runtimeInventory.SelectedItem;
}
}
private void OnEnable()
{
EventManager.OnHotspotSelect += OnHotspotSelect;
if (AdvGame.GetReferences().inventoryManager)
{
inventoryManager = AdvGame.GetReferences().inventoryManager;
}
// Create a string List of the field's names (for the PopUp box)
List<string> labelList = new List<string>();
int invNumber;
if (inventoryManager.items.Count > 0)
{
invNumber = 1;
foreach (InvItem _item in inventoryManager.items)
{
labelList.Add(_item.label);
}
EditorGUILayout.Space();
EditorGUILayout.BeginHorizontal();
invNumber = EditorGUILayout.Popup("Inventory item:", invNumber, labelList.ToArray());
ButtonGUI(invButton, "Inventory", _hotspot.interactionSource, true);
}
}
private void OnDisable()
{
EventManager.OnHotspotSelect -= OnHotspotSelect;
}
private void OnHotspotSelect(Hotspot hotspot)
{
if ((hotspot == _hotspot)&&(selectedItem == inventoryItem))
{
KickStarter.cursorManager.hotspotPrefix2.label = newPrefix;
}
else
{
KickStarter.cursorManager.hotspotPrefix2.label = "on";
}
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.