예제 #1
0
    public void SetUserDogInfo(RES_USERDOGINFO packet)
    {
        GameObject         pUI      = MonoBehaviour.Instantiate(AssetBundleEx.Load <GameObject>("[Prefabs]/[Gui]/OtherPlayerProfile"), Vector3.zero, Quaternion.identity) as GameObject;
        OtherPlayerProfile pProfile = pUI.GetComponent <OtherPlayerProfile>();

        pProfile.Init(OnProfileExit, null, packet.userDogInfo, WorldManager.instance.m_player.CheckRoomLoadType(ROOM_LOAD_TYPE.NOFRIEND), true, packet.rateCntD, packet.isRatedD, null, 1);
    }
예제 #2
0
    private void CreateWindow()
    {
        GameObject createObj = Instantiate(AssetBundleEx.Load <GameObject>(ACHIEVEMENTWINDOW_PATH)) as GameObject;

        createObj.transform.localPosition = Vector3.zero;
        createObj.transform.localScale    = Vector3.one;

        m_achieveWindow = createObj.GetComponent <AchievementWindow>();
    }
예제 #3
0
    public void UpdateBackgroundTexture(string textureName)
    {
        m_uiBackgroundSelectPopup.ClosePopup();
        if (textureName.Equals(m_state.GetBackgroundTextureName) == false)
        {
            Texture texture = AssetBundleEx.Load <Texture>(string.Format("[Textures]/[PhotoStudio]/{0}", textureName));
            StartCoroutine("OnUpdateBackgroundTexture", texture);

            texture = null;
        }
    }
예제 #4
0
    /// <summary>
    /// <para>name : Init</para>
    /// <para>describe : 유저 정보 HUD를 생성하고, parent 밑에 붙입니다. parent가 null값일 시, Active가 꺼진 상태가 됩니다.</para>
    /// <para>tag : [email protected]</para>
    /// </summary>
    public void Init(Transform parent)
    {
        if (m_uiUserInfo == null || m_uiUserInfo.CheckUIUserInfoExists == false)
        {
            m_uiUserInfo = new UIUserInfo(Instantiate(AssetBundleEx.Load <GameObject>(USERINFO_PATH)) as GameObject);
        }

        m_uiUserInfo.Init(parent);

        InitUIDogLevelUp();
    }
예제 #5
0
    private void InitScroll()
    {
        m_itemObj  = AssetBundleEx.Load <GameObject>("[Prefabs]/[Gui]/LevelUnlock_ScrollItem");
        m_itemList = new List <UIScrollItem>();

        m_scrollPanel = m_transform.FindChild("ScrollWindow/ScrollView").GetComponent <UIPanel>();
        m_scrollView  = m_scrollPanel.GetComponent <UIScrollView>();
        m_scrollGrid  = m_scrollPanel.transform.FindChild("Grid").GetComponent <UIGrid>();

        InitItem();
    }
예제 #6
0
    public void OpenLevelUp()
    {
        if (m_uiUserLevelUp == null || m_uiUserLevelUp.CheckUIExists == false)
        {
            GameObject levelUpWindow = Instantiate(AssetBundleEx.Load <GameObject>("[Prefabs]/[Gui]/UI_S107_LevelUp")) as GameObject;
            levelUpWindow.name = "UI_S99_LevelUp";

            m_uiUserLevelUp = new UIUserLevelUp(levelUpWindow);
        }

        m_uiUserLevelUp.OpenPopup();
    }
예제 #7
0
    public void InitUIDogLevelUp()
    {
        if (m_UIDogLevelUp == null || m_UIDogLevelUp.GetTransform == null)
        {
            GameObject obj = Instantiate(AssetBundleEx.Load <GameObject>("[Prefabs]/[Gui]/UI_S109_DogLevelUp"), Vector3.zero, Quaternion.identity) as GameObject;
            obj.transform.name          = "UI_S109_DogLevelUp";
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;

            m_UIDogLevelUp = obj.AddComponent <UIDogLevelUp>();
            m_UIDogLevelUp.InitUIDogLevelUp();
        }
    }
