private Image AddPatch(int x, int y, string patchName, GameObject parent = null) { Sprite logo = DoomGraphic.BuildSprite(patchName, GameSetup.wad); GameObject newPatch = new GameObject(patchName); Image img = newPatch.AddComponent <Image>(); img.material = menuMaterial; img.sprite = logo; if (parent != null) { newPatch.transform.SetParent(parent.transform, false); } else { newPatch.transform.SetParent(gameObject.transform, false); } img.SetNativeSize(); img.rectTransform.anchorMin = new Vector2(0f, 1f); img.rectTransform.anchorMax = new Vector2(0f, 1f); img.rectTransform.anchoredPosition = new Vector2(x, -y); img.rectTransform.pivot = new Vector2(logo.pivot.x / Mathf.Pow(img.rectTransform.sizeDelta.x, 2), 1.0f - (logo.pivot.y / Mathf.Pow(img.rectTransform.sizeDelta.y, 2))); return(img); }
private void BuildCursor(GameObject parent) { cursorAnim1 = DoomGraphic.BuildSprite("M_SKULL1", GameSetup.wad); cursorAnim2 = DoomGraphic.BuildSprite("M_SKULL2", GameSetup.wad); cursorImage = AddPatch(65, 83, "M_SKULL1", parent); }