From Unify Community Wiki
Jump to: navigation, search

Note that if(includeChildren != false || excludePrefabs != false) is the same as the more readable if(includeChildren || excludePrefabs) In general, comparing boolean variables to true and false should not be necessary, as the result from a comparison is in it self a boolean. I.e. aVariable == true and aVariable != false become simlpy aVariable. Likewise aVariable != true and aVariable == false become !aVariable. That's much nicer in my opinion. --KeliHlodversson 09:39, 11 December 2006 (GMT)

Btw. What's the difference between ticking includeChildren and excludePrefabs? The code seems to do the same if either is set. --KeliHlodversson 09:44, 11 December 2006 (GMT)

You're right, I updated the boolean line. It is the (embarrassing) result of this being my first editor script and as you can see, I'm learning .js and C# too. And on second look (i wrote this a few weeks ago) it looks like there is no difference between selecting the two. How would it be written if either option were independent? (oh the power of wiki!) --Casemon

If I understand correctly, then something like this maybe? <csharp> modePrefs = SelectionMode.Editable; if(excludePrefabs)

       modePrefs |= SelectionMode.ExcludePrefab ;


       modePrefs |= SelectionMode.Deep;

</csharp> --KeliHlodversson 00:14, 12 December 2006 (GMT)

Ahh that's much nicer! However, it seems Exclude Prefabs doesn't work as expected. Or I don't understand how it is supposed to work! =) If ticked, material is changed regardless whether selection is an instanced prefab or just prefab or not a prefab. Expect that, if ticked, prefabs are excluded from selection (and thus not changed). Is that how it supposed to work? --Casemon

Personal tools