예제 #8
0
    public void OpenLevelUpScenario(UserLevelInfo info)
    {
        if (m_uiLevelUpScenario == null || m_uiLevelUpScenario.CheckUIExists == false)
        {
            GameObject levelUpScenario = Instantiate(AssetBundleEx.Load <GameObject>("[Prefabs]/[Gui]/UI_S99_LevelUpTitle")) as GameObject;
            levelUpScenario.name = "UI_S99_LevelUpTitle";

            m_uiLevelUpScenario = new UILevelUpScenario(levelUpScenario);
        }

        StateManager.instance.m_curState.OnOffGUIState(false);

        m_uiLevelUpScenario.SetActive(true);
        StartCoroutine(m_uiLevelUpScenario.TitleTweenStart(info));
    }
예제 #9
0
    /// <summary>
    /// <para>name : AddExtraUserInfo</para>
    /// <para>describe : 메인 재화 HUD와 별개로, 따로 표시와 업데이트가 가능한 재화 HUD를 생성하고, parent 밑에 붙입니다.
    ///                      (주의!) 이 HUD 오브젝트는 리턴받은 UIUserInfo로 따로 관리해주세요. UserInfo.Instance로 관리되지 않습니다!
    /// <para>tag : [email protected]</para>
    /// </summary>
    public UIUserInfo AddExtraUserInfo(Transform parent, bool isUser = true)
    {
        UIUserInfo uiUserInfo = null;

        #region Instantiate
        uiUserInfo = new UIUserInfo(Instantiate(AssetBundleEx.Load <GameObject>(USERINFO_PATH)) as GameObject);
        #endregion

        #region InitUserInfo
        uiUserInfo.Init(parent);
        uiUserInfo.UpdateInfo(isUser);
        #endregion

        return(uiUserInfo);
    }
예제 #10
0
    public UIAchieveScrollGroup(GameObject obj)
    {
        m_obj       = obj;
        m_transform = obj.transform;

        m_background = obj.GetComponent <UISprite>();

        m_titleGroup = m_transform.FindChild("Title_Group").gameObject;
        m_titleLabel = m_transform.FindChild("Title_Group/Title").GetComponent <UILabel>();

        m_itemObj  = AssetBundleEx.Load <GameObject>("[Prefabs]/[Gui]/UIAchieve_Item");
        m_itemList = new List <UIAchieveInfoItem>();

        SetActive(false);
    }
예제 #11
0
파일: ResourceEx.cs 프로젝트: zwong91/Titan
    public static void GenerateResourceTable()
    {
        // get database path based on the path to the current .jar file
        string TYPE_FILE_PATH   = "types";
        string CLASSID_PATH     = "classes";
        string STRINGTABLE_PATH = "strings";

        TextAsset ta1 = Resources.Load(STRINGTABLE_PATH) as TextAsset;

        StringTable.stInt = new StringTable();
        StringTable.stInt.loadStrings(ta1.bytes);

        TextAsset    ta2     = Resources.Load(CLASSID_PATH) as TextAsset;
        MemoryStream classms = new MemoryStream(ta2.bytes);

        UnityClassDatabase.Instance.load(classms);

        TextAsset    ta3    = Resources.Load(TYPE_FILE_PATH) as TextAsset;
        MemoryStream typems = new MemoryStream(ta3.bytes);

        TypeTreeDatabase.Instance.load(typems);

        string[] filter = new string[] { "Texture2D" };
        //string path1 = "D:\\project\\speedex\\Bin\\Client\\Game\\Assets\\AssetBundles\\Web\\Scene_TaoYuan.unity3d";
        //string path2 = "D:\\project\\speedex\\Bin\\Client\\Game\\Assets\\AssetBundles\\Web\\Scene_Moba101.unity3d";
        //abm.Load(path1);
        //abm.Load(path2);
        string assetfilefolder = GetAssetFileFolder();

        abm.LoadBundleFromFolder(assetfilefolder, filter);

        resourcetable.Clear();
        foreach (KeyValuePair <string, AssetBundleEx> pair1 in abm.abhs)
        {
            AssetBundleEx ab = pair1.Value;
            foreach (AssetFileEx af in ab.afs.Values)
            {
                foreach (string classname in af.extractlist.Keys)
                {
                    if (resourcetable.ContainsKey(classname) == false)
                    {
                        resourcetable[classname] = new Dictionary <string, ResourceInfoEx>();
                    }
                    LoadResourceInfoFromAssetFile(ab, af, classname);
                }
            }
        }
    }
