Skip to content

Commit 0985554

Browse files
authored
Feature/task 823 box light improvement (#85)
* Deal with the situation plural GameObjects are selected [skip ci] * Improved menu to handle plural gameObjects. * Updated CHANGELOG.md
1 parent e99e470 commit 0985554

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

com.unity.toonshader/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Changelog
22
## [0.4.1-preview] - 2021-10-27
33
### Added
4-
* Something similar to exposure compensation.
4+
* HDRP:Something similar to exposure compensation.
55
### Fixed:
66
* typo in documants.
77
* missing mono behaviors in sample scenes.

com.unity.toonshader/Editor/HDRP/BoxLightAdjustmentInspector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ float ConvertToEV100(float val)
140140
static void CreateBoxLight()
141141
{
142142

143-
var go = Selection.activeGameObject;
144-
var lightGo = BoxLightAdjustment.CreateBoxLight(go);
143+
144+
var lightGo = BoxLightAdjustment.CreateBoxLight(Selection.gameObjects);
145145

146146
}
147147

com.unity.toonshader/Runtime/HDRP/BoxLightAdjustment.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void Update()
108108

109109
for (int ii = 0; ii < m_Renderers.Length; ii++)
110110
{
111-
m_Renderers[ii].renderingLayerMask &= 0xff;
111+
m_Renderers[ii].renderingLayerMask &= 0xffffff00;
112112
m_Renderers[ii].renderingLayerMask |= (uint)m_targetBoxLight.lightlayersMask;
113113
}
114114
if ( /* m_targetBoxLight != null && */ m_GameObjects != null && m_GameObjects.Length > 0 && m_GameObjects[0] != null )
@@ -163,17 +163,17 @@ void UpdateObjectLightLayers()
163163

164164
}
165165

166-
internal static GameObject CreateBoxLight(GameObject go)
166+
internal static GameObject CreateBoxLight(GameObject[] gameObjects)
167167
{
168-
if (go == null)
168+
if (gameObjects == null || gameObjects[0] == null )
169169
{
170170
Debug.LogError("Please, select a GameObject you want a Box Light to follow.");
171171
return null;
172172
}
173-
var gameObjectName = "Box Light for " + go.name;
173+
var gameObjectName = "Box Light for " + gameObjects[0].name;
174174
GameObject lightGameObject = new GameObject(gameObjectName);
175175
#if UNITY_EDITOR
176-
Undo.RegisterCreatedObjectUndo(lightGameObject, "Created " + go.name);
176+
Undo.RegisterCreatedObjectUndo(lightGameObject, "Created Boxlight adjustment");
177177
#endif
178178
HDAdditionalLightData hdLightData = lightGameObject.AddHDLight(HDLightTypeAndShape.BoxSpot);
179179
// light size
@@ -210,8 +210,8 @@ internal static GameObject CreateBoxLight(GameObject go)
210210
hdLightData.gameObject.transform.rotation = goRot;
211211

212212
// must be put to gameObject model chain.
213-
boxLightAdjustment.m_GameObjects = new GameObject[1];
214-
boxLightAdjustment.m_GameObjects[0] = go;
213+
boxLightAdjustment.m_GameObjects = gameObjects;
214+
215215

216216
return lightGameObject;
217217
}

0 commit comments

Comments
 (0)