Static Enforcer For Unity

by showcase-tv

Unity3D component to propagate static flag to child nodes (GameObjects) of re-imported model. It is useful because Unity3D does not automatically set static flag for newly created child nodes inside re-imported model.

( Crawled 35 minutes ago )


This is a Unity3D component to propagate static flag from root game object to child objects on re-import. So that, you can safely edit 3D model files and re-import without collapsing conditions to do GI lightmap correctly.


I'm using GI lightmapping (enlighten) with SketchUp models and I frequently met the problem that some of the inner game objects doesn't lit correctly, because these objects does't have static flag on, while the root model object have the static flag. It becomes very cumbersome when I edit the model again and again. \ This StaticEnforcer component solves that problem.

Otherwise, you need to ensure static flag almost everytime you edited and re-imported a model. Which is not that a human must do.



  1. Assume you have sample-model.skp (SketchUp 2015 format) in your Unity project somewhere under Assets/.
  2. Unity will automatically import sample-model.skp and generate "sample-model" prefab.
  3. Place that "sample-model" prefab to a scene.
  4. Set static flag to the placed "sample-model" to make GI lightmap for that model.

Add StaticEnforcer

  1. add StaticEnforcer scripts to your project

  2. Add "Static Enforcer" component to the places "sample-model" with "Add Component" button on the inspector.

Then what happens?

If you modify sample-model.skp with SketchUp and especially add some "group"s, Unity3D will re-import the model, and generate some GameObjects each for the new groups. The generated GameObjects usually doesn't have static flag, but with Static Enforcer component attached, they will have static flag on.

Condition to work

The game object which the StaticEnforcer attached must be an root instance of a prefab, imported from a 3D model file.


Q. What if the root model doesn't have static flag on?

A. the StaticEnforcer will do nothing on re-import if the root object is not static, and the behavior is the same as Unity3D default.

in Japanese

SketchUpファイルのような3DモデルファイルをUnityプロジェクトに読み込んでいる場合で、SketchUp側で後から修正してモデル内にグループを追加した場合など、モデル内部のGameObjectにstaticフラグがつかないケースがあり、いつのまにかGIの影がきちんとつかなくなる、という現象を防止するものです。 \ 使い方としては、3DモデルファイルをインポートしてSceneに配置したオブジェクトに対して、Add Component で "Static Enforcer" を追加すると利用することができます。3Dモデルファイルを修正して再importしたときに働きます。