• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By Michael Santer
      Hi!
      We're currently two programmers and a game designer working on a turn-based tactics fantasy board game. For reference you can search for images of "Tactics Arena Online", a fairly dated game that used to have a lot of depth and complexity.
      Our goal is to use the same combat concepts, but giving it a much needed modern touch as well as a whole new set of heroes to choose from with additional abilities. The game is a mix of isometric and 3D and we plan to release the game on Steam and hopefully Android & iOS as well.
      We are looking for someone to work with us pro-bono (just like we're doing) as a 3D character artist. The skills needed are creativity, a hard working attitude and an ability to make minor animations (things like idle, walk, block and very rudimentary attack animations). A perk to have would be the ability to make some VFX. If the game makes it on steam and money starts coming in, you'd obviously be compensated for your hard work, but as it stands this is a hobby project to garnish your portfolio.
      A bit more about the game:
      This game will be an online multiplayer game where each user gets to pick up to 10 characters to place on his half of the board (this would be done before even entering matchmaking. Think runes in League of Legends for example). The user can place his 10 units of choice anywhere he likes on his half board. Some units can be used more than once. So if you want 4 knights and 2 mages or even if you want 10 clerics, you can do as you please. You can then save your setups for future use. The goal of the game is to wipe out the enemy team.
      Each character or Hero (except premium and abyss characters) start with 1 ability and they can ascend (either by playing a certain amount of matches with the character or by forcing the ascension with real money) to gain a new ability or passive. Acquiring a new character can be done by using in-game currency that you earn from playing matches or using real money with the exception of Abyss characters which can only be acquired by winning certain rare matches. The goal is to offer a freemium game with lots of customizable elements while making sure that no user can "buy power" with real money. We want everything that a paying user can get to be available to non-paying users who play the game a lot.
      Ultimately we want this to become a competitive game that people can enjoy and really get invested in. Each character is designed with options for counterplay in mind and synergy with other heroes.
       
      We sincerely believe in what this game can become and we home to find someone just as passionate as we are to get involved in this project!
    • By CrazyApplesStudio
         Hello , i would like to showcase my first game project, a simple endless casual arcade game called Apples Mania : Apple Catcher. The game has simple goal , scoring as high as possible by collecting falling apples while the difficulty gradually increases. Different apples are worth different amount of points and there are also 2 power-ups to help you in your challenge.
        The game took me about 2 months to complete and polish and i made everything except for the music tracks and some of the sound files. Made in unity and blender3d.
        Would appreciate any kind of feedback.
      Google Play Link
       
        A trailer showing basic game-play:
       
    • By drago28
      I'm using construct 2 physics I have a working bike with everything setup and I'm able to do frontflip and backflip by adding angular velocity to the bike
      I want to increase score/ add points and display the "backflip / frontflip" text when the bike does it.
      so please help me I want to know the logic and how it's done.
      p.s. example about construct 2 is not necessary, just explain me how other games do it or anything else you have to share
      Thanks,
      Drago
    • By otgs17
      You have 12 hours to search for supplies, transportation or you can continue your journey.
      But as soon as night falls, you must find shelter, turn it into a fortress to stand against the hordes of monsters.
      Equip soldiers, use bonuses and do not forget to follow the energy level of your fighters. 
      In battle be useful to your transport, it would be nice to find a tank.
      Every day the number of monsters to get more, they mutate into stronger and more dangerous forms.
      https://play.google.com/store/apps/details?id=com.otgs.FortTD&hl=en
      https://itunes.apple.com/us/app/fortress-td/id1367094965?mt=8
      https://www.youtube.com/watch?v=QIkXPikiRqc





  • Advertisement
  • Advertisement
Sign in to follow this  

Unity Unity remove sprite from memory and replace in next frame.

Recommended Posts

So I am working on a mobile game.

It uses slides for a story, the slides are very large. Each slide is almost 2048*2048; the max texture loading size I am using for the game.

 

My problem is that Unity keeps each slide in the memory after it's loaded, even when it will show only once per game. This leads to the game crashing on older mobiles.

My idea was to destroy each object after it was shown using a coroutine, so it deletes the past slide and loads the next slide. This worked because instead of crashing on 23 slides it crashed on 48 slides.

After some profiling I realized that destroy() isn't clearing all the memory that a slide used.

 

What I want to do now is assign a limited amount of memory as a slide slot. Then I need some way to unload the slide from the slot, freeing the slot for the next slide; without Unity storing the slides in the memory.

Any ideas on how I would do this? 

Share this post


Link to post
Share on other sites
Advertisement

First thought is to use a better texture compression algorithm.  The DXT# formats (often called dds format or S3 algorithms) give a 6:1 compression ratio.  PVRTC2 gives 8:1 or even 16:1 compression depending on which sub-format you use.  Others like ETC and ASTC also have great compression rates but varying hardware support.  Make sure you have set Unity to compress those textures.

After that, make sure you are actually destroying the textures. It will have some memory that won't instantly vanish but will be cleaned up, but the bulk of the memory should be immediately released.

You should be able to load them and replace them all as you go. The resources will be released as you move along, and assuming you've released all the references, the other allocations will be picked up by the garbage collector in due time.  (Note: Don't force the garbage collector to run. It is designed by default to run at lower priority during idle cycles, forcing it to run usually means interrupting time-sensitive work.)

