在扩展编辑器、绘制窗口等情况下我们需要用到ComboBox来进行多项选择,但是GUI中没有DropList的实现,所以需要自己做一个ComboBox的效果。
效果如下:
当点击Prefabs时,会更新出Prefabs下的所有预制体进行选择,然后进行地图编辑。
源码:
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
#if UNITY_EDITOR
public class ResourcesComboBox {
public bool isChoice = false;
public bool isDirComboBoxOpen = false;
public bool isResComboBoxOpen = false;
public GameObject[] resGameObjectArray;
private Vector2 start_pos = new Vector2(0, 0);
public string DirectoryComboList(string path) {
string[] names = Directory.GetDirectories(path);
string[] new_names = new string[names.Length + 1];
for (i