Hey,
i’m making a command window where you can enter text and it will do that fuction you have setup in the inspector.
So, here was my question what i want to do is if you type in “/Time 1400” it wil set time to 1400 or what ever number, but here is my problem i have set up that you can say “/Time” but how can i set the number to a new public value that i can send to the day and night cirkel??
waht i tought how can i detect a space and then set that number to a new public int that then can be send to the day and night cirkel.
All help is Appreciated!!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CommandWindow : MonoBehaviour {
public InputField CommandLine;
public string WritedCommand;
public string Itemtoaddtest;
[Space(10)]
public List<Commands> Command = new List<Commands>();
GameObject Manager;
void Awake()
{
Manager = GameObject.FindWithTag("Manager");
}
public void StartCommand()
{
WritedCommand = CommandLine.text;
CommandLine.text = "";
for (int i = 0; i < Command.Count; i++)
{
if (Command[i].CammandLine == WritedCommand)
{
if(Command[i].Function == Functions.AddItem)
AddItem();
if (Command[i].Function == Functions.Night)
Manager.GetComponent<DayNightController>().Night();
if (Command[i].Function == Functions.Day)
Manager.GetComponent<DayNightController>().Day();
}
}
}
public void AddItem()
{
ItemSystem itemSystem = Manager.GetComponent<ItemSystem>();
for (int i = 0; i < itemSystem.itemobjects.Count; i++)
{
if (itemSystem.itemobjects[i].Name == Itemtoaddtest)
{
itemSystem.itemobjects[i].Amount++;
itemSystem.itemobjects[i].Amount_T.text = itemSystem.itemobjects[i].Amount.ToString();
}
}
}
}
[System.Serializable]
public class Commands
{
public string Name;
public string CammandLine;
public Functions Function;
}
public enum Functions
{
Teleport,
AddItem,
Day,
Night
}