Ejemplo n.º 1
0
        public Component AddComponent(Type componentType)
        {
            for (int i = 0; i < _components.Count; i++)
            {
                if (_components[i].GetType() == componentType)
                {
                    // Already contains this component
                    return _components[i];
                }
            }
            Component c = Activator.CreateInstance(componentType) as Component;
            if (c is Transform) _transform = (Transform)c;
            if (c is SpriteRenderer) _renderer = (SpriteRenderer)c;
            if (c is Camera) _camera = (Camera)c;

            _components.Add(c);
            c.gameObject = this;
            c.Start();
            return c;
        }
Ejemplo n.º 2
0
 public override void Start()
 {
     // Set up main camera, if we dont have one
     if (mainCamera == null) mainCamera = this;
 }