标签:cts UI cut item click prevent validate tin 过滤
需要注意的有两点:
1.如果直接输出,每个没选中的物体都会执行一遍命令,需要过滤只让一个物体执行命令,但是我用Validate不太管用.直接在命令里过滤
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[CanEditMultipleObjects]
public class SelectionCount : Editor {
[MenuItem("GameObject/Get Selection Count",false,0)]
static public void GetSelectionCount(MenuCommand menuCommand)
{
//Prevent executing multiple times when right-clicking.
if (Selection.objects.Length > 1)
{
if (menuCommand.context != Selection.objects[0])
{
return;
}
}
Debug.Log("<color=yellow>选中的数量为" + Selection.objects.Length + "</color>");
}
}
标签:cts UI cut item click prevent validate tin 过滤
原文地址:http://www.cnblogs.com/ptqueen/p/6697215.html