<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — Smart Gallery Remote Texture]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=2320</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=2320&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Smart Gallery Remote Texture.]]></description>
		<lastBuildDate>Wed, 09 Oct 2024 11:11:53 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Smart Gallery Remote Texture]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9674#p9674</link>
			<description><![CDATA[<p>Hello.</p><p>Unfortunately, I have never worked with FTP inside Unity.<br />I have looked at some examples for C#, but they don&#039;t work.</p><p>It is very easy to add third party source support in Smart Gallery. <br />You just need to implement your own content type, and select it in the gallery.<br />Example (doesn&#039;t work, but if you are already successfully downloading files via FTP, you can fix it):<br /></p><div class="codebox"><pre><code>using System.Collections;
using System.IO;
using System.Net;
using InfinityCode.SmartGallery.Modules;
using UnityEngine;

namespace InfinityCode.SmartGallery.ContentTypes
{
    public class FtpTextureContent: RawImageContent
    {
        public string url;
        public string login;
        public string password;
        
        public override bool allowZoom =&gt; true;
        public override string name =&gt; &quot;Ftp Texture&quot;;

        protected override void LoadContentData(Content content)
        {
            contentRawImage.enabled = false;
            messageSystem.SetLoadingState?.Invoke(true);
            content.viewer.StartCoroutine(LoadCoroutine());
        }

        private IEnumerator LoadCoroutine()
        {
            FtpWebRequest request = (FtpWebRequest)WebRequest.Create(url);
            request.Method = WebRequestMethods.Ftp.DownloadFile;
            request.Credentials = new NetworkCredential(login, password);
            FtpWebResponse response = (FtpWebResponse)request.GetResponse();
            Stream responseStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(responseStream);
            
            byte[] bytes = new byte[responseStream.Length];
            reader.BaseStream.Read(bytes, 0, bytes.Length);
            
            Texture2D texture = new Texture2D(2, 2);
            texture.LoadImage(bytes);
            
            if (texture == null)
            {
                messageSystem.SetLoadingState?.Invoke(false);
                Debug.LogError(&quot;Texture is null.&quot;);
                yield break;
            }
            
            contentRawImage.texture = texture;
            contentRectTransform.sizeDelta = new Vector2(texture.width, texture.height);
            
            content.InitContentSize();
            content.AdjustSize();
            messageSystem.SetLoadingState?.Invoke(false);
        }

        protected override bool ValidateProperties()
        {
            return true;
        }
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Wed, 09 Oct 2024 11:11:53 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9674#p9674</guid>
		</item>
		<item>
			<title><![CDATA[Smart Gallery Remote Texture]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9673#p9673</link>
			<description><![CDATA[<p>Hello, I purchased your Smart Gallery from the Unity Asset Store and it looks great. I am however having trouble loading remote assets. I can see how this is done in Unity by inserting files into the Inspector but I am going to load them via C Sharp from an ftp server file that downloads files within the app itself. Is there a script that would handle this in your asset? Looks like the way to do it would be to build a Gallery with the ftp files that I am loading to Persistent Data Path. Just trying to avoid writing another application if you had already put something in there to do it.</p>]]></description>
			<author><![CDATA[null@example.com (townsend35)]]></author>
			<pubDate>Tue, 08 Oct 2024 13:57:48 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9673#p9673</guid>
		</item>
	</channel>
</rss>