Share this post


Link to post
Share on other sites
33 minutes ago, frob said:

 Others like ETC

I am using ETC1 with split alpha. It's the one that I find works on most mobiles, even if it has bad mips for iOS games.

I have designed all the art to take advantage of this and yes it reduces the 10mb textures to 2mb. Yet the problems are still there.

 

The worst part is I still have to add in sound.

38 minutes ago, frob said:

other allocations will be picked up by the garbage collector in due time.

It's the time that is a problem. The slides show one after the other, even with the bulk unloaded with destroy() it still builds to the crashing point before the slide show ends.

 

I feel like there should be a way just to load each slide over the last slide. So that the space used by it is now used by the new slide.

Share this post


Link to post
Share on other sites
19 hours ago, ferrous said:

What methods are you using to load and unload the slides?

None they are loaded by Unity once they are needed. The are just marked not to load on start up or they would prevent the game from even working on old mobiles.

 

Share this post


Link to post
Share on other sites

And just for clarification, exactly how old are these old phones you are talking about?

The official end of support for Android devices is 3 years after product launch or 18 months after first sale, which ever is longer. After that you're entirely on your own.

Apple devices are similar, 3 years of support.  The are called "vintage" for a few more years, then they're obsolete.

 

Everyone knows it is short, even us as consumers. However, as customers it is clear the devices are no longer supported, and as developers it is unrealistic to expect years-old devices to conform to this year's needs.

Share this post


Link to post
Share on other sites
6 hours ago, frob said:

The official end of support for Android devices is 3 years after product launch or 18 months after first sale, which ever is longer. After that you're entirely on your own.

I am testing on as many as I can find. With a samsung galaxy 2.7 made in 2012 I think, as my oldest; android.

Although I am not aiming to get it working on all of them, just on most off them.

 

The problem isn't the devices it's my images. At 6mb in memory and 60 of them I would use 360mb normally. Except Unity isn't normal, it uses 720mb of memory to have them all loaded.

Even on a new device that is scary, especially because it kept building without cleaning the memory.

I found out why. Unity loads the texture to the scene and to the UI image, making two instances. The level instance was also why I could not clear the memory of them once I was done with them.

The pointer the scene kept was preventing the garbage disposal from collecting it. There also appears to be no way of removing that scene pointer.

To fix this I am using a separate level that is streamed over the other(additive scene). The level holds 5 slides, once I am done I destroy() the level and make a new one holding the next 5. This works for most mobiles and as a IEnumerator I can load it without the player noticing.

 

So it's kind of fixed. Except than now I can't resist finding a way to make it work on the old galaxy. I also think I know how:

In my search for clearing the memory I learned Unity has a resource loading function. This could be used at the start of the game to choose between two slide packs. One with 6mb images and the other with say around 500kb images. The APK will be larger yet if t works I will be able to make a game that almost anyone could play.

The only problem I can think with this is detecting the players device. I think that the DPI check can be used then if the player has <200 DPI the smaller texture is loaded. In the options I will allow the player to also set the texture pack if they know there mobile can use it.

Edited by Scouting Ninja

Share this post


Link to post
Share on other sites

For those wondering if it worked.

I made a global image array to hold the slides.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameGlobals : MonoBehaviour {

//Just so I can call it when needed
public static Sprite[] StoredSlides;

}

Then before I load the level I load the sprites based on DPI

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class GameLoader : MonoBehaviour {

...
...
	private AsyncOperation LoadSync = null; //for loading the level
	private ResourceRequest request = null; //for laoding the slides
...
...
	private IEnumerator LoadLevel()
	{
		LoadSync = SceneManager.LoadSceneAsync("MainScene");
		yield return LoadSync;
	}

	private IEnumerator LoadLargeImages (string NameOfAnimation, int MaxFrames){
		for (int i = MaxFrames; i >= 1; i -= 1) {
			SpriteCount += 1;
			request = Resources.LoadAsync <Sprite>(NameOfAnimation+ SpriteCount.ToString());// The images follow MyName1 - MyName59
			GameGlobals.StoredSlides.SetValue (request.asset as Sprite, SpriteCount-1);
			yield return request; // return the sprite for use
		}
	}
  ...
  ...
    // Use this for initialization
	void Start () {
    	//Create a arry so we can use it
		GameGlobals.StoredSlides = new Sprite[60]; //Set size of array
		if (Screen.dpi >= 300 && OverSetting == false) { 
          // The OverSetting is to allow larger mobiles to set to low
			StartCoroutine (LoadLargeImages ("Large", 60));
		} else {
			StartCoroutine (LoadLargeImages ("Small", 60));
		}
	}
  ...
  ...
}

This works.

The Unity ResourceRequest keeps things in the APK and only loads the textures you need.

The 300 dpi works best, because all the mobiles that have a 1GB or more memory uses a larger dpi. Works on all the old mobiles I have gathered with no problems.

In the end it made the file 3mb larger, a extremely small sacrifice for compatibility.

Edited by Scouting Ninja

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Advertisement