I’m working over a 3D platform for clients and I wish them to create at least prefabs in game. I know that it is designed to work only in Editor, but it is important for me to include such a feature in builds. My question: is it possible to provide Unity users with this possibility? I need my clients are able to import 3D models from the disk and then make them into prefabs to create their prefab collections. How to work with things imported at runtime (changing them, saving and loading).
You’ll need to roll your own system for that. Basically, track models uploaded by client, and parameters set to hose models. Nothing really prevents you from saving those to a json file and loading them later.
Thank you, guys!
I know about asset bundles and persistent data like JSON or serialization. I use them in my projec. But why don’t Unity Technologies include such a feature in Unity? It will be very useful because Unity is a platform not only for games but also for various tools. Those Editor functions should be available in builds. What is the obstacle to use them in builds. It would make work easier for many users including me.
Unity Team, please consider that. It is the only problem I have in Unity.
Editor functions create assets within the project. Those assets are later baked into data that is used by your runtime build. Editor functions can also modify those assets and even destroy them.
The reason why editor functions are not available at runtime is because the asset database is “frozen” and cannot be changed.
While having some sort of “PrefabsLite” for runtime purposes is not a bad idea, having editor functions available is not a good thing, simply because those functions can wipe out data used by your game, and having ability to wipe the data often would require elevated privilegies in runtime build.
In short what you’re looking for is not “Editor functions at runtime”, but rather ability to serialize and deserialize any object at runtime. Which is not exactly the same thing.
I understand, not all is probably possible at runtime. It’s not a game, it is a tool. Dangerous? So there should be a possibility to switch that on or off. All in a developer’s hands, of course.
As I said, I use serialization. However, it would be great to have a control over prefabs at runtime, for example you take two prefabs and make one from them, replace them, nest, etc. In other words, similar functions to those we have in editor. Now, you can only instantiate a prefab at runtime. What can I do more with it?
The simple answer why Unity doesn’t support building prefabs at runtime is Unity already built a tool for that, which is the Editor. The Editor’s purpose is to create games. You’re attempting to use the Editor to create standalone builds from the Editor that function as tools with output that goes back into the Editor… That’s not really the workflow Unity had in mind.
Since the Editor is free, there is no barrier to entry. Unity also included Editor Extensions to fill the role you’re trying to use a standalone build for. My opinion is whatever you’re trying to do you should be doing as an Editor Extension.
I have no experience with writing Editor Extensions, so my question: is there a possibility to write such an Editor Extension by me? Is there an API for that? My idea is to import a mesh at runtime by a client and create a prefab from it and then change this prefab, place in a Resource folder, load from the folder, etc. All done at runtime.
I think providing Unity users with such a possibility would make Unity more universal and multipurpose. We have investors and money, so it is the sphere Unity should be interested in. We are going to use the Enterprise level of Unity because we need special features.
I have in-build prefabs in Resources folders that can be used by users at runtime (they will be default prefabs/models available for all). They can be spawned, scaled, their material and texture can be changed. They can also be saved, loaded and deleted. All is done in my app and works great. Now, I need users to be able to increase the collections of the models/prefabs at runtime. I need to allow my clients to import stuff like meshes, textures, etc. and then let them do things like in the Unity Editor. For example, a user import his custom mesh into my app, texture it and do other things and makes a prefab. Then, the prefab is placed in a Resources folder and is available for him in game if he wants to use it.
I have just seen some videos about Editor Scripting. Alas, that cool stuff works only in Editor namespace, not in builds My idea is to get some functions that are in the Editor in builds. My question is why so powerful functions available in the Editor on now cannot be available in build either. For example, this video:
teaches Unity users how to use the Editor scripting. Why aren’t those things available in builds? I know that it can be dangerous because we can give too much power to users, but I think a developer should have a possibility to limit the features that are available for users. A develop can decided what will be exposed to a user and what not.
In short, I need the Editor stuff in builds. At least, some features.
I can import meshes, textures, movies, etc. No problem. The problem is that I need a user to have a possibility to place this mesh (imported by a user.) as a prefab in a Resources folder to be available in the menu for spawning in the scene. Users can spawn the default prefabs that will be in-built as I said before (a default collection of objects prepared by me) and I wish users be able to add their own object (prefabs) to the default collection. And the added objects must be available for using like the default ones. No difference. The problem is that the prefab is the Editor stuff. So users are unable to create a prefab from an imported model/mesh at runtime. This is the problem. It is not a game, but a tool. There are many good things but they are available only in the Editor. Why not in builds? Unity would be a very flexible platform.
I though about using UE4 for that because the source code is available but UE4 is more complex and we have no time to lose.
So you won’t create a competitor to Unreal Engine.
Allowing editor tools at runtime would allow you to easily make a runtime editor and distribute it to an unlimited number of people who will not be subject to unreal eula. Meaning they will be legally allowed to make games with your tool without paying a thing to epic games.
I think it should be possible to prototype basic prefab-like system in a week or less. It’ll have to be a custom solution, though. Roll out your custom format, scan local folders for user data present, etc. It is not difficult.
Preventing someone from hijacking tools and creating competitor (UNreal)
Portability/Simplicity (Unity). Some platforms may not even HAVE user-writeable folders. Meaning the easiest way to make prefabs is make assets frozen and non-editable at runtime. It is also not a common scenario. If you’re working only on PC and want runtime prefabs, you have an edge case scenario, not a common one.
Also, please note that rather than “users making cool stuff” a company would be interested in “features that make engine more profitable”. Runtime prefabs are edge case and most games don’t need them. So, it’ll be a low priority request.
Ok, it makes sense. However, they should avoid that in another way. Now, it is just a limiting developers.
I can write a similar system too. I thought it would be possible to do that with Unity. But of course, if there’s no other solutions, a custom prefab system should be created.
Another thing, creating prefabs at runtime/build was not the only question. I wished to know about the possibility including other Editor things in builds. Now, I see it is impossible.
Like above. I can add that there should be more flexibility. Now, a game is a something more than a game in the 90s. End user interactivity seems a very important feature.
It is not my duty. Other people take care of that. Yes, in games, nobody needs that, but I repeat: it is not a game within the meaning of what most people think.
This topic was started to get any info about that because there was a possibility that I missed something. But, I see that the only solution is asset bundles.
I suggest to file a feature request. Either via forums (I think you can edit the thread title), either via unity feedback system. Also, I suspect there might’ve been something related on asset store already.
Thank you! I did a feature request a few days ago. I haven’t found anything on the Asset Store.
I’m going to create my own prefab system. In this way, I will be independent from Unity decisions. I created my own animation system in the project for recording and playing animations. Users can edit animations too. The same will be with my own prefab system. Much work, but there are some advantages.
You don’t need prefabs. Make a game object, add scripts, components(mesh filter, colliders, etc), create other game objects for the children you need, parent them, set their local positions, etc, etc. It’s trivial and needing to use prefabs instead of knowing how yo do that isn’t good for you as a programmer.
Well, you don’t know all the project and the functions. Using prefabs has some advantages. My question: Why do you use prefabs instead of just objects? In my project, I have selecting, parenting and other stuff needed for a true level editor, but for now only for the in-built prefabs I keep in Resource folders. Every object will have many sub-objects, dynamic content, notes and all other stuff. It can be shared, changed, sent via network among people, etc. Really, I cannot imagine do that without prefab system. It must be easy and handy for the end users.