Beispiel #1
0
        private void SetPatternName(string patternName)
        {
            if (patternTexture == null)
            {
                return;
            }

            var textureName = Path.GetFileNameWithoutExtension(patternName);

            if (patternName != null)
            {
                if (sourceTexture == null || currentTextureName != textureName)
                {
                    if (CheckCrossFade(textureName))
                    {
                        StartCrossFade();
                    }

                    sourceTexture      = patternTexture.GetPatternData(textureName);
                    currentTextureName = textureName;

                    if (sourceTexture == null)
                    {
                        Debug.LogErrorFormat("This texture is not found. {0}", textureName);
                    }

                    SetAllDirty();

                    selectionPatternName = patternName;
                }
            }
            else
            {
                sourceTexture        = null;
                currentTextureName   = null;
                selectionPatternName = null;
            }
        }
Beispiel #2
0
        // 元になったテクスチャ情報構築.
        private PatternData[] BuildPatternData(PatternTargetData[] targetDatas)
        {
            var result = new List <PatternData>();

            foreach (var targetData in targetDatas)
            {
                var texture   = targetData.texture;
                var assetPath = AssetDatabase.GetAssetPath(texture);
                var fullPath  = UnityPathUtility.ConvertAssetPathToFullPath(assetPath);

                var textureName = Path.GetFileNameWithoutExtension(assetPath);
                var assetGuid   = AssetDatabase.AssetPathToGUID(assetPath);
                var lastUpdate  = File.GetLastWriteTime(fullPath).ToUnixTime();
                var width       = texture.width;
                var height      = texture.height;
                var blockIds    = targetData.blocks.Select(x => x.blockId).ToArray();

                var item = new PatternData(textureName, assetGuid, lastUpdate, width, height, targetData.bx, targetData.by, blockIds);

                result.Add(item);
            }

            return(result.OrderBy(x => x.TextureName, new NaturalComparer()).ToArray());
        }