Help with an error in scripting - extreme newbie

I have an error that I am unable to figure out: rror CS0308: The non-generic method `UnityEngine.GameObject.GetComponent(System.Type)’ cannot be used with the type arguments

Here is the code giving me grief:

	public void Q1False ()
	{
		Q1FalseButton.SetActive (false);
		Debug.Log ("False button clicked");
		Q1B = true;
		Debug.Log ("Q1B set to true");
		Q1TrueButton.GetComponent<BlinkEffect> (true);
		Debug.Log ("True set to blink");

	}

I’ve also tried replacing GetComponent with AddComponent with the same results.

BlinkEffect is essentially a .cs script attached to the UI and linked to the OnClick event of the False button. When the false button is clicked, I want the true button to start blinking, indicating the answer was actually True.

I know my code is probably laborious, but I am very new to scripting, coming from a design background, and I am trying to learn. I am reading the book: Learning C# Programming with Unity 3D, but the process is long, and I’m only on Chapter 3 - I’ve learned about ints, floats and doubles and the numbers they can handle and when to use them. But that doesn’t help me with this problem.

I’m hoping someone with more knowledge than me could help me out and point me in the right direction.

I did find this article:

but I don’t completely understand how to use this information to fix my issue.

Please help.
Respectfully,
Kimber

Remove the argument. Only GetComponentsInChildren and GetComponentsInParent have the optional argument to include inactive GameObjects. GetComponent on it’s own doesn’t use any arguments.

// Remove the "true" argument from GetComponent
Q1TrueButton.GetComponent<BlinkEffect>();

Maybe you want to enable that component? In that case, it would look like this:

Q1TrueButton.GetComponent<BlinkEffect>().enabled = true;

@cre8or

Here is a quick test script that I threw together using BlinkEffect of the UI Addons package. I created a UI Button component along with a UI Text component and BlinkEffect component.

This script will take the BlinkEffect either as a property through the inspector or if the script is attached to the same GameObject then it will get a reference to the the BlinkEffect component using GetComponent(). The ToggleBlink(() function toggles the blinking when the button is pressed.

using UnityEngine;
using System.Collections;
using UIAddons;

public class Test : MonoBehaviour
{
    public BlinkEffect blinkEffect;

	// Use this for initialization
	void Start ()
    {
        if (blinkEffect == null)
        {
            blinkEffect = gameObject.GetComponent<BlinkEffect>();
        }
	}
	
	public void ToggleBlink ()
    {
	    if (blinkEffect != null)
	    {
	        blinkEffect.isBlinking ^= true;
	    }
	}
}

this line:

Q1TrueButton.GetComponent<BlinkEffect> (true);

should probably look something like this:

Q1TrueButton.GetComponent<BlinkEffect>().someParameter = true;

… the GetComponent<>() method returns a component (which is an object), and does not take any regular parameters. the < BlinkEffect > isn’t strictly a parameter; it’s a generic/template specifier.