public void DrawCustomInspector() { ZippyLights2D t = (ZippyLights2D)target; if (!Application.isPlaying) { if (GUILayout.Button("Update")) { t.ForceUpdate(); } } lab = new GUIStyle(); lab.richText = true; CheckIdle(t); CheckUnityLight(t); CheckResolution(t); }
public void DrawCustomInspector() { ZippyLights2D t = (ZippyLights2D)target; if (!Application.isPlaying) { if (GUILayout.Button("Update")) { t.ForceUpdate(); Debug.Log(t.GetComponent <MeshRenderer>().sortingLayerName); Debug.Log(t.GetComponent <MeshRenderer>().sortingOrder); } } lab = new GUIStyle(); lab.richText = true; CheckIdle(t); CheckUnityLight(t); CheckResolution(t); }
public void DrawCustomInspector() { serializedObject.Update(); ZippyLights2D t = (ZippyLights2D)target; if (t.hiddenChildren) { if (GUIButton("Show Child Objects")) { t.hiddenChildren = !t.hiddenChildren; t.HideChildren(); } } else { if (GUIButton("Hide Child Objects")) { t.hiddenChildren = !t.hiddenChildren; t.HideChildren(); } } GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Light", t.showLightSettings), EditorStyles.boldLabel)) { t.showLightSettings = !t.showLightSettings; } if (t.showLightSettings) { GUIBeginBox("", true, 2); EditorGUILayout.PropertyField(staticLight); EditorGUILayout.PropertyField(resolution); EditorGUILayout.PropertyField(degrees); EditorGUILayout.PropertyField(offset); EditorGUILayout.PropertyField(offsetSpherify); if (t.offset < 0 || t.offsetSpherify < 0) { EditorGUILayout.HelpBox("Negative offsets can cause bugs if light is too close to a collider.\nMake sure to create a buffer collider between the light and other colliders.", MessageType.Warning); } EditorGUILayout.PropertyField(moveToUpdate); EditorGUILayout.PropertyField(layers); EditorGUILayout.PropertyField(unityLight); EditorGUILayout.PropertyField(follow); EditorGUILayout.PropertyField(meshTransform); GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Duplicate Lights", t.showDuplicate), EditorStyles.boldLabel)) { t.showDuplicate = !t.showDuplicate; } if (t.showDuplicate) { GUIBeginBox("", true, 2); if (GUIButton("Create Dupe")) { GameObject go = new GameObject("LightMesh Dupe " + t.duplicatedLights.Count, typeof(MeshRenderer), typeof(MeshFilter)); Transform tr = go.transform; MeshRenderer parentMr = t.meshTransform.GetComponent <MeshRenderer>(); MeshFilter parentMf = t.meshTransform.GetComponent <MeshFilter>(); MeshFilter mf = tr.GetComponent <MeshFilter>(); MeshRenderer mr = tr.GetComponent <MeshRenderer>(); tr.parent = t.meshTransform; tr.localPosition = Vector3.zero; tr.localRotation = Quaternion.identity; mr.sharedMaterial = parentMr.sharedMaterial; mr.receiveShadows = false; mr.castShadows = false; EditorUtility.SetSelectedWireframeHidden(mr, true); mf.sharedMesh = parentMf.sharedMesh; t.duplicatedLights.Add(mf); } GUILayout.Space(2); if (t.duplicatedLights.Count == 0) { GUI.enabled = false; } if (GUIButton("Remove Dupe")) { DestroyImmediate(t.duplicatedLights[t.duplicatedLights.Count - 1].gameObject); t.duplicatedLights.RemoveAt(t.duplicatedLights.Count - 1); } //if (t.duplicatedLights.Count == 0) GUI.enabled = true; GUILayout.Space(2); EditorGUILayout.HelpBox("Duplicated lights can be rotated, moved or scaled after creation to create special effects.\nChanging to a different material can also improve the look and feel of the lights.", MessageType.Info); EditorGUILayout.PropertyField(duplicatedLights, true); GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Range", t.showRange), EditorStyles.boldLabel)) { t.showRange = !t.showRange; } if (t.showRange) { GUIBeginBox("", true, 2); EditorGUILayout.PropertyField(range); EditorGUILayout.PropertyField(animateRange); EditorGUILayout.PropertyField(rangeAnimation); EditorGUILayout.PropertyField(animateRangeSpeed); EditorGUILayout.PropertyField(animateRangeScale); GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Falloff", t.showFalloff), EditorStyles.boldLabel)) { t.showFalloff = !t.showFalloff; } if (t.showFalloff) { GUIBeginBox("", true, 2); EditorGUILayout.HelpBox("Experimental, can have bugs in mobile or other builds.", MessageType.Warning); EditorGUILayout.PropertyField(falloff); EditorGUILayout.PropertyField(falloffAfterglow); EditorGUILayout.PropertyField(falloffMobileFix); if (GUIButton("Mobile Mode Toggle (Fix)")) { t.ForceUpdate(); t.falloffMobileFix = !t.falloffMobileFix; } GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Color", t.showColor), EditorStyles.boldLabel)) { t.showColor = !t.showColor; } if (t.showColor) { GUIBeginBox("", true, 2); EditorGUILayout.PropertyField(enableVertexColors); EditorGUILayout.PropertyField(vertexFade); EditorGUILayout.PropertyField(vertexColor); EditorGUILayout.PropertyField(enableOuterColor); EditorGUILayout.PropertyField(vertexColorOuter); EditorGUILayout.PropertyField(ColorCycleEnabled); EditorGUILayout.PropertyField(ColorCycle); EditorGUILayout.PropertyField(ColorCycleSpeed); EditorGUILayout.PropertyField(ColorCycleOuterEnabled); EditorGUILayout.PropertyField(ColorCycleOuter); EditorGUILayout.PropertyField(ColorCycleSpeedOuter); GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("UV", t.showUV), EditorStyles.boldLabel)) { t.showUV = !t.showUV; } if (t.showUV) { GUIBeginBox("", true, 2); EditorGUILayout.PropertyField(CreateUV); EditorGUILayout.PropertyField(UVScale); GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Noise", t.showNoise), EditorStyles.boldLabel)) { t.showNoise = !t.showNoise; } if (t.showNoise) { GUIBeginBox("", true, 2); EditorGUILayout.PropertyField(noise); EditorGUILayout.PropertyField(noiseDelay); GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Sort", t.showSort), EditorStyles.boldLabel)) { t.showSort = !t.showSort; } if (t.showSort) { GUIBeginBox("", true, 2); EditorGUILayout.PropertyField(sortingOrder); EditorGUILayout.PropertyField(sortingLayer); GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Particles", t.showParticle), EditorStyles.boldLabel)) { t.showParticle = !t.showParticle; } if (t.showParticle) { GUIBeginBox("", true, 2); EditorGUILayout.PropertyField(particles); EditorGUILayout.PropertyField(particleEmitDelay); EditorGUILayout.PropertyField(particleRayAmount); EditorGUILayout.PropertyField(particleEmitAmount); EditorGUILayout.PropertyField(particleRangeLimitMin); EditorGUILayout.PropertyField(particleRangeLimitMax); GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Functions", t.showFunctions), EditorStyles.boldLabel)) { t.showFunctions = !t.showFunctions; } if (t.showFunctions) { GUIBeginBox("", true, 2); if (!Application.isPlaying) { if (GUIButton("Update")) { t.ForceUpdate(); //Debug.Log(t.GetComponent<MeshRenderer>().sortingLayerName); //Debug.Log(t.GetComponent<MeshRenderer>().sortingOrder); } GUILayout.Space(2); if (GUIButton("Force New Mesh")) { t.ForceNewMesh(); } GUILayout.Space(2); if (GUIButton("Create Material Instances\n(ignore error)")) { MeshRenderer r = t.GetComponent <MeshRenderer>(); for (int i = 0; i < r.materials.Length; i++) { r.materials[i] = new Material(r.materials[i]); } } } EditorGUILayout.HelpBox("Tip : Use [Unity Menu > GameObject > Break Prefab Instance] to improve performance in editor.\nApply changes to connect scene object to prefab again.\nTip2 : Improve inspector lag by copying Zippy Light component, removing it, then paste it back as new.", MessageType.Info); GUIEndBox(); } GUIEndBox(); CheckIdle(t); CheckUnityLight(t); CheckResolution(t); CheckTexture(t); if (GUI.changed) { EditorUtility.SetDirty(t); serializedObject.ApplyModifiedProperties(); } }
public void DrawCustomInspector() { ZippyLights2D t = (ZippyLights2D)target; GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Light", t.showLightSettings), EditorStyles.boldLabel)) { t.showLightSettings = !t.showLightSettings; } if (t.showLightSettings) { GUIBeginBox("", true, 2); EditorGUILayout.PropertyField(staticLight); EditorGUILayout.PropertyField(resolution); EditorGUILayout.PropertyField(degrees); EditorGUILayout.PropertyField(offset); EditorGUILayout.PropertyField(offsetSpherify); EditorGUILayout.PropertyField(moveToUpdate); EditorGUILayout.PropertyField(layers); EditorGUILayout.PropertyField(unityLight); EditorGUILayout.PropertyField(follow); GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Range", t.showRange), EditorStyles.boldLabel)) { t.showRange = !t.showRange; } if (t.showRange) { GUIBeginBox("", true, 2); EditorGUILayout.PropertyField(range); EditorGUILayout.PropertyField(animateRange); EditorGUILayout.PropertyField(rangeAnimation); EditorGUILayout.PropertyField(animateRangeSpeed); EditorGUILayout.PropertyField(animateRangeScale); GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Color", t.showColor), EditorStyles.boldLabel)) { t.showColor = !t.showColor; } if (t.showColor) { GUIBeginBox("", true, 2); EditorGUILayout.PropertyField(enableVertexColors); EditorGUILayout.PropertyField(vertexFade); EditorGUILayout.PropertyField(vertexColor); EditorGUILayout.PropertyField(enableOuterColor); EditorGUILayout.PropertyField(vertexColorOuter); EditorGUILayout.PropertyField(ColorCycleEnabled); EditorGUILayout.PropertyField(ColorCycle); EditorGUILayout.PropertyField(ColorCycleSpeed); EditorGUILayout.PropertyField(ColorCycleOuterEnabled); EditorGUILayout.PropertyField(ColorCycleOuter); EditorGUILayout.PropertyField(ColorCycleSpeedOuter); GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("UV", t.showUV), EditorStyles.boldLabel)) { t.showUV = !t.showUV; } if (t.showUV) { GUIBeginBox("", true, 2); EditorGUILayout.PropertyField(CreateUV); EditorGUILayout.PropertyField(UVScale); GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Noise", t.showNoise), EditorStyles.boldLabel)) { t.showNoise = !t.showNoise; } if (t.showNoise) { GUIBeginBox("", true, 2); EditorGUILayout.PropertyField(noise); EditorGUILayout.PropertyField(noiseDelay); GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Sort", t.showSort), EditorStyles.boldLabel)) { t.showSort = !t.showSort; } if (t.showSort) { GUIBeginBox("", true, 2); EditorGUILayout.PropertyField(sortingOrder); EditorGUILayout.PropertyField(sortingLayer); GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Particles", t.showParticle), EditorStyles.boldLabel)) { t.showParticle = !t.showParticle; } if (t.showParticle) { GUIBeginBox("", true, 2); EditorGUILayout.PropertyField(particles); EditorGUILayout.PropertyField(particleEmitDelay); EditorGUILayout.PropertyField(particleRayAmount); EditorGUILayout.PropertyField(particleEmitAmount); EditorGUILayout.PropertyField(particleRangeLimitMin); EditorGUILayout.PropertyField(particleRangeLimitMax); GUIEndBox(); } GUIEndBox(); GUIBeginBox(); if (GUILayout.Button(GUIButtoneText("Functions", t.showFunctions), EditorStyles.boldLabel)) { t.showFunctions = !t.showFunctions; } if (t.showFunctions) { GUIBeginBox("", true, 2); if (!Application.isPlaying) { if (GUIButton("Update")) { t.ForceUpdate(); //Debug.Log(t.GetComponent<MeshRenderer>().sortingLayerName); //Debug.Log(t.GetComponent<MeshRenderer>().sortingOrder); } GUILayout.Space(2); if (GUIButton("Force New Mesh")) { t.ForceNewMesh(); } GUILayout.Space(2); if (GUIButton("Create Material Instances\n(ignore error)")) { MeshRenderer r = t.GetComponent <MeshRenderer>(); for (int i = 0; i < r.materials.Length; i++) { r.materials[i] = new Material(r.materials[i]); } } } EditorGUILayout.HelpBox("Tip : Use [Unity Menu > GameObject > Break Prefab Instance] to improve performance in editor.\nApply changes to connect scene object to prefab again.\n(For reasons unknown, Unity behaves this way)", MessageType.Info); GUIEndBox(); } GUIEndBox(); CheckIdle(t); CheckUnityLight(t); CheckResolution(t); CheckTexture(t); if (GUI.changed) { EditorUtility.SetDirty(t); serializedObject.ApplyModifiedProperties(); } }