Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by veleno94 · Mar 29, 2016 at 10:50 AM · imageserverdatabasegalleryphoto

Image Gallery

Hello everyone I would like to create a photo gallery in my android app. to reduce the size of the app I wish the pictures were downloaded from the Internet, but do not know which method to use. I have to create a database? I have to implement a server? help me please

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image chillersanim · Mar 29, 2016 at 10:57 AM 0
Share

What plattform are you targeting? Where and how are the images stored?

This question as it is now, is to broad to be answered.

avatar image veleno94 chillersanim · Mar 29, 2016 at 11:44 AM 0
Share

You're right, I'm sorry. I'm building an android app. To give you an example, I would like to create a photo gallery like that of the famous app "Backrounds HD" or any other app that provides backgrounds. I want to know what are the alternatives and what are their advantages and disadvantages.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by chillersanim · Mar 29, 2016 at 12:03 PM

You could use a web server running either a database or hosting the images directly.
Alternative, if the images are already available in the internet, you could use a table with all image urls you want to include.

Database:
The advantage of using a database is that you've got more control over the images available and you can store additional information.

Direct storage:
Storing the images directly on the server is easier, as you can just use the WWW class.

User costs:
Be aware that in either case, the user needs internet connection, and in the case of mobile development, downloading images can cost the user lots of MB on his phone abonement.

Caching:
If you are okay with using lot's of space AFTER the user installed the app, you could also download all images and store them on the disk.
Or, you could only store images which the user already viewed to prevent downloading the same image mutliple times.

Greetings
Chillersanim

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image veleno94 · Mar 29, 2016 at 12:17 PM 0
Share

Thank you so much, it is what I was looking for

avatar image
1

Answer by OmerDoron · Jan 19, 2017 at 08:12 AM

@veleno94 I made this for my project, kind of what you need (ignore "book" variables, it`s specific for my project).

Flow: Check if file exists (change the path to your path), if exists, open the file (this way you`d have to download it only the first time and not every time). if it`s not exist, download the file.

     using UnityEngine;
     using System.Collections;
     
         public class OnPressingPictureButton : MonoBehaviour {
         
             public int currentPage;
             public string [] imageURL;
             public Book book;
         
             public GameObject loading;
         
         
         // Update is called once per frame
             void Update () {
         
                 currentPage = book.page;
         
         }
         
         
         void OnMouseDown ()
         {
                 loading.SetActive (true); //@@@ "Loading ON"
         
         
                 //Checking if the file exists in the users device
                 if (System.IO.File.Exists (Application.persistentDataPath + "/image"+currentPage.ToString()+".jpg")) 
                 {
                     //if yes, open it
                     loading.SetActive (false);
                     Application.OpenURL (Application.persistentDataPath + "/image"+currentPage.ToString()+".jpg");
                 } 
         
         
                 //if not, download it
                         else {
             StartCoroutine (TestDownload (imageURL [currentPage]));
             
         }
 }
         
             private IEnumerator TestDownload (string uRL)
             {
         
                 WWW www = new WWW (uRL);
                 yield return www;
         
                 while (!www.isDone) {
         
                     Debug.Log (www.progress);
                     yield return null;
                 }
         
         
                 string savePath = Application.persistentDataPath + "/image"+currentPage.ToString()+".jpg";
         
                 byte[] bytes = www.bytes;
         
                 System.IO.File.WriteAllBytes (savePath, bytes);
         
                 loading.SetActive (false); //@@@ "Loading OFF"
         
                 Application.OpenURL (savePath);
         
             }
         }
















Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Players online counter 1 Answer

Remote database for leaderboard 2 Answers

Best way to connect to database for my mobile game? 3 Answers

[Closed] www.data help 0 Answers

How can I show image from server ? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges