How to make a Transparent GameObject?

I have this script for making the material transparent. Is it right? Also it gives me this error:
Assets/MyGame/Transparent.cs(6,46): error CS1519: Unexpected symbol `=’ in class, struct, or interface member declaration
using UnityEngine;
using System.Collections;

public class Transparent : MonoBehaviour
{
	gameObject.renderer.material.color.a = 1;
}

Idk whats wrong with it though. Any answer helps :smiley:

Um.

Lots.

FIRST off, you can’t just have code sitting in a C# class. It needs to be in a method. In this case, probably the Start method

public class Transparent : MonoBehaviour
{
    void Start(){
       gameObject.renderer.material.color.a = 1;
    }
}

Secondly, you probably can’t set the color that way. Color is likely a struct which means you probably have to set gameObject.renderer.material.color to a complete color.

public class Transparent : MonoBehaviour
{
    void Start(){
       gameObject.renderer.material.color= 
              new Color(1.0f,1.0f.1.0f,1.0f);
    }
}

THIRD, alpha of 1.0 is fully opaque, you want something less then 1 if you want it to be translucent.

FOURTH, it wont work anyway unless you have a transparent renderer set.

i dont know if im missing something, or maybe is a new feature in unity 5 but i just selected “Rendering Mode: Transparent” inside my material, then assigned it to my gameObject and, thats it.