예제 #12
0
파일: ResourceEx.cs 프로젝트: zwong91/Titan
    private static void LoadResourceInfoFromAssetFile(AssetBundleEx ab, AssetFileEx af, string classname)
    {
        List <ObjectData> odlist = af.extractlist[classname];
        Dictionary <string, ResourceInfoEx> resourcetableoftype = resourcetable[classname];

        foreach (ObjectData od in odlist)
        {
            ResourceInfoEx currentinfo = new ResourceInfoEx();
            currentinfo.bundlename    = ab.name;
            currentinfo.assetfilename = af.sourceFile;
            currentinfo.objectname    = od.objectname;
            currentinfo.classname     = od.classname;
            currentinfo.typename      = od.typename;
            currentinfo.propertyfield = od.propertyfield;
            currentinfo.path          = od.path;
            object data = od.data;
            if (data is StreamBlock)
            {
                StreamBlock sdi = (StreamBlock)od.data;
                if (sdi != null)
                {
                    currentinfo.offset = sdi.offset;
                    currentinfo.length = sdi.length;
                }
            }

            if (currentinfo.objectname == null || currentinfo.objectname == "")
            {
                continue;
            }

            //if (currentinfo.path == null || currentinfo.path == "")
            //{
            //    continue;
            //}

            if (resourcetableoftype.ContainsKey(currentinfo.objectname))
            {
                ResourceInfoEx otherinfo = resourcetableoftype[od.objectname];
                //Logger.Log("current=" + currentinfo.objectname + "<" + currentinfo.typename + ">,other=" + otherinfo.objectname + "<" + otherinfo.typename + ">");
            }
            else
            {
                resourcetableoftype.Add(currentinfo.objectname, currentinfo);
            }
        }
    }
예제 #13
0
    private void InitItem()
    {
        GameObject createObj = AssetBundleEx.Load <GameObject>("[Prefabs]/[Gui]/UIAchieve_ScrollGroup");

        m_scrollGroupList = new List <UIAchieveScrollGroup>();

        for (int i = 0; i < SCROLL_GROUP_SIZE; i++)
        {
            GameObject obj = MonoBehaviour.Instantiate(createObj) as GameObject;
            obj.transform.parent        = m_scrollGrid;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localPosition = Vector3.zero;

            UIAchieveScrollGroup item = new UIAchieveScrollGroup(obj);
            m_scrollGroupList.Add(item);
        }
    }
예제 #14
0
    private void InitUI()
    {
        m_transform = transform;

        m_window   = m_transform.FindChild("ScreenShot/Anchor_Center/Window");
        m_uiWindow = new UIWindow(this, m_transform.FindChild("UI").gameObject);

        m_baseMaterial = AssetBundleEx.Load <Material>("[Materials]/[PhotoStudio]/Mat_PhotoStudio_Result");

        m_uiTexture          = m_window.FindChild("ScreenShot").GetComponent <UITexture>();
        m_uiTexture.material = Instantiate(m_baseMaterial) as Material;

        m_edge = m_window.FindChild("Edge").GetComponent <UISprite>();

        SetUISize(BASE_SCALE);

        m_workTimeline = new PhotoStudioWorkTimeline(this);
    }
