I don’t know the syntax and was wondering how I could create a function within a script that is able to be manipulated through the Eventsystem, such as changing a bool in that function to true.
Hi TheFacelessOne,
I don’t know if I understand right, it would be something like this?
using System;
using System.Reflection;
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
using UnityEngine.Events;
public class MyEventObject : MonoBehaviour, IEventSystemHandler
{
[RenamedSerializedData("onPress")]
[SerializeField]
private ButtonClickedEvent m_OnClick = new ButtonClickedEvent();
public void Start()
{
ButtonPressed();
}
private void ButtonPressed()
{
m_OnClick.Invoke(true);
}
[Serializable]
public class ButtonClickedEvent : UnityEvent<bool>
{}
}
Source: Unity events in inspector example - Pastebin.com
I don’t know who wrote the code but thank you!
I’m not sure if this works. Does it allow you to run the class/function/everything/whatever via the built-in UI Eventsystem? Instead of adding the script as a component.