예제 #1
0
 private void Initialize3DGameObjects()
 {
     this.m_3DGameObjects.Clear();
     for (int i = 0; i < base.gameObject.transform.childCount; i++)
     {
         GameObject gameObject = base.gameObject.transform.GetChild(i).gameObject;
         CUIUtility.SetGameObjectLayer(gameObject, CUI3DImageScript.s_cameraLayers[(int)this.m_imageLayer]);
         if (this.m_renderCamera.orthographic)
         {
             this.ChangeScreenPositionToWorld(gameObject, ref this.m_pivotScreenPosition);
         }
         CUI3DImageScript.C3DGameObject c3DGameObject = new CUI3DImageScript.C3DGameObject();
         c3DGameObject.m_path              = gameObject.name;
         c3DGameObject.m_gameObject        = gameObject;
         c3DGameObject.m_useGameObjectPool = false;
         c3DGameObject.m_protogenic        = true;
         c3DGameObject.m_bindPivot         = true;
         this.m_3DGameObjects.Add(c3DGameObject);
     }
     this.m_renderCamera.enabled = (this.m_3DGameObjects.get_Count() > 0);
 }
예제 #2
0
        public GameObject AddGameObject(string path, bool useGameObjectPool, ref Vector2 screenPosition, bool bindPivot, bool needCached = false, string pathToAdd = null)
        {
            GameObject gameObject = null;

            if (useGameObjectPool)
            {
                gameObject = Singleton <CGameObjectPool> .GetInstance().GetGameObject(path, 5);
            }
            else
            {
                GameObject gameObject2 = (GameObject)Singleton <CResourceManager> .GetInstance().GetResource(path, typeof(GameObject), 5, needCached, false).m_content;

                if (gameObject2 != null)
                {
                    gameObject = (GameObject)Object.Instantiate(gameObject2);
                }
            }
            if (gameObject == null)
            {
                return(null);
            }
            Vector3 localScale = gameObject.transform.localScale;

            if (pathToAdd == null)
            {
                gameObject.transform.SetParent(base.gameObject.transform, true);
            }
            else
            {
                Transform transform = base.gameObject.transform.Find(pathToAdd);
                if (transform)
                {
                    gameObject.transform.SetParent(transform, true);
                }
            }
            gameObject.transform.localPosition = Vector3.zero;
            gameObject.transform.localRotation = Quaternion.identity;
            CUI3DImageScript.C3DGameObject c3DGameObject = new CUI3DImageScript.C3DGameObject();
            c3DGameObject.m_gameObject        = gameObject;
            c3DGameObject.m_path              = path;
            c3DGameObject.m_useGameObjectPool = useGameObjectPool;
            c3DGameObject.m_protogenic        = false;
            c3DGameObject.m_bindPivot         = bindPivot;
            this.m_3DGameObjects.Add(c3DGameObject);
            if (this.m_renderCamera.orthographic)
            {
                this.ChangeScreenPositionToWorld(gameObject, ref screenPosition);
                if (!this.m_renderCamera.enabled && this.m_3DGameObjects.get_Count() > 0)
                {
                    this.m_renderCamera.enabled = true;
                }
            }
            else
            {
                Transform transform2 = base.transform.FindChild("_root");
                if (transform2 != null)
                {
                    if (pathToAdd == null)
                    {
                        gameObject.transform.SetParent(transform2, true);
                    }
                    else
                    {
                        Transform transform3 = base.gameObject.transform.Find(pathToAdd);
                        if (transform3)
                        {
                            gameObject.transform.SetParent(transform3, true);
                        }
                    }
                    gameObject.transform.localPosition = Vector3.zero;
                    gameObject.transform.localRotation = Quaternion.identity;
                    gameObject.transform.localScale    = localScale;
                }
            }
            CUIUtility.SetGameObjectLayer(gameObject, (!this.m_renderCamera.enabled) ? 31 : CUI3DImageScript.s_cameraLayers[(int)this.m_imageLayer]);
            return(gameObject);
        }