Why Update works with ExecuteInEditMode, while OnUpdate doesn’t work with ExecuteInEditMode? Or if it works, then tell me what I’m doing wrong.
I want to do something like this but couldn’t do. Kindly check the code
Update works with ExecuteInEditMode
using UnityEngine;
using UnityEngine.UI;
namespace Game.UI
{
[ExecuteInEditMode()]
public class TestUIWorks : MonoBehaviour
{
public Button button;
public virtual void Awake()
{
OnSkinUI();
}
public virtual void OnSkinUI()
{
}
protected virtual void Update()
{
if (!Application.isPlaying)
{ // set UI if it is not running in Editor
OnSkinUI();
}
}
}
}
OnUpdate don’t works with ExecuteInEditMode
using UnityEngine;
using Unity.Entities;
using UnityEngine.UI;
namespace Game.UI
{
[RequireComponent(typeof(GameObjectEntity))]
[ExecuteInEditMode()]
public class TestUI : MonoBehaviour
{
public Button button;
public virtual void Awake()
{
OnSkinUI();
}
public virtual void OnSkinUI()
{
}
}
class TestUISystem : ComponentSystem
{ // behaviour
struct Components
{
public TestUI testUIComponent;
}
protected override void OnUpdate()
{
if (!Application.isPlaying)
{ // set UI if it is not running in Editor
foreach (var e in GetEntities<Components>())
e.testUIComponent.OnSkinUI();
}
}
}
}
Any help regarding this