예제 #15
0
    private void EditorInitMovingObjectList()
    {
        GameObject[] carObject = new GameObject[3];
        carObject[0] = AssetBundleEx.Load <GameObject>("[Prefabs]/[Others]/Prb_Car02");
        carObject[1] = AssetBundleEx.Load <GameObject>("[Prefabs]/[Others]/Prb_Car03");
        carObject[2] = AssetBundleEx.Load <GameObject>("[Prefabs]/[Others]/Prb_Car04");

        m_carGroup = new Transform[EDITOR_MAX_CAR];
        for (int i = 0; i < EDITOR_MAX_CAR; i++)
        {
            m_carGroup[i] = Instantiate(carObject[Random.Range(0, carObject.Length)].transform, Vector3.one * 9999.0f, Quaternion.identity) as Transform;

            m_carGroup[i].parent          = transform.FindChild("S01_Group");
            m_carGroup[i].gameObject.name = string.Format("Car_{0:D2}", i);
            m_carGroup[i].localScale      = Vector3.one * 360.0f;

            Util.SetGameObjectLayer(m_carGroup[i].gameObject, LayerMask.NameToLayer("Background"));
        }
    }
예제 #16
0
    private Texture2D GetTexture()
    {
        string     texturePath = "";
        STATE_TYPE type        = StateManager.instance.m_curStateType;

        if (type.Equals(STATE_TYPE.STATE_ROOM))
        {
            texturePath = "[Textures]/[ScreenOut]/Tex_LoadingScene_04";
        }
        else if (type.Equals(STATE_TYPE.STATE_VILLAGE))
        {
            texturePath = "[Textures]/[ScreenOut]/Tex_LoadingScene_03";
        }
        else
        {
            return(null);
        }

        return(AssetBundleEx.Load <Texture2D>(texturePath));
    }
예제 #17
0
    public UIUserLevelUp(GameObject obj)
    {
        m_obj       = obj;
        m_transform = obj.transform.FindChild("Anchor_Center/Window");

        #region Label
        m_labelArray = new UILabel[(int)LABEL_TYPE.TYPE_END];
        string[] labelPathArray = { "Level_Group/Level", "Reward_Group/Gems_Group/Value" };
        for (int i = 0; i < labelPathArray.Length; i++)
        {
            m_labelArray[i] = m_transform.FindChild(labelPathArray[i]).GetComponent <UILabel>();
        }
        #endregion

        #region Sprite
        m_spriteArray = new UISprite[(int)SPRITE_TYPE.TYPE_END];
        string[] spritePathArray = { "Reward_Group/Item_Group/Item_Icon_Group/Icon", "Reward_Group/Gems_Group/Icon" };
        for (int i = 0; i < spritePathArray.Length; i++)
        {
            m_spriteArray[i] = m_transform.FindChild(spritePathArray[i]).GetComponent <UISprite>();
        }
        #endregion

        #region Object
        string[] objPathArray = { "Title_Group", "Reward_Group", "Reward_Group/Item_Group", "Reward_Group/Gems_Group" };
        m_objArray = new GameObject[(int)OBJECT_TYPE.TYPE_END];

        for (int i = 0; i < objPathArray.Length; i++)
        {
            m_objArray[i] = m_transform.FindChild(objPathArray[i]).gameObject;
        }
        m_objArray[(int)OBJECT_TYPE.TYPE_EFFECT] = AssetBundleEx.Load <GameObject>("[Prefabs]/[Effects]/FX_UI_LevelUp");
        #endregion

        #region Callback
        m_transform.GetComponent <UIEventListener>().onTutorialClick = OnLevelUpWindowClick;
        #endregion

        OnOffTitleGroup(false, true);
        OnOffRewardGroup(false, true);
    }
