是否可以扩展新的单位ui组件,例如变换组件?因为当我尝试扩展按钮而不是转换组件时没有任何反应
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(Transform))]
public class CustomTransform : Editor
{
public override void OnInspectorGUI()
{
}
}
Run Code Online (Sandbox Code Playgroud) 我创建了一个课程列表。在这里您可以看到代码:
public class People{
public string name;
public int age;
}
public List<People> peopleInfo = new List<People>();
Run Code Online (Sandbox Code Playgroud)
我的问题是,例如,我有一个名字,现在我想知道年龄。我如何获得这些数据?我可以通过以下方式获得特定职位的姓名或年龄:
int pos = peopleInfo[0].name;
Run Code Online (Sandbox Code Playgroud)
但是,我怎么能倒过来做并获得名字的位置呢?当我有了这个时,就很容易获得年龄。
我正试图测试一个15拼图是否可以解决.我写了一个适用于大多数谜题的方法,但有些则没有.
例如,这个谜题可以通过两个动作(0,11),(0,12)来解决.
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 11, 13, 14, 15, 12
Run Code Online (Sandbox Code Playgroud)
这是更好的可视化拼图:
1 2 3 4
5 6 7 8
9 10 0 11
13 14 15 12
Run Code Online (Sandbox Code Playgroud)
但这个拼图的奇数奇偶校验为3,所以不应该是可以解决的.
public boolean isSolvable(int[] puzzle)
{
int parity = 0;
for (int i = 0; i < puzzle.length; i++)
{
for (int j = i + 1; j < puzzle.length; j++)
{
if (puzzle[i] > puzzle[j] && puzzle[i] != 0 && puzzle[j] != 0)
{ …Run Code Online (Sandbox Code Playgroud) 我正在使用parse.com进行身份验证.当用户通过身份验证时,我想从解析中加载一些数据,但这只应在身份验证成功时进行.我尝试用a取消任务CancellationToken,但它不起作用.这是示例代码:
CancellationTokenSource cts = new CancellationTokenSource();
ParseUser.LogInAsync(username, password).ContinueWith(t =>
{
if (t.IsFaulted || t.IsCanceled)
{
// Login failed
cts.Cancel();
}
return t;
}, cts.Token).Unwrap().ContinueWith(t =>
{
return LoadDataAsync();
}).Unwrap().ContinueWith(t =>
{
LoginSuccessful();
})
Run Code Online (Sandbox Code Playgroud)
可以取消这样的任务吗?或者我做错了什么?