Hi, my last problem is this one : I've got an file (a prefab) and I want edit some variable in it. I want modify the ScaleInLightmap property and StaticEditorFlags property. I want modify the gameObject.isStatic to allow me bake lightmap in a custom editor window. The steps are : - Load assets in my scene dynamically. CHECK - Define if they need GenerateUVLightmap. CHECK - Pass them to static. Maybe but don't know - Define their new ScaleInLightmap. Don't work (SURE !) - Bake. CHECK (But with the bad scale all my work is screwed :/) - Move the lightmaps to a new folder. CHECK - Clean scene and reload it at its initial state. CHECK My tools is nearly over and after need to add the possibility to create your own baking scene and allow user to iterate automatically through all prefab he wants. But with the 2 buggy states left it's currently not possible. And this is what I do for those 2 fail steps. Code (csharp): //Force all game object in our scene as static private void StaticAllTheScene() { //Iterate on all our gameobject in the scene and put them as static GameObject[] goList = new GameObject[GameObject.FindSceneObjectsOfType( typeof( GameObject )).Length]; //Take all gameobject type and put them in da list goList = (GameObject[])GameObject.FindSceneObjectsOfType( typeof( GameObject )); Debug.Log("Real start of static scale in lightmap..."); for( int i = 0 ; i < goList.Length ; i++ ) { //Put all gameObject static field to true foreach( Transform trans in goList[i].transform ) { Debug.Log("static before ? " + trans.gameObject.isStatic ); trans.gameObject.isStatic = true; Debug.Log("static after ? " + trans.gameObject.isStatic ); ScaleInLightmapAll( trans.gameObject ); } } Debug.Log("Static scale in lightmap over"); } //Modify all scale of our object to a new one private void ScaleInLightmapAll( GameObject go ) { //Check if he got a renderer if( go.renderer != null ) { //Serialized my object to allow to modify every property in it SerializedObject so = new SerializedObject ( go ); Debug.Log( "Scale value : " + m_nScaleInLightmap ); Debug.Log( "Scale value in current object : " + so.FindProperty( "m_ScaleInLightmap" ).floatValue ); //Find the property and modify them so.FindProperty( "m_StaticEditorFlags" ).boolValue = true; so.FindProperty( "m_ScaleInLightmap").floatValue = m_nScaleInLightmap; Debug.Log( "Scale value after : " + so.FindProperty( "m_ScaleInLightmap" ).floatValue ); That's it. If someone got a solution on this problem, this can be very very usefull for me And for this part of my script : Code (csharp): so.FindProperty( "m_StaticEditorFlags" ).boolValue = true; so.FindProperty( "m_ScaleInLightmap").floatValue = m_nScaleInLightmap; Must I iterate on all property fields ? Or it does it alone ? Thanks in advance for your help !
I finally find a solution to my problem and I share this with you if someone need it someday : Code (csharp): private void ScaleInLightmapAll( GameObject go ) { //Check if he got a renderer if( go.renderer != null ) { //Serialized my object to allow to modify every property in it SerializedObject so = new SerializedObject ( go.GetComponent<Renderer>() ); //Find the property and modify them so.FindProperty( "m_ScaleInLightmap").floatValue = m_nScaleInLightmap; Debug.Log( "Scale value after : " + so.FindProperty( "m_ScaleInLightmap" ).floatValue ); //Apply the modified properties Debug.Log( "succes ? " + so.ApplyModifiedProperties() ); //Send true but this is working ? oO } } For the iterate part, I don't know if it's needed for the moment, maybe someone can unconfirm or confirm that ? Thanks