예제 #18
0
    /// <summary>
    /// <para>name : InitBuildingDummy</para>
    /// <para>describe : 빌딩/레벨 표지판 더미 위치 데이터를 초기화.</para>
    /// <para>tag : [email protected]</para>
    /// </summary>
    private void InitBuildingDummy()
    {
        m_dicBuildingDummy  = new Dictionary <int, Transform>();
        m_dicLevelFlagDummy = new Dictionary <int, Transform>();

        Transform buildingGroup = transform.FindChild("Building_Group");

        for (int i = 0; i < buildingGroup.childCount; i++)
        {
            Transform child = buildingGroup.GetChild(i);
            if (child.name.Contains("Building_"))
            {
                int    index    = 0;
                string indexStr = child.name.Replace("Building_", "");
                if (int.TryParse(indexStr, out index))
                {
                    if (m_dicBuildingDummy.ContainsKey(index))
                    {
                        m_dicBuildingDummy[index] = child;
                    }
                    else
                    {
                        m_dicBuildingDummy.Add(index, child);
                    }

                    Transform levelChild = child.FindChild("LevelFlag");
                    if (m_dicLevelFlagDummy.ContainsKey(index))
                    {
                        m_dicLevelFlagDummy[index] = levelChild;
                    }
                    else
                    {
                        m_dicLevelFlagDummy.Add(index, levelChild);
                    }
                }
            }
        }

        m_buildingButtonGroup  = new List <BuildingButton>();
        m_buildingButtonObject = AssetBundleEx.Load <GameObject>("[Prefabs]/[Gui]/Town_Building_Button");
    }
예제 #19
0
    private void InitEmojiList()
    {
        m_getItemCount = 0;

        m_emojiItemGroup = m_window.FindChild("PhotoEmojiGroup");

        m_emojiItem       = AssetBundleEx.Load <GameObject>("[Prefabs]/[Gui]/PhotoEmoji");
        m_emojiItemList   = new List <PhotoStudioEmojiItem>();
        m_installItemList = new List <PhotoStudioEmojiItem>();

        for (int i = 0; i < MAX_EMOJI_COUNT; i++)
        {
            GameObject obj = Instantiate(m_emojiItem) as GameObject;
            obj.transform.parent        = m_emojiItemGroup;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            obj.name = string.Format("EmojiItem_{0:D2}", i);

            m_emojiItemList.Add(obj.GetComponent <PhotoStudioEmojiItem>());
        }
    }
예제 #20
0
    void Awake()
    {
        m_transform = transform;
        m_window    = m_transform.FindChild("Anchor_Center/Window");

        #region Button
        m_window.FindChild("CloseButton").GetComponent <UIEventListener>().onClick = OnClose;
        m_window.FindChild("HelpButton").GetComponent <UIEventListener>().onClick  = OnHelp;
        #endregion

        #region Tab
        SelectTab selectTab = new SelectTab(OnSelectTab);
        m_tabGroup = new UITab[(int)ACHIEVE_TAB_TYPE.TYPE_END];
        string[] tabPathArray = { "Tab_Group/Daily_Tab", "Tab_Group/Progress_Tab", "Tab_Group/Complete_Tab" };

        for (int i = 0; i < tabPathArray.Length; i++)
        {
            m_tabGroup[i] = new UITab(m_window.FindChild(tabPathArray[i]).gameObject, (ACHIEVE_TAB_TYPE)i, selectTab);
        }
        #endregion

        #region Scroll
        m_scrollPanel = m_window.FindChild("ScrollWindow/ScrollView").GetComponent <UIPanel>();
        m_scrollView  = m_scrollPanel.GetComponent <UIScrollView>();
        m_scrollGrid  = m_scrollPanel.transform.FindChild("Grid");
        m_scrollBar   = m_window.FindChild("ScrollWindow/ScrollBar").GetComponent <UIScrollBar>();

        m_emptyView = m_window.FindChild("ScrollWindow/EmptyView").gameObject;

        InitItem();
        #endregion

        #region Object
        GameObject tooltipObj = Instantiate(AssetBundleEx.Load <GameObject>("[Prefabs]/[Gui]/UIItemTooltip")) as GameObject;
        tooltipObj.transform.parent        = m_window;
        tooltipObj.transform.localPosition = Vector3.zero;
        tooltipObj.transform.localScale    = Vector3.one;
        m_uiItemTooltip = tooltipObj.GetComponent <UIItemTooltip>();
        #endregion
    }
