Ejemplo n.º 1
0
        private void RecordPrefabPosition(string path, GameObject go, Object prefab)
        {
            List <ScenePrefabData> list;

            if (prefabPos.ContainsKey(path) == false)
            {
                list = new List <ScenePrefabData>();
                prefabPos.Add(path, list);
            }
            else
            {
                list = prefabPos[path];
            }
            ScenePrefabData data = new ScenePrefabData();
            MeshRenderer    mr   = go.GetComponentInChildren <MeshRenderer>();

            if (mr == null)
            {
                data.lightIndex = -1;
            }
            else
            {
                data.lightIndex = mr.lightmapIndex;
                data.lightMap   = mr.lightmapScaleOffset;
            }
            data.scaler = go.transform.localScale;
            data.rotate = go.transform.eulerAngles;
            data.pos    = go.transform.position;

            list.Add(data);
        }
Ejemplo n.º 2
0
    void Start()
    {
        simpleLoader = new SimpleAssetLoader("Android");
        string text = File.ReadAllText(Application.streamingAssetsPath + "/level/yaosai.info");

        string[] lines = text.Split(new string[] { "\r\n" }, StringSplitOptions.None);
        if (lines.Length < 4)
        {
            Debug.LogError("Parse scene info file failed.");
            return;
        }
        int     mapWidth  = (int)float.Parse(lines[0]);
        int     mapHeight = (int)float.Parse(lines[1]);
        int     blockSize = (int)float.Parse(lines[2]);
        Vector3 vStartPos = Str2Vec3(lines[3]);

        for (int i = 4; i < lines.Length; ++i)
        {
            string[] col = lines[i].Split(new char[] { '\t' });
            if (col.Length == 6)
            {
                string assetName = col[0];

                ScenePrefabData data = new ScenePrefabData();
                data.pos        = Str2Vec3(col[1]);
                data.rotate     = Str2Vec3(col[2]);
                data.scaler     = Str2Vec3(col[3]);
                data.lightIndex = int.Parse(col[4]);
                data.lightMap   = Str2Vec4(col[5]);

                assets.Add(assetName);
                assetsPos.Add(data);
                int t = assetName.LastIndexOf("/");
                names.Add(assetName.Substring(t + 1, assetName.Length - t - 1));
            }
        }

        for (int i = 0; i < assets.Count; ++i)
        {
            simpleLoader.LoadAsset(assets[i], names[i], OnSuccess, i);
        }
    }