private CPooledGameObjectScript CreateGameObject(string prefabFullPath, Vector3 pos, Quaternion rot, bool useRotation, enResourceType resourceType, string prefabKey)
    {
        bool       needCached = resourceType == enResourceType.BattleScene;
        GameObject gameObject = Singleton <CResourceManager> .GetInstance().GetResource(prefabFullPath, typeof(GameObject), resourceType, needCached, false).m_content as GameObject;

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

        if (useRotation)
        {
            gameObject2 = (Object.Instantiate(gameObject, pos, rot) as GameObject);
        }
        else
        {
            gameObject2 = (Object.Instantiate(gameObject) as GameObject);
            gameObject2.transform.position = pos;
        }
        DebugHelper.Assert(gameObject2 != null);
        CPooledGameObjectScript cPooledGameObjectScript = gameObject2.GetComponent <CPooledGameObjectScript>();

        if (cPooledGameObjectScript == null)
        {
            cPooledGameObjectScript = gameObject2.AddComponent <CPooledGameObjectScript>();
        }
        cPooledGameObjectScript.Initialize(prefabKey);
        cPooledGameObjectScript.OnCreate();
        return(cPooledGameObjectScript);
    }
Exemplo n.º 2
0
    private CPooledGameObjectScript CreateGameObject(string prefabFullPath, Vector3 pos, Quaternion rot, bool useRotation, enResourceType resourceType, string prefabKey)
    {
        CPooledGameObjectScript component = null;
        bool       needCached             = resourceType == enResourceType.BattleScene;
        GameObject content = Singleton <CResourceManager> .GetInstance().GetResource(prefabFullPath, typeof(GameObject), resourceType, needCached, false).m_content as GameObject;

        if (content == null)
        {
            return(null);
        }
        GameObject obj3 = null;

        if (useRotation)
        {
            obj3 = UnityEngine.Object.Instantiate(content, pos, rot) as GameObject;
        }
        else
        {
            obj3 = UnityEngine.Object.Instantiate(content) as GameObject;
            obj3.transform.position = pos;
        }
        DebugHelper.Assert(obj3 != null);
        component = obj3.GetComponent <CPooledGameObjectScript>();
        if (component == null)
        {
            component = obj3.AddComponent <CPooledGameObjectScript>();
        }
        component.Initialize(prefabKey);
        component.OnCreate();
        return(component);
    }