예제 #21
0
    private void InitTalkDummy()
    {
        m_dicTalkDummy = new Dictionary <int, Transform>();
        Transform talkGroup = transform.FindChild("Talk_Group");

        for (int i = 0; i < talkGroup.childCount; i++)
        {
            Transform child = talkGroup.GetChild(i);
            if (child.name.Contains("Talk_"))
            {
                int    index    = 0;
                string indexStr = child.name.Replace("Talk_", "");
                if (int.TryParse(indexStr, out index))
                {
                    if (m_dicTalkDummy.ContainsKey(index))
                    {
                        m_dicTalkDummy[index] = child;
                    }
                    else
                    {
                        m_dicTalkDummy.Add(index, child);
                    }
                }
            }
        }

        GameObject talkObj = AssetBundleEx.Load <GameObject>("[Prefabs]/[Gui]/UITownTalkItem");

        m_talkGroup = new List <TownTalkItem>();
        for (int i = 0; i < 15; i++)
        {
            GameObject obj = Instantiate(talkObj) as GameObject;
            obj.transform.parent     = m_villageManager.m_panelGroup[(int)GUIManager_Village.PANEL_TYPE.PANEL_S13];
            obj.transform.localScale = Vector3.one;
            Util.SetGameObjectLayer(obj, LayerMask.NameToLayer("UIBackground"));

            m_talkGroup.Add(obj.GetComponent <TownTalkItem>());
        }
    }
예제 #22
0
        public UIDogIcon(GameObject obj)
        {
            m_obj       = obj;
            m_transform = obj.transform;

            #region Object
            m_selectObj = MonoBehaviour.Instantiate(AssetBundleEx.Load <GameObject>("[Prefabs]/[Effects]/FX_UI_Select02")) as GameObject;
            m_selectObj.transform.parent        = m_transform;
            m_selectObj.transform.localScale    = Vector3.one;
            m_selectObj.transform.localPosition = Vector3.zero; // new Vector3(-1.0f, 4.0f, 0);

            m_dogIcon    = m_transform.FindChild("DogIcon").GetComponent <UISprite>();
            m_background = m_transform.FindChild("Background").GetComponent <UISprite>();

            m_slider = m_transform.FindChild("Slider").GetComponent <UISlider>();
            #endregion

            #region Callback
            m_obj.GetComponent <UIEventListener>().onClick = OnItemClick;
            #endregion

            SetActive(false);
        }
예제 #23
0
    /// <summary>
    /// <para>name : InitMissionDummy</para>
    /// <para>describe : 미션 더미 위치 데이터를 초기화.</para>
    /// <para>tag : [email protected]</para>
    /// </summary>
    private void InitMissionDummy()
    {
        m_dicMissionDummy = new Dictionary <int, Transform>();
        Transform missionGroup = transform.FindChild("Mission_Group");

        for (int i = 0; i < missionGroup.childCount; i++)
        {
            Transform child = missionGroup.GetChild(i);
            if (child.name.Contains("Mission_"))
            {
                int    index    = 0;
                string indexStr = child.name.Replace("Mission_", "");
                if (int.TryParse(indexStr, out index))
                {
                    if (m_dicMissionDummy.ContainsKey(index))
                    {
                        m_dicMissionDummy[index] = child;
                    }
                    else
                    {
                        m_dicMissionDummy.Add(index, child);
                    }
                }
            }
        }

        m_eventObjGroup = new List <TownEventTrigger>();

        string[] townEventObjPath = { "",                                       "[Prefabs]/[Gui]/TownEventTrigger_Gold", "[Prefabs]/[Gui]/TownEventTrigger_Event", "[Prefabs]/[Gui]/TownEventTrigger_Gold",
                                      "[Prefabs]/[Gui]/TownEventTrigger_Event", "[Prefabs]/[Gui]/TownEventTrigger_Event" };
        m_townEventObjectGroup = new GameObject[(int)TOWN_OBJ_TYPE.TYPE_END];

        for (int i = 0; i < townEventObjPath.Length; i++)
        {
            m_townEventObjectGroup[i] = AssetBundleEx.Load <GameObject>(townEventObjPath[i]);
        }
    }
예제 #24
0
파일: ResourceEx.cs 프로젝트: zwong91/Titan
    public static void LoadAsyn(string relpath, Type t, ResourceAsynHandlerEx handler)
    {
        if (relpath == null || relpath.Length <= 0)
        {
            return;
        }

        if (!bEnable) //editor case
        {
            //return Resources.Load(relpath, t);
            return;
        }
        else
        {
            string classname = t.Name;
            if (resourcetable.ContainsKey(classname) == false)
            {
                return;
            }

            Dictionary <string, ResourceInfoEx> infolist = resourcetable[classname];
            if (infolist == null)
            {
                return;
            }

            string resname = Path.GetFileNameWithoutExtension(relpath);
            if (infolist.ContainsKey(resname) == false)
            {
                return;
            }

            ResourceInfoEx info = infolist[resname];

            //if (info.path == null || info.path.Length <= 0) return;
            //UnityEngine.Object retobj = Resources.Load(info.path, t);
            //if (retobj == null)
            //{
            //    retobj = Resources.Load(info.path);
            //}

            //if (!t.IsInstanceOfType(retobj))
            //{
            //    UnityEngine.Object extractobj = GetObjectFromDependent(retobj, resname, t);
            //    if (extractobj != null) retobj = extractobj;
            //}

            //if (t == null || !t.IsInstanceOfType(retobj))
            //{
            //    Debug.Log("resname=" + resname + ",respath=" + info.path);
            //    Debug.Log(retobj);
            //}
            //if (handler != null)
            //{
            //    handler(relpath, retobj);
            //}

            if (info.obj != null)//已经加载过的直接回调
            {
                info.refcount++;
                if (handler != null)
                {
                    handler(relpath, info.obj);
                }
                return;
            }

            if (info.length > 0)
            {
                if (abm.abhs.ContainsKey(info.bundlename))
                {
                    AssetBundleEx ab = abm.abhs[info.bundlename];
                    if (ab.afs.ContainsKey(info.assetfilename))
                    {
                        AssetFileEx af = ab.afs[info.assetfilename];
                        Stream      fs = af.stream;
                        fs.Position = info.offset;
                        byte[]             data       = new byte[info.length];
                        AsyncResourceState asyncState = new AsyncResourceState {
                            FS = fs, Buffer = data, Info = info, T = t, Handler = handler, ResourcePath = relpath
                        };
                        IAsyncResult asyncResult = fs.BeginRead(data, (int)0, (int)info.length, new AsyncCallback(AsyncReadCallback), asyncState);
                    }
                }
            }

            return;
        }
    }
예제 #25
0
파일: ResourceEx.cs 프로젝트: zwong91/Titan
    public static UnityEngine.Object Load(string relpath, Type t)
    {
        if (relpath == null || relpath.Length <= 0)
        {
            return(null);
        }

        if (!bEnable)
        {
            UnityEngine.Object retobj = null;
            try
            {
                if (LoadResourceEvent != null)
                {
                    retobj = LoadResourceEvent(relpath, t);
                }
            }
            catch
            { }
            return(retobj);
        }
        else
        {
            string classname = t.Name;
            if (resourcetable.ContainsKey(classname) == false)
            {
                return(null);
            }

            Dictionary <string, ResourceInfoEx> infolist = resourcetable[classname];
            if (infolist == null)
            {
                return(null);
            }

            string resname = Path.GetFileNameWithoutExtension(relpath);
            if (infolist.ContainsKey(resname) == false)
            {
                return(null);
            }

            ResourceInfoEx info = infolist[resname];

            //if (info.path == null || info.path.Length <= 0) return null;
            //UnityEngine.Object retobj = Resources.Load(info.path, t);
            //if (retobj == null)
            //{
            //    retobj = Resources.Load(info.path);
            //}

            //if (!t.IsInstanceOfType(retobj))
            //{
            //    UnityEngine.Object extractobj = GetObjectFromDependent(retobj, resname, t);
            //    if (extractobj != null) retobj = extractobj;
            //}

            //if (t == null || !t.IsInstanceOfType(retobj))
            //{

            //}
            //Debug.Log("resname=" + resname + ",respath=" + info.path);
            //Debug.Log(retobj);
            //return retobj;


            if (info.obj != null)
            {
                info.refcount++;
                return(info.obj); //已经有直接返回
            }

            UnityEngine.Object retobj = null;

            if (info.length > 0)
            {
                if (abm.abhs.ContainsKey(info.bundlename))
                {
                    AssetBundleEx ab = abm.abhs[info.bundlename];
                    if (ab.afs.ContainsKey(info.assetfilename))
                    {
                        AssetFileEx af = ab.afs[info.assetfilename];
                        Stream      fs = af.stream;
                        fs.Position = info.offset;
                        byte[] data = new byte[info.length];
                        int    ret  = fs.Read(data, (int)0, (int)info.length);
                        if (ret == info.length)
                        {
                            retobj = LoadByType(info, data, t);
                            loadedlist.Add(info);
                        }
                    }
                }
            }

            return(retobj);
        }
    }
    public void InstantiateObject(WskRequest wskRequest, string assetItem_PrefabName, string assetBundleName)
    {
        /*
         * (3) Environment selection & build script
         *
         *  3.1. Unity project configuration
         *  Create an empty Unity project. Assuming the game would have online features and we’ll
         *  have 3 environments (e.g. test, homologation and production, with different server URL’s),
         *  create a way to define which environment to connect. When hitting ‘Play’, the game must display
         *  which environment is selected.
         *
         */



        if (Application.platform == RuntimePlatform.WebGLPlayer)
        {
            url = basePath + "WebGL/" + assetBundleName;
        }
        else
        if (Application.platform == RuntimePlatform.Android)
        {
            url = basePath + "Android/" + assetBundleName;
        }
        else
        if (Application.platform == RuntimePlatform.WindowsPlayer ||
            Application.platform == RuntimePlatform.WindowsEditor)
        {
            // default - all other platforms

            url = basePath + "Windows/" + assetBundleName;
        }



        //TODO: 2 simultaneous AssetBundle request ==> only 1 async web request
        AssetBundleEx bundle_ex = null;

        for (int i = 0; i <= bundles.Count - 1; i++)
        {
            if (bundles[i].url == url)
            {
                bundle_ex = bundles[i];
            }
        }

        if (bundle_ex == null)
        {
            bundle_ex = new AssetBundleEx();
            if (bundle_ex.Requestlist == null)
            {
                bundle_ex.Requestlist = new List <WskRequest>();
            }
            bundle_ex.url = url;
            bundles.Add(bundle_ex);
        }

        //TODO: use correct assetname
        //string assetname = "avatar1";
        bundle_ex.assetItem_PrefabName = assetItem_PrefabName;


        bundle_ex.Requestlist.Add(wskRequest);
        Debug.Log("queue:" + bundle_ex.Requestlist.Count);



        if (bundle_ex.isReady_loadedOK)
        {
            //BundleReady_LoadedOK(bundle_ex);
        }
        else
        if (bundle_ex.loading)
        {
            // already loading, wait finish
        }
        else
        {
            // async request

            // start load and wait finish
            bundle_ex.loading = true;
            //StartCoroutine(RequestAssetBundleAsync(bundle_ex));
        }
    }