Sorry for the amateur question,
but for my Main Menu, when “Play” is pressed (which by the way is a Plane), i’d like two more planes to appear (preferably fade in). How exactly would I go ahead and do that?
Sorry for the amateur question,
but for my Main Menu, when “Play” is pressed (which by the way is a Plane), i’d like two more planes to appear (preferably fade in). How exactly would I go ahead and do that?
A few ways to do this, I’ll try to give you the simplest. Create your 3 planes in the editor. Make the plane you are going to click the parent of the 2 planes that will be invisible at first. Disable the mesh colliders for the invisibles. Then attach a script to your “main” plane, and use an [OnMouseDown][1] function. In this function, since your other two planes are the children, use [GetComponentsInChildren][2] to find the [MeshRenderer][3] components in each. On startup, set these to have 0 alpha in their color. Here’s a C# example. Check the links I posted for more help.
using UnityEngine;
using System.Collections;
public class EXAMPLE : MonoBehaviour
{
MeshRenderer[] planes;
Color color;
void Start()
{
color = Color.grey;
color.a = 0;
planes = GetComponentsInChildren<MeshRenderer>();
foreach(MeshRenderer plane in planes)
{
plane.renderer.material.color = color;
}
}
void OnMouseDown()
{
StartCoroutine(FadeInChildren());
}
IEnumerator FadeInChildren()
{
while(true)
{
color.a+= 0.01f;
if(color.a >= 1.0f)
{
StopAllCoroutines();
}
foreach(MeshRenderer plane in planes)
{
plane.renderer.material.color = color;
}
print (color.a);
yield return new WaitForEndOfFrame();
}
}
}