- Home /
How to set up LODs for a Asset Store pack in Unity Indie?
I'm not making a game I'm selling models on the asset store. I plan to get Unity pro but can not afford it now.
I know I can't fully configure an LOD prefab in the free version but is there a way to set the prefabs or imports up so Unity pro will set it up?
Thanks
I'd say the miss-directing title on your question lead to the bad unrelated question... And I guess there is no way to do what you want without Unity Pro.
Answer by cregox · Dec 10, 2013 at 01:48 PM
@TonyLi gave good suggestions, but here's the technical aspect of what you want to do. Quoting from http://docs.unity3d.com/Documentation/Manual/LevelOfDetail.html :
LOD-based naming conventions in the asset import pipeline In order to simplify setup of LODs, Unity has a naming convention for models that are being imported.
Simply create your meshes in your modelling tool with names ending with _LOD0, _LOD1, _LOD2, etc., and the LOD group with appropriate settings will be created for you.
Note that the convention assumes that the LOD 0 is the highest resolution model.
This should mean you can just set the naming convention and it will automatically pick up. I couldn't make it work in practice, but it should work eventually. And, even if it doesn't work, it's just drag n' drop the prefab into the lod group, quite easy.
Also, since your title is still confusing, I'll answer it separately as well, just like @inkspot did, but with code from the wiki:
/*
Automatically set LOD Levels of models
(C)2010 by Tom Vogt
Use and modify as you wish, but retain author credits (aka BSD license)
== Usage ==
* Create an empty gameobject
* Drag all LOD levels into it, so they become children of the LOD object
* Attach this script to the empty gameobject
* Set the number of meshes in the script, and drag them into the slots, from highest (closest) to lowest (far away)
* Set the number of distances to '''one less''' than the number of meshes (beyond the highest distance will use the most far away mesh automatically)
* Set the distances at which the script shall switch to the next lowest LOD. So the first number means "at this distance or less, use the highest LOD".
* Press Play and drag the camera around to check if your distances are fine.
*/
public var Distances : float[];
public var Models : GameObject[];
private var current = -2;
function Start() {
for (var i=0; i<Models.Length; i++) {
Models[i].SetActiveRecursively(false);
}
}
function Update() {
var d = Vector3.Distance(camera.main.transform.position, transform.position);
var stage = -1;
for (var i=0; i<Distances.Length; i++) {
if (d<Distances[i]) {
stage=i;
i=Distances.Length;
}
}
if (stage==-1) stage=Distances.Length;
if (current!=stage) {
SetLOD(stage);
}
}
function SetLOD(stage) {
Models[stage].SetActiveRecursively(true);
if (current>=0) Models[current].SetActiveRecursively(false);
current = stage;
}
It is a nice script. Stinks that it does not worked in the editor view. Side by side game and editor view works good though. Thanks for the link.
Could I use this script in my pack? Would I just leave credit and info in the readme to give credit to $$anonymous$$ Vogt in there project?
Answer by TonyLi · Dec 09, 2013 at 05:12 PM
Since you're just making models to distribute on the Asset Store, here are a couple suggestions:
Include the LOD meshes in the model but don't provide a prefab. Let the customer use Unity Pro to add an LODGroup and assign the meshes as appropriate. Make sure to name the meshes so it's obvious which LOD group they belong to. It's not that much extra effort for the customer.
Wait until all your models are ready, and then set up the prefabs in the trial version of Pro. I'm not sure if this is legit, but it may be allowable since you're just setting up the prefabs for the convenience of Pro users, not using Pro yourself per se. You might want to check with the Asset Store folks before trying this.
Thanks for the answer TonyLi. What I've been doing is importing the LOD1 and LOD2 models and putting them in a folder under the normal models. For the textures, materials, and prefabs I do the same thing. Each LOD model has its own texture, material, and prefab. So the buyer, who has Unity Pro, can just drag the normal prefab and then the LOD prefab.
The LOD system is just drag and drop prefab right?
If I can start making some money I will get Unity Pro and set up the LODs. I will then include the LOD prefabs in an update.
Do you think that sounds logical? Sounds complicated to me but I do not really have a choice. Really wish the LOD system was in free. I already did the trial with Unity 4. Wasted it because I really wasn't into Unity then.
Thanks again for the answer.
Answer by inkspot · Jul 19, 2013 at 04:50 PM
You could use the camera to get and detect the distance away from the prefab and use like thresholds to load the LOD mesh on your prefab: LOD1 loads when 50units away from camera, LOD2 loads when 100 units away from camera etc.
Yeah I know but I'm not a programmer and don't plan on selling the package with any scripts. Just want it to be set up to use the Unity LOD system.
Your answer
Follow this Question
Related Questions
Refund Fake Package 1 Answer
Asset Store Tools upload? 0 Answers
Importing assets breaks my game 1 Answer
asset store download blank 1 Answer
How to add and remove installed packages more easily? E.g. Google Admob. Package control in Unity? 0 Answers