Exemplo n.º 1
0
        /// <summary>
        /// 改变按钮被点击后的状态
        /// </summary>
        /// <param name="type"></param>
        /// <param name="sprName"></param>
        /// <returns></returns>
        public SpriteState SetButtonStateSpr(EAtlasType type, string sprName)
        {
            SpriteState spriteSwop = new SpriteState();

            spriteSwop.pressedSprite = ResourceManager.Instance.GetSpriteByName((int)type, sprName);
            return(spriteSwop);
        }
Exemplo n.º 2
0
 public void SetTexture(EAtlasType atlasType, Texture2D tex)
 {
     m_textures[(int)atlasType] = tex;
     if (atlasType != EAtlasType.Default || tex != null)
     {
         return;
     }
     Type = ETexType.Invalid;
 }
        void LevelTextureSettingGUI()
        {
            var settings = target;

            settings.AtlasDimension    = EditorGUILayout.IntField("AtlasDimension", settings.AtlasDimension);
            settings.HalfTileDimension = EditorGUILayout.IntField("HalfTileDimension", settings.HalfTileDimension);

            m_currentView = (EAtlasType)EditorGUILayout.Popup("CurrentView: ", (int)m_currentView, m_viewOptions);
            if (m_currentView == EAtlasType.Length)
            {
                m_currentView = EAtlasType.Default;
            }
            settings.ActiveMaps[(int)m_currentView] = EditorGUILayout.Toggle("Active", settings.ActiveMaps[(int)m_currentView]);
        }
Exemplo n.º 4
0
        // ReSharper disable once FlagArgument
        static Texture2D GenerateAtlas(LevelTextureConfig config, EAtlasType atlasType)
        {
            var textureCollections = config.LevelTextureCollections;
            var tileWidthAndHeight = 2 * config.HalfTileDimension;
            var atlasSize          = new Vector2Int(config.AtlasDimension, config.AtlasDimension);

            //int widthAndHeight = texWidthAndHeight + (repeatedPixels * 2);
            var outputTexture = new Texture2D(config.AtlasDimension, config.AtlasDimension, TextureFormat.ARGB32, false);

            config.UVInset    = (float)k_repeatedPixels / config.AtlasDimension;
            config.UVTileSize = (float)tileWidthAndHeight / atlasSize.x;

            var allTexData = GatherAllTextures(textureCollections, config);

            var data = new GenerateAtlasData()
            {
                AtlasType       = atlasType,
                OutputTexture   = outputTexture,
                CurrentDim      = Vector2Int.zero,
                AtlasSize       = atlasSize,
                TileWidthHeight = tileWidthAndHeight,
                CurrentRowYEnd  = -1,
                X = 0,
                Y = 0
            };
            //currentRowYStart = 0,
            //blockXStart = 0,
            //blockXEnd = -1,
            //blockX = 0,
            //blockY = 0;

            var progressIndex = 0;
            var initialCount  = allTexData.Count;

            while (allTexData.Count > 0)
            {
                EditorUtility.DisplayProgressBar("Generating Atlas", $"{progressIndex}/{initialCount}", (float)(progressIndex++) / initialCount);
                var current = allTexData[0];

                if (GenerateAtlasProcessTexture(current, ref data) == OperationResult.Error)
                {
                    break;
                }
                allTexData.RemoveAt(0);
            }

            EditorUtility.ClearProgressBar();
            return(outputTexture);
        }
Exemplo n.º 5
0
 static string TextureAtlasPath(Object config, string textureDirectory, EAtlasType type) =>
 $"{textureDirectory}{config.name}{type}Atlas.png";
Exemplo n.º 6
0
 public Texture2D GetTexture(EAtlasType atlasType = EAtlasType.Default) =>
 m_textures[(int)atlasType];