这是第一个 Unity 开放项目的repo,是 Unity 和社区合作创建的一个小型开源游戏演示,第一款游戏是一款名为 Chop Chop 的动作冒险游戏。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

59 行
1.1 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
public partial class SceneSelector : EditorWindow
{
[Serializable]
private class Item
{
public string guid;
public int order = int.MaxValue;
public bool isVisible = true;
public Color color = Color.clear;
[NonSerialized]
public GameSceneSO gameSceneSO;
}
private class Styles
{
public GUIStyle item;
}
private class Textures
{
public Texture2D visibilityOn;
public Texture2D visibilityOff;
}
[Serializable]
private class Storage : ISerializationCallbackReceiver
{
[SerializeField]
public List<Item> items = new List<Item>();
[NonSerialized]
public Dictionary<string, Item> itemsMap = new Dictionary<string, Item>();
void ISerializationCallbackReceiver.OnBeforeSerialize()
{
for (int i = 0, count = items.Count; i < count; ++i)
{
var item = items[i];
item.order = i;
}
}
void ISerializationCallbackReceiver.OnAfterDeserialize()
{
items.OrderBy(x => x.order);
foreach (var item in items)
{
itemsMap.Add(item.guid, item);
}
}
}
}