您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
51 行
1.4 KiB
51 行
1.4 KiB
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.Experimental.UIElements;
|
|
|
|
#if UNITY_2018_1
|
|
using UnityEditor.Experimental.UIElements.GraphView;
|
|
#endif
|
|
|
|
namespace UnityEditor.ShaderGraph.Drawing
|
|
{
|
|
static class CompatibilityExtensions
|
|
{
|
|
#if UNITY_2018_1
|
|
public static void OpenTextEditor(this BlackboardField field)
|
|
{
|
|
field.RenameGo();
|
|
}
|
|
#endif
|
|
|
|
public static void AppendAction(this ContextualMenu contextualMenu, string actionName, Action action, Func<ContextualMenu.MenuAction.StatusFlags> actionStatusCallback)
|
|
{
|
|
Debug.Assert(action != null);
|
|
Debug.Assert(actionStatusCallback != null);
|
|
contextualMenu.AppendAction(actionName, e => action(), e => actionStatusCallback());
|
|
}
|
|
|
|
public static void AppendAction(this ContextualMenu contextualMenu, string actionName, Action action, ContextualMenu.MenuAction.StatusFlags statusFlags)
|
|
{
|
|
Debug.Assert(action != null);
|
|
contextualMenu.AppendAction(actionName, e => action(), e => statusFlags);
|
|
}
|
|
|
|
public static bool GetValue(this Toggle toggle)
|
|
{
|
|
#if UNITY_2018_1
|
|
return toggle.on;
|
|
#else
|
|
return toggle.value;
|
|
#endif
|
|
}
|
|
|
|
public static void SetValue(this Toggle toggle, bool value)
|
|
{
|
|
#if UNITY_2018_1
|
|
toggle.on = value;
|
|
#else
|
|
toggle.value = value;
|
|
#endif
|
|
}
|
|
}
|
|
}
|