Repository URL to install this package:
Version:
1.3.1 ▾
|
using System;
using UnityEditor;
using UnityEngine;
namespace Fluctio.FluctioSim.EditorUtils.Gui
{
// Unity's ChangeCheckScope is not sane
public class ChangeCheck
{
private ChangeCheckScope _scope = null;
public IDisposable Scope()
{
if (_scope != null)
{
throw new InvalidOperationException("Can not create scope multiple times");
}
_scope = new ChangeCheckScope();
return _scope;
}
public bool Changed
{
get
{
if (_scope == null)
{
throw new InvalidOperationException("Can not check change without creating scope");
}
return _scope.Changed;
}
}
private class ChangeCheckScope : GUI.Scope
{
private bool _changed;
private bool _checkEnded = false;
public bool Changed
{
get
{
if (!_checkEnded)
{
throw new InvalidOperationException("Can not check change before scope ended");
}
return _changed;
}
}
public ChangeCheckScope() {
EditorGUI.BeginChangeCheck();
}
protected override void CloseScope()
{
_changed = EditorGUI.EndChangeCheck();
_checkEnded = true;
}
}
}
}