Example #1
0
    void ArmyMouseDown(GameObjectAnimator army)
    {
        // Changes tank color to white
        Renderer renderer = army.GetComponentInChildren <Renderer>();

        renderer.sharedMaterial.color = Color.white;
        // Sprite newSprite = Resources.Load<Sprite>("/Sprites/AustrianInfantry1.png");
        // obj.GetComponent<SpriteRenderer>().sprite = newSprite;
    }
Example #2
0
    void RestoreArmyColor(GameObjectAnimator army)
    {
        // Restores original tank color
        Renderer renderer  = army.GetComponentInChildren <Renderer>();
        Color    tankColor = army.attrib["color"]; // get back the original color from attribute bag

        renderer.sharedMaterial.color = tankColor;
        // army.GetComponent<Animator>().SetTrigger("MakeIdle");
        //  army.GetComponent<Animator>().SetBool(key_isRun, false);
        //army.GetComponent<Animator>().SetBool(key_isAttack01, false);

        // obj.GetComponentInChildren<SpriteRenderer>().color = Color.blue;
    }
Example #3
0
    void ArmyHover(GameObjectAnimator army)
    {
        // Changes tank color - but first we store original color inside its attribute bag
        Renderer renderer = army.GetComponentInChildren <Renderer>();

        army.attrib["color"] = renderer.sharedMaterial.color;
        // army.GetComponent<Animator>().SetTrigger("MakeAttack");
        // army.GetComponent<Animator>().SetBool(key_isAttack01, true);

        //Sprite newSprite = Resources.Load<Sprite>("/Sprites/AustrianInfantry1.png");
        //obj.GetComponent<SpriteRenderer>().color = Color.white;
        renderer.material.color = Color.yellow; // notice how I use material and not sharedmaterial - this is to prevent affecting all clone instances - we just want to color this one, so we need to make this material unique.
    }