Example #1
0
    private PooledGameObjectScript CreateGameObject(string prefabFullPath, Vector3 pos, Quaternion rot, bool useRotation, enResourceType resourceType, string prefabKey)
    {
        bool       needCached = false;// resourceType == enResourceType.BattleScene;
        GameObject gameObject = Singleton <ResourceManager> .GetInstance().GetResource(prefabFullPath, typeof(GameObject), resourceType, needCached, false).content as GameObject;

        if (gameObject == null)
        {
            return(null);
        }
        GameObject gameObject2;

        if (useRotation)
        {
            gameObject2 = (UnityEngine.GameObject.Instantiate(gameObject, pos, rot) as GameObject);
        }
        else
        {
            gameObject2 = (UnityEngine.GameObject.Instantiate(gameObject) as GameObject);
            gameObject2.transform.position = pos;
        }
        // DebugHelper.Assert(gameObject2 != null);
        PooledGameObjectScript pooledGameObjectScript = gameObject2.GetComponent <PooledGameObjectScript>();

        if (pooledGameObjectScript == null)
        {
            pooledGameObjectScript = gameObject2.AddComponent <PooledGameObjectScript>();
        }
        pooledGameObjectScript.Initialize(prefabKey);
        pooledGameObjectScript.OnCreate();
        return(pooledGameObjectScript);
    }