示例#1
0
        public void UpdatePreviewTexture(IconUtil.GUIDIconData iconData = null)
        {
#if UNITY_EDITOR
            Vector2Int size = new Vector2Int(64, 64);
            Texture2D  iconTexture;
            if (_wallSurface == null && _ceilingSurface == null && _sillSurface == null && _openingSurface == null)
            {
                iconTexture = new Texture2D(1, 1);
            }
            else
            {
                Color32[] textureArray;
                WallSectionGenerator.Texture(out textureArray, this, size, Vector2.one * 2);
                iconTexture = new Texture2D(64, 64, TextureFormat.ARGB32, false);
                iconTexture.SetPixels32(0, 0, 64, 64, textureArray);
                iconTexture.Apply(false, false);
            }

            string assetPath = UnityEditor.AssetDatabase.GetAssetPath(this);
            string guid      = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
            if (iconData == null)
            {
                iconData = IconUtil.GenerateGUIDIconData(guid);
            }

            IconUtil.SaveIcon(iconData.tempTexturePath, iconTexture);
            customIconPath = iconData.tempTexturePath;
#endif
        }
示例#2
0
        private void LoadPreviewTexture()
        {
#if UNITY_EDITOR
            if (string.IsNullOrEmpty(customIconPath))
            {
                string assetPath = UnityEditor.AssetDatabase.GetAssetPath(this);
                string guid      = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
                IconUtil.GUIDIconData iconData = IconUtil.GenerateGUIDIconData(guid);
                customIconPath = iconData.tempTexturePath;
            }
            _previewTexture = IconUtil.GetIcon(customIconPath);
            if (_previewTexture == null)
            {
                UpdatePreviewTexture();
                _previewTexture = IconUtil.GetIcon(customIconPath);
            }
#endif
        }
示例#3
0
        private void UpdatePreviewTexture(IconUtil.GUIDIconData iconData = null)
        {
            HUtils.log();
#if UNITY_EDITOR
            if (GetBaseWallSection(0, 0) != null)
            {
                Vector2Int size = new Vector2Int(64, 64);
                Color32[]  previewTextureArray = new Color32[size.x * size.y];
                string     assetPath           = UnityEditor.AssetDatabase.GetAssetPath(this);
                string     guid = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
                if (iconData == null)
                {
                    iconData = IconUtil.GenerateGUIDIconData(guid);
                }
                previewTextureArray = SimpleTextureGenerator.GenerateFacadePreview(this, size, new Vector2Int(4, 4));
                Texture2D iconTexture = new Texture2D(64, 64, TextureFormat.ARGB32, false);
                iconTexture.SetPixels32(0, 0, 64, 64, previewTextureArray);
                iconTexture.Apply(false, false);
                IconUtil.SaveIcon(iconData.tempTexturePath, iconTexture);
                customIconPath = iconData.tempTexturePath;
                //                UnityEditor.AssetDatabase.Refresh();
            }
#endif
        }