8

String-keying / Hashmaps Are fast, as read time is amortized O(1), meaning that read access is usually very fast, but in worst cases (rare, but not unheard of), it can be quite slow. Worst case results from hash collisions. Implementations sometimes have to be built, or found (for instance, in C). Writing / finding a performant string-keyed map ...


5

Back in the days of C and no templates... we had void pointers. Good thing they weren't made obsolete, because you have just seen that templates aren't omnipotent gods. This situation is perfect for some void pointer hacks. Here, I tried to make an example that was as simple as possible: Edit: The example below makes a dangerous use of shared_ptr, please ...


5

Naughty Dog seems to use scheme for describing both the data and how it should be read. However, my knowledge of scheme is non-existent so I have no clue how that would work. This would however, solve my problem, as the data would describe itself see reference. Not something I would recommend if you are a solo developer or a small group of developers. This ...


4

When the players want to edit stuff, they will find out how. Hardcoding attributes won't stop a determined modder for long. So I would recommend you to do the only sensible thing and put that data in a config file. XML is just one option. Some people prefer JSON or custom formats because they are simpler to write and read. When you don't want to make the ...


4

I believe this could be an issue with the AssetManager as it uses an objectMap which maps loaded objects to the string used to load them. In this case you're loading the font and the assetManager is storing it in it's objectMap under the key "fonts/Roboto-Regular.ttf", then when you load your font again with second set of parameters the previous font is ...


3

You want to be able to easily sort by material in order to render everything that has the same material at once. This helps a lot with efficiency. So it's almost definitely a bad idea to store materials by actual value though this may seem handy for some reason. Instead move to some kind of index into a materials array. The rest is fine, logically speaking. ...


3

I believe creating this super editor will distract you from your true goal, to create a game. From the sound of it the editor will be more difficult to create than the actual game. Furthermore I don't believe you need such a tool for your project. An easy way to approach this is by breaking all different resources the game needs into categories and create a ...


3

Hardcoding this data as constants in the code would be terribly unpractical, requiring a recompile of the project for every change. Even for small games this is very annoying. To make the game data opaque, you either have to write custom binary formats or pack every text file into a compressed (ZIP) folder. You might even go to the extreme of encrypting ...


3

Easy indeed - you are looking for Asset Bundles, which you can read about here: https://unity3d.com/learn/tutorials/topics/scripting/assetbundles-and-assetbundle-manager In pre-2017 versions, you simply set the asset bundle at the bottom of the inspector for each asset. In 2017, I believe there have been some changes to have a UI that allows you to set ...


2

As Adam suggested, you can write your own custom loader which could implement a network connection to any type of server which could download assets during runtime and serve them up. Just implement the file loading interface it provides and request a url as a string for the asset name in the overriden load function and pass that to your downloader. Then you ...


2

Unfortunately, you can’t access the labels during runtime. As you said methods like AssetDatabase.GetLabels and AssetDatabase.FindAssets are part of the namespace UnityEditor, which can’t be used in runtime. But what you could do is: Write a editor script that export that all the labels information into a file and then in runtime read in that file, then ...


2

If you specifically mean revisioning large assets, GitHub has recently come to your rescue: Git Large File Storage :) Git LFS is supported by GitHub, BitBucker Server, Visual Studio Online, and GitLab. I'm sure some of the more boutique Git services have it as well, and you can install git-lfs on any servers you've manually configured. There's also source ...


2

I would recommend you use Assetmanager because that way when the application exits and you call manager.dispose() it automatically releases all resources you loaded. Example from the wiki Assetmanager AssetManager manager = new AssetManager(); This sets up a standard AssetManager, with all the loaders libgdx has in store at the moment. Let's see how the ...


2

Some better idea based on your approach: You have template<typename T> bool addFactory( std::unique_ptr<ResourceFactory<T>> factory ) so every factory added is a std::unique_ptr<ResourceFactory<T>>. So your loading code should be: template <typename T> ResourceHandle<T> load(const std::string &path) { std::...


2

Update Object in place. *cache["foo"] = Object(stuff); Or add a method that will reload the entire object. cache["foo"]->reload(stuff);


2

Turns out there's EditorSceneManager.LoadSceneInPlayMode which does exactly what I'm looking for! Awesome. I had asked on the Unity Forum and found the answer there


2

You don’t seem to have a lot of questions here, so I’ll answer the ones I see. Loading an asset bundle from a web server using a normal http/s URL works just fine. It can also load bundles from within the project, in the StreamingAssets folder, using Application.streamingAssetsPath, but that is irrelevant to your needs. As for the extra credit, you can run ...


2

The main advantage of Addressables is that they make it very easy for your game to acquire a certain asset by name at runtime. This used to be pretty annoying with asset bundles. First you had to know in which asset bundles that asset was hiding in. Then you had to find out if this asset bundles was already loaded, and when it wasn't you had to load it first....


1

While you certainly can do what you're doing I would suggest that you pass your AssetManager around yo the classes that need to load resources instead. So instead of doing BlockTextures.get(id); where you need to use the texture you should instead pass the AssetManager and do // Store this variable TextureAtlas atlas = manager.get(name, TextureAtlas.class);...


1

Your question is a bit unclear, but I assume you are asking: Why render the world of a 2D game using a single texture holding an indexable tileset instead of having the world pre-rendered from said tiles? What is the advantage to building the image of the world at runtime? There are many advantages to this. Firstly you are right that less memory ...


1

It's simply more convenient. If you store the tiles with ids, then you can easily convert those to coordinates on the texture, so you don't need to store the textures in an array or use switches. You also don't need to rebind the textures if you use an API like OpenGL or DirectX, and you only need a single reference for the textures instead of multiple ones. ...


1

Ordering the data is going to depend on existing data access patterns for your application. Profile first, and see what areas of execution are taking the longest as a result of cache misses. Once you've done that, interleaved data (array of structs) will almost certainly be better than splitting into massive arrays of a single element type. How you ...


1

In my project I use hashed strings, which are transformed, at compile time in unique (I wish!) numbers. So, when I need a resource, for example a texture I simply call MngTexture->get(hash("my_texture")) And since I'm creating a simple entity system framework and I need to load components data from files I created a simple language like json to store ...


1

You will need to save your things in Streaming Assets folder: http://docs.unity3d.com/Manual/StreamingAssets.html And using some serializer, if you are using Unity below version 4, you should use whydoidoit serializer: https://www.assetstore.unity3d.com/en/#!/content/3675 If you are using higher versions you can try an adapted version of this from ...


1

Put this in a editor folder inside the Assets folder. using System.Diagnostics; using UnityEditor; public class CustomBuild { [MenuItem("MyTools/Windows Build With Postprocess")] public static void BuildGame() { // Get filename. string path = EditorUtility.SaveFolderPanel("Choose Location of Built Game", "", ""); string[...


1

This issue only happens when using a mobile shader. When I shifted to the Standard shader, this issue disappeared. Perhaps this is a bug in Unity. So if you're having a similar problem, just shift to the Standard shader if possible.


1

This question has been posted several times on the Unity forums, and while I should think one would run into it before posting on here, I will repost it just in case. This one answer popped up across all iterations I could find, most commonly marked as the most useful answer. To quote: Hi :), just an adjucated guess[sic]: setting the category of your ...


Only top voted, non community-wiki answers of a minimum length are eligible