Search Unity

How to call to the image object? "Cannot convert method group `GetComponent' to non-delegate type...

Discussion in 'UGUI & TextMesh Pro' started by Mateix, Oct 18, 2014.

  1. Mateix

    Mateix

    Joined:
    Aug 15, 2014
    Posts:
    8
    Hey, I'm gonna to create a simple fade effect and I wrote this script, but that's not working.
    I'm getting an error:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3.  
    4. public class fadeImage : MonoBehaviour {
    5.     Image image;
    6.     float a = 255;
    7.  
    8.     void Start(){
    9.         image = GetComponent<Image>;
    10.     }
    11.  
    12.     void Update(){
    13.        a -= 0.33f * Time.deltaTime;
    14.        a = Mathf.Clamp01(a);
    15.        image.color = new Color(a, a, a, 255);
    16.     }
    17. }
    18.  
    The image is directly in the Canvas object. Please help.
     
    Last edited: Oct 18, 2014
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,411
    I think its just missing those ()
    Code (CSharp):
    1. image = GetComponent<Image>();
     
  3. TempestMia

    TempestMia

    Joined:
    Jun 5, 2013
    Posts:
    5
    *headdesks*

    I think I wasted an hour wondering why my GetComponent<Text>.text = "Something"; wasn't working... blahhh... thanks ;)
     
  4. ThatProgrammerJack

    ThatProgrammerJack

    Joined:
    Jan 6, 2019
    Posts:
    32
    Thank you for the help! I can't believe I forgot the parentheses.
     
  5. glenncode

    glenncode

    Joined:
    Mar 20, 2020
    Posts:
    1
    how do you get the angle brackets to show up ?