一款基于卡牌的塔防游戏,类似于 Supercell 的《皇室战争》的游戏玩法(简化形式), 可以与“非智能”AI 进行比赛。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

54 行
1.7 KiB

using System;
using System.Reflection;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Controls
{
[AttributeUsage(AttributeTargets.Property)]
class CubemapControlAttribute : Attribute, IControlAttribute
{
string m_Label;
public CubemapControlAttribute(string label = null)
{
m_Label = label;
}
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo)
{
return new CubemapControlView(m_Label, node, propertyInfo);
}
}
class CubemapControlView : VisualElement
{
AbstractMaterialNode m_Node;
PropertyInfo m_PropertyInfo;
public CubemapControlView(string label, AbstractMaterialNode node, PropertyInfo propertyInfo)
{
m_Node = node;
m_PropertyInfo = propertyInfo;
if (propertyInfo.PropertyType != typeof(Cubemap))
throw new ArgumentException("Property must be of type Texture.", "propertyInfo");
label = label ?? ObjectNames.NicifyVariableName(propertyInfo.Name);
if (!string.IsNullOrEmpty(label))
Add(new Label(label));
var cubemapField = new ObjectField { value = (Cubemap)m_PropertyInfo.GetValue(m_Node, null), objectType = typeof(Cubemap) };
cubemapField.RegisterValueChangedCallback(OnChange);
Add(cubemapField);
}
void OnChange(ChangeEvent<UnityEngine.Object> evt)
{
m_Node.owner.owner.RegisterCompleteObjectUndo("Cubemap Change");
m_PropertyInfo.SetValue(m_Node, evt.newValue, null);
this.MarkDirtyRepaint();
}
}
}