55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using UnityEngine;
|
|
using UnityEditor;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
public class TEst : MonoBehaviour
|
|
{
|
|
|
|
public CityExcelData manager = new CityExcelData();
|
|
public AggregateStation aggregateStation;
|
|
public List<Sprite> sprites = new List<Sprite>();
|
|
public List<GameObject> gameObjects = new List<GameObject>();
|
|
[ContextMenu("GetInfo")]
|
|
public void CreateItemAsset()
|
|
{
|
|
manager.cityItems = null;
|
|
manager.cityItems = ExcelTool.CreateItemArrayWithExcel(ExcelConfig.excelsFolderPath + "ɽ¶«ÐÐÕþÇø»®Êý¾Ý.xlsx");
|
|
|
|
for (int i = 0; i < transform.childCount; i++)
|
|
{
|
|
CityInfo c = transform.GetChild(i).GetComponent<CityInfo>();
|
|
c.cityName = c.gameObject.name;
|
|
for (int l = 0; l < manager.cityItems.Length; l++)
|
|
{
|
|
if (c.cityName == manager.cityItems[l].districtName)
|
|
c.distCode = manager.cityItems[l].divisionNumber;
|
|
}
|
|
}
|
|
|
|
}
|
|
[ContextMenu("CreateStation")]
|
|
public void CreateStation()
|
|
{
|
|
for (int i = 0; i < gameObjects.Count; i++)
|
|
{
|
|
DestroyImmediate(gameObjects[i]);
|
|
}
|
|
gameObjects.Clear();
|
|
for (int i = 0; i < transform.childCount; i++)
|
|
{
|
|
Transform t = transform.GetChild(i);
|
|
|
|
for (int j = 0; j < sprites.Count; j++)
|
|
{
|
|
AggregateStation _aggregateStation = Instantiate(aggregateStation, t);
|
|
_aggregateStation.transform.localPosition = new Vector3( Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 0.5f), 2f);
|
|
_aggregateStation.transform.localEulerAngles = new Vector3(90, 0, 0);
|
|
_aggregateStation.SetInfo(sprites[j], "0");
|
|
gameObjects.Add(_aggregateStation.gameObject);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|