Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Fade an Image of Game Object

Discussion in '2D' started by Mobvill, Jul 14, 2015.

  1. Mobvill

    Mobvill

    Joined:
    Jul 8, 2015
    Posts:
    5
    Hi

    I am using the DOTween extension and have been trying to fade out a single Image component of a game object.
    the game object is a child of a canvas.

    This is my code

    for(int i = 0; i < size; i++){
    array.getComponant<Image>().material.DOFade(0, 2);
    }

    The issue is that when I do the above all the other children of the canvas gets faded out.

    I am not sure how to use DOTween to just fade out a single image of a single Game Object

    any help would be appreciated

    Thx
     
  2. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    897
    If you want to fade just the Image, you need to fade its color component and not the material.
    Code (CSharp):
    1. GetComponent<Image>().color;
     
  3. Mobvill

    Mobvill

    Joined:
    Jul 8, 2015
    Posts:
    5
    Got it to work.

    Imports were not set up properly

    Thx