Initial import of Rhyculator
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
728bb0c657
315 files changed
+96030
No files matched your search
@@ -0,0 +1,52 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GridDisplay_MainScene : MonoBehaviour
|
||||
{
|
||||
public GridManager_MainScene gridManager;
|
||||
|
||||
public Sprite imgAccount;
|
||||
public Sprite imgSetting;
|
||||
public Sprite imgWebsite;
|
||||
|
||||
private bool initialized = false;
|
||||
|
||||
void Update()
|
||||
{
|
||||
// 等待 GridManager
|
||||
if (!initialized && gridManager != null && gridManager.gridCells != null)
|
||||
{
|
||||
if (gridManager.gridCells[0,0] != null)
|
||||
{
|
||||
InitDisplay();
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InitDisplay()
|
||||
{
|
||||
PlaceImage(1, 5, imgAccount);
|
||||
PlaceImage(2, 5, imgSetting);
|
||||
PlaceImage(3, 5, imgWebsite);
|
||||
}
|
||||
|
||||
void PlaceImage(int cellX, int cellY, Sprite sprite)
|
||||
{
|
||||
var cell = gridManager.gridCells[cellX, cellY];
|
||||
if (cell == null) return;
|
||||
|
||||
GameObject obj = new GameObject("DisplayIcon", typeof(RectTransform), typeof(Image));
|
||||
obj.transform.SetParent(cell.transform, false);
|
||||
|
||||
Image img = obj.GetComponent<Image>();
|
||||
img.sprite = sprite;
|
||||
img.preserveAspect = true;
|
||||
|
||||
RectTransform rt = obj.GetComponent<RectTransform>();
|
||||
rt.anchorMin = Vector2.zero;
|
||||
rt.anchorMax = Vector2.one;
|
||||
rt.offsetMin = Vector2.zero;
|
||||
rt.offsetMax = Vector2.zero;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user