public void OnSelected() { if (selectedItem != this) { if (selectedItem != null) { //tell the other selected one that it's time to stop selectedItem.OnEscape(); } //just chosen to be spawned on the map. Put our object under the mouse cursor cursorObject = Instantiate(cursorPrefab, transform.root); SpriteRenderer curRend = cursorObject.GetComponent <SpriteRenderer>(); curRend.sprite = image.sprite; if (isPaletted) { curRend.material = prefab.GetComponentInChildren <SpriteRenderer>().sharedMaterial; MaterialPropertyBlock block = new MaterialPropertyBlock(); curRend.GetPropertyBlock(block); List <Vector4> pal = palette.ConvertAll((Color c) => new Vector4(c.r, c.g, c.b, c.a)); block.SetVectorArray("_ColorPalette", pal); block.SetInt("_IsPaletted", 1); curRend.SetPropertyBlock(block); } UIManager.IsMouseInteractionDisabled = true; escapeKeyTarget.enabled = true; selectedItem = this; drawingMessage.SetActive(true); lightingSystem.enabled = false; } }
public void OnEscape() { if (selectedItem == this) { //stop drawing Destroy(cursorObject); UIManager.IsMouseInteractionDisabled = false; escapeKeyTarget.enabled = false; selectedItem = null; drawingMessage.SetActive(false); lightingSystem.enabled = true; } }
public void OnSelected() { if (selectedItem != this) { if (selectedItem != null) { //tell the other selected one that it's time to stop selectedItem.OnEscape(); } //just chosen to be spawned on the map. Put our object under the mouse cursor cursorObject = Instantiate(cursorPrefab, transform.root); cursorObject.GetComponent <SpriteRenderer>().sprite = image.sprite; UIManager.IsMouseInteractionDisabled = true; escapeKeyTarget.enabled = true; selectedItem = this; drawingMessage.SetActive(true); lightingSystem.enabled = false; } }