67 lines
1.7 KiB
C#
67 lines
1.7 KiB
C#
using Cinemachine;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class xinXi : MonoBehaviour
|
|
{
|
|
public TMPro.TMP_Text zi;
|
|
public Image noMN;
|
|
public Image gu;
|
|
public Image jin;
|
|
public Image wz;
|
|
public GameObject bN;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void disXX()
|
|
{
|
|
string buildingName = bN.GetComponent<building>().buildingName;
|
|
if (!File.Exists(Application.streamingAssetsPath + "/XinXi.txt"))
|
|
{
|
|
Debug.LogError("Îļþ²»´æÔÚ!");
|
|
return;
|
|
}
|
|
string[] lines = File.ReadAllLines(Application.streamingAssetsPath + "/XinXi.txt");
|
|
|
|
for (int i = 0; i < lines.Length; i++)
|
|
{
|
|
string[] data = lines[i].Split('@');
|
|
if (data.Length >= 2)
|
|
{
|
|
string itemName = data[0];
|
|
string description = data[1];
|
|
}
|
|
if (data[0] == buildingName)
|
|
{
|
|
zi.text = data[1];
|
|
zi.text = zi.text.Replace("\\n", "\n");
|
|
return;
|
|
}
|
|
}
|
|
Sprite Name = Resources.Load<Sprite>("noModels/name/" + buildingName);
|
|
noMN.sprite = Name;
|
|
Sprite gu1 = Resources.Load<Sprite>("noModels/gu/" + buildingName);
|
|
gu.sprite = gu1;
|
|
Debug.Log(gu1);
|
|
Sprite jin1 = Resources.Load<Sprite>("noModels/jin/" + buildingName);
|
|
jin.sprite = jin1;
|
|
Sprite weizhi = Resources.Load<Sprite>("noModels/weizhi/" + buildingName);
|
|
wz.sprite = weizhi;
|
|
|
|
|
|
}
|
|
}
|