Made image buttons get destroyed when done

This commit is contained in:
2026-01-14 11:25:19 +00:00
parent 441f738456
commit 69f0e3c9fc
4 changed files with 19 additions and 61 deletions

View File

@@ -1,4 +1,3 @@
using System;
using UnityEngine;
namespace InterfaceOff

View File

@@ -24,6 +24,8 @@ namespace InterfaceOff
new(-45, -45),
new(45f, -45)
};
private int m_TilesRotatedCorrectly;
public override void OnWindowInstantiation()
{
@@ -36,7 +38,7 @@ namespace InterfaceOff
t.sizeDelta = new Vector2(80, 80);
t.localPosition = Positions[i];
t.eulerAngles = new Vector3(0, 0, Random.Range(0, 4) * 90);
t.eulerAngles = new Vector3(0, 0, Random.Range(1, 4) * 90);
Image img = go.GetComponent<Image>();
img.material = new Material(Shader.Find("UI/Default"));
@@ -54,8 +56,22 @@ namespace InterfaceOff
rect.rotation = Quaternion.Euler(rot);
}
if (rect.rotation.eulerAngles.z < 45 && rect.rotation.eulerAngles.z > -45)
{
m_TilesRotatedCorrectly++;
button.interactable = false;
}
});
}
}
private void Update()
{
if (m_TilesRotatedCorrectly == 4)
{
Destroy(gameObject);
}
}
}
}