public static void CacheSpriteWorker(UnityEngine.Object[] assets, Atlas atlas) { string assetName; for (int i = 0; i < assets.Length; ++i) { if (assets[i] is Sprite) { assetName = PathUtil.LastTrim(assets[i].name, '-'); if (!_atlasDict.ContainsKey(assetName)) { _atlasDict.Add(assetName, atlas); atlas.Add(assetName, assets[i] as Sprite); } #if UNITY_EDITOR else { Debug.LogWarning("duplicate sprite name : " + assetName + " oldAtlas : " + _atlasDict[assetName].name + " newAtlas : " + atlas.name); } #endif } if (assets[i] is Material) { atlas.material = assets[i] as Material; atlas.material.shader = Shader.Find("UI/Default(MW)"); } } }
public override Atlas LoadAtlas(string spriteName) { GameResInfo data; if (CheckRes(GameResType.Sprite, spriteName, out data)) { Atlas atlas = new Atlas(""); Sprite sp = LoadAssetAtPath(data.resPath, typeof(Sprite)) as Sprite; atlas.Add(spriteName, sp); return(atlas); } return(null); }
public void SaveSystem_GetSaveState_WithMap_ReturnsSaveStateWithSerialisedMap() { var mapCell = new Entity(0, "Map Cell", new IEntityComponent[] { new Appearance(), new Physical() }); _mutableEntities.Add(mapCell); var map = new Map("key", mapCell); _mapCollection.Add(map.MapKey, map); var result = _saveSystem.GetSaveState(); var expected = MapSerializer.Serialize(map); result.Maps.Single().Should().Be(expected); }
//private Cb4aCollisionMeshSoupFaceEdge BuildBspCollisionFaceSoupFaceEdge(BspCollisionFaceSoupFaceEdge e) //{ // return new Cb4aCollisionMeshSoupFaceEdge() { Normal = GetVec3Fixed(e.Normal), Distance = (int)e.Distance * AirplaySDKMath.IW_GEOM_ONE }; //} private void BuildLightmapAtlas(BspDocument bsp) { Dictionary<Bitmap, bool> lightmaps = new Dictionary<Bitmap, bool>(); CollectAllLightmaps(lightmaps); //TODO: Make multiple atlases 128x128 istead one huge atlas. The reason is that there is only 4096 steps in UV coordinate! Atlas atlas = new Atlas(); foreach (var l in lightmaps.Keys) { atlas.Add(l); } commonLightmap = new BspEmbeddedTexture() { Name = bsp.Name + "_lightmap", mipMaps = new Bitmap[] { atlas.Bitmap } }; UpdateLightmap(commonLightmap, atlas); // // Bitmap Lightmap = new Bitmap(128,128); // using (var g = Graphics.FromImage(Lightmap)) // { // g.Clear(Color.Red); // } // BspEmbeddedTexture lm = new BspEmbeddedTexture() { Name = "lightmap", mipMaps = new Bitmap[1] { Lightmap } }; // foreach (var l in leaves) // { // if (l.Geometry != null) // foreach (var f in l.Geometry.Faces) // if (f.Lightmap != null) // f.Lightmap = lm; // } }