Cannot cast from source type to destination type.

Hi, I am trying to make a loading screen, where at the start of the scene, all of the objects are inactive, and then one by one, they activate.
Here is my current code.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class LoadingScreen : MonoBehaviour
{
	public float Percentage;
	public GameObject MainObj;
	// Use this for initialization
	void Start ()
	{
		
	}
	
	// Update is called once per frame
	void Update ()
	{
		Transform[] Trans = (Transform[])MainObj.transform.GetComponentsInChildren(typeof(Transform),true);
		
		
		//GameObject[] ActiveObjs;
		//Array Arr = new Array();
		List<GameObject> Active = new List<GameObject>();
	
		for(int i = 0; i<Trans.Length;i++){
			Trans*.gameObject.active = true;*

_ Active.Add(Trans*.gameObject);_
_
}*_

_ Percentage = (Trans.Length/Active.Capacity)100;_
_
}_
_
}*_
BTW the error is the title.
I am really stuck, please help.
Thanks
Tz

Could be nice to point to the line giving the error. I suppose it’s on :

 Transform[] Trans = (Transform[])MainObj.transform.GetComponentsInChildren(typeof(Transform),true);

if so, I would advice using the Generic version of the function :

 Transform[] Trans = MainObj.transform.GetComponentsInChildren<Transform>(true);

Also on another note, your purcentage will always return 0 : Length is an integer, as is Capacity (here you want to check Count instead, Capacity can be greater than the number of item in the list). So interger divide by interger will give you 0.

Do something like

Percentage = (int) ( ((float)Active.Count/(float)Trans.Length) * 100.0f)

And to finish, this won’t allow you to “see” your purcentage, because you will stall the update with the loop. Use a Coroutine so you can from time to time (each transform for example) yield for a frame.