Ejemplo n.º 1
0
    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;
        }
    }
Ejemplo n.º 2
0
 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;
     }
 }