Esempio n. 1
0
 protected void ChildAdded(ComponentAdded <Child> args)
 {
     if (args.handle.component.parent != null)
     {
         EntityHandle parentEntityHandle = world.LookUpEntity(args.handle.component.parent);
         if (parentEntityHandle != null)
         {
             ComponentHandle <Parent> parentHandle = parentEntityHandle.GetOrCreateComponent <Parent>();
             parentHandle.component.children.Add(args.handle.entity);
             GameObject parentObj = parentEntityHandle.GetOrCreateComponent <UnityGameObject>().component.gameObject;
             GameObject childObj  = world.GetOrCreateComponent <UnityGameObject>(args.handle.entity).component.gameObject;
             childObj.transform.parent = parentObj.transform;
         }
     }
 }
Esempio n. 2
0
        protected void CameraAdded(ComponentAdded <ProvenceCamera> args)
        {
            ComponentHandle <UnityGameObject> objectHandle = world.GetOrCreateComponent <UnityGameObject>(args.handle.entity);

            if (objectHandle != null && objectHandle.component.gameObject != null)
            {
                GameObject gameObject = objectHandle.component.gameObject;
                Camera     camera     = gameObject.GetComponent <Camera>();
                if (camera == null)
                {
                    camera = gameObject.AddComponent <Camera>();
                }
                args.handle.component.camera = camera;
                ProvenceCameraHook hook = gameObject.GetComponent <ProvenceCameraHook>();
                if (hook == null)
                {
                    hook = gameObject.AddComponent <ProvenceCameraHook>();
                }
                hook.Init(args.handle.world, args.handle.entity);
            }
        }
Esempio n. 3
0
        protected void MainCameraAdded(ComponentAdded <MainCamera> args)
        {
            ComponentHandle <ProvenceCamera> cameraHandle = world.GetOrCreateComponent <ProvenceCamera>(args.handle.entity);

            if (cameraHandle.component.camera == null)
            {
                cameraHandle = world.AddComponent <ProvenceCamera>(args.handle.entity);
            }
            cameraHandle.component.camera.gameObject.tag = "MainCamera";
            cameraHandle.component.camera.gameObject.SetActive(true);
            foreach (ComponentHandle <MainCamera> mainHandle in world.componentManager.GetAllComponents <MainCamera>())
            {
                if (mainHandle.entity != args.handle.entity)
                {
                    ProvenceCamera pCamera = world.GetComponent <ProvenceCamera>(mainHandle.entity).component;
                    pCamera.camera.tag = "Untagged";
                    pCamera.camera.gameObject.SetActive(false);
                    world.RemoveComponent <MainCamera>(mainHandle.entity);
                }
            }
        }
Esempio n. 4
0
        protected void ComponentAdded(ComponentAdded <UnityGameObject> args)
        {
            /* GameObject gameObject = args.handle.component.gameObject;
             * if(gameObject != null)
             *  gameObject.name = args.handle.entity.ToString();
             * else
             *  gameObject = GameObject.Find(args.handle.entity.ToString());
             * if(gameObject != null){
             *  args.handle.component.gameObject = gameObject;
             * }else{
             *  gameObject = new GameObject(args.handle.entity.ToString());
             *  args.handle.component.gameObject = gameObject;
             * }
             * gameObject.transform.position = args.handle.component.position;
             * gameObject.transform.rotation = args.handle.component.rotation; */
            GameObject gameObject = args.handle.component.gameObject;

            if (gameObject != null)
            {
                gameObject.name = args.handle.entity.ToString();
            }
            else
            {
                gameObject = GameObject.Find(args.handle.entity.ToString());
            }
            if (gameObject != null)
            {
                args.handle.component.gameObject = gameObject;
                args.handle.component.position   = gameObject.transform.position;
                args.handle.component.rotation   = gameObject.transform.rotation;
            }
            else
            {
                gameObject = new GameObject(args.handle.entity.ToString());
                args.handle.component.gameObject = gameObject;
                gameObject.transform.position    = args.handle.component.position;
                gameObject.transform.rotation    = args.handle.component.rotation;
            }
        }
Esempio n. 5
0
 protected void BlackAndWhiteComponentAdded(ComponentAdded <BlackAndWhiteImageEffect> args)
 {
     world.eventManager.AddListener <ImageEffectArgs>(BlackAndWhiteEffect);
 }