public override void OnInspectorGUI() { if (light == null) { return; } initStyles(); EditorGUI.BeginChangeCheck(); { float fRange = range.floatValue; if (fRange > 360.001f) { fRange = 360f; } if (fRange < .999f) { fRange = 1f; } //Debug.Log(fRange - Mathf.FloorToInt(fRange)); if (Mathf.Abs(fRange - Mathf.FloorToInt(fRange)) > 0.5f) { fRange = Mathf.Round(fRange); range.floatValue = fRange; } if (range.floatValue != fRange) { range.floatValue = fRange; } float fradius = radius.floatValue; if (fradius < 0) { fradius *= -1; } if (radius.floatValue != fradius) { radius.floatValue = fradius; } string v = version.stringValue; EditorGUILayout.Separator(); GUILayout.Label("2DDL Pro", titleStyle); //GUILayout.Label("----------------"); EditorGUILayout.Separator(); GUILayout.Label("Main Prefs", subTitleStyle); if (fRange < 360f) { if (segments.intValue < 5) { segments.intValue = 5; } EditorGUILayout.IntSlider(segments, 5, 20, new GUIContent("Segments", "Quantity of line segments is used for build mesh render of 2DLight. 5 at least in spot Lights")); } else { EditorGUILayout.IntSlider(segments, 3, 20, new GUIContent("Segments", "Quantity of line segments is used for build mesh render of 2DLight. 3 at least")); } EditorGUILayout.PropertyField(radius, new GUIContent("Radius", "Size of light radius")); EditorGUILayout.PropertyField(range, new GUIContent("Field Range", "from 0 to 360 degrees. Change the light mesh from point to angular light")); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(lmaterial, new GUIContent("Light Material", "Material Object used for render into light mesh")); EditorGUILayout.PropertyField(lUseSolidColor, new GUIContent("Is Solid Color", "if TRUE, render properly texturized or vertex color lights, if is FALSE, allow work with procedural gradient shaders.")); if (lUseSolidColor.boolValue == true) { EditorGUILayout.PropertyField(lColor, new GUIContent("Light Color", "Only can be used with Is Solid Color check to TRUE")); } EditorGUILayout.PropertyField(strokeRender, new GUIContent("Stroke Render", "Stroke revealed when render as stencil shader (Only Applied on Stencil shaders)")); EditorGUILayout.Separator(); GUILayout.Label("Layer", subTitleStyle); EditorGUILayout.PropertyField(layerm, new GUIContent("Layer", "Current layer where raycast is working. Must be the same layer for the colliders that will need interact with this 2dlight object")); EditorGUILayout.Separator(); //EditorGUILayout.HelpBox("Events", MessageType.None); GUILayout.Label("Events", subTitleStyle); EditorGUILayout.PropertyField(useEvents, new GUIContent("Use Events", "Enable events when light touch casters")); EditorGUILayout.Separator(); GUILayout.Label("Optimizations", subTitleStyle); //EditorGUILayout.HelpBox("Optimizations", MessageType.None); //EditorGUILayout.PropertyField(lightMode); EditorGUILayout.PropertyField(intelliderConvex, new GUIContent("Use Intellider Convex", "Forces 2Dlight to work with only 2 vertices per collider in scene")); EditorGUILayout.PropertyField(staticScene, new GUIContent("Static Scene", "If is TRUE, ignore any caster created after start scene, this means that you need preload all caster before run the app")); EditorGUILayout.Separator(); GUILayout.Label("Rendering and Debug Options", subTitleStyle); //EditorGUILayout.HelpBox("Rendering and Debug Options", MessageType.None); //EditorGUILayout.PropertyField(sortOrder); EditorGUILayout.PropertyField(recalcNorms); EditorGUILayout.PropertyField(debugLines); EditorGUILayout.Separator(); if (GUILayout.Button("Refresh")) { //light.Rebuild(); refreshLightObject(); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); GUILayout.Label("Info", subTitleStyle); EditorGUILayout.HelpBox("2DDL PRO version: " + v, MessageType.None); EditorGUILayout.Separator(); if (GUILayout.Button("Settings")) { SettingsWindow.Init(); } if (GUILayout.Button("About")) { DynamicLightAboutWindow.Init(); } EditorGUILayout.Separator(); if (GUILayout.Button("Support")) { Application.OpenURL("mailto:[email protected]"); } } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(target); applyChanges(); } }
public override void OnInspectorGUI() { if (light == null) { return; } serializedObject.Update(); initStyles(); GUILayoutOption miniButtonWidth = GUILayout.Width(60f); float fRange = range.floatValue; if (fRange > 360.001f) { fRange = 360f; } if (fRange < .999f) { fRange = 1f; } //Debug.Log(fRange - Mathf.FloorToInt(fRange)); if (Mathf.Abs(fRange - Mathf.FloorToInt(fRange)) > 0.5f) { fRange = Mathf.Round(fRange); range.floatValue = fRange; } if (range.floatValue != fRange) { range.floatValue = fRange; } float fradius = radius.floatValue; if (fradius < 0) { fradius *= -1; } if (radius.floatValue != fradius) { radius.floatValue = fradius; } string v = version.stringValue; EditorGUILayout.Separator(); EditorGUILayout.BeginVertical("Window"); EditorGUILayout.BeginHorizontal("Box"); GUILayoutOption[] reBtnStyle = { GUILayout.Width(35f), GUILayout.Height(35f) }; //Reload btn if (GUILayout.Button(AssetDatabase.LoadAssetAtPath(EditorUtils.getMainRelativepath() + "2DLight/Misc/reload-w.png", typeof(Texture2D)) as Texture2D, reBtnStyle)) { refreshLightObject(); } GUILayout.Label("2D Light Object", titleStyle); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); /* http://answers.unity3d.com/questions/465983/where-is-the-box-part-of-editorguilayoutbeginverti.html * * //Auto fit styles: * EditorGUILayout.BeginVertical("Box"); * EditorGUILayout.BeginVertical("Button"); * EditorGUILayout.BeginVertical("TextArea"); * EditorGUILayout.BeginVertical("Window"); * EditorGUILayout.BeginVertical("Textfield"); * EditorGUILayout.BeginVertical("HorizontalScrollbar"); //Fixed height * EditorGUILayout.BeginVertical("Label"); //No style * EditorGUILayout.BeginVertical("Toggle"); //Just puts a non usable CB to the left * EditorGUILayout.BeginVertical("Toolbar"); //Fixed height */ EditorGUILayout.Separator(); EditorGUILayout.BeginVertical("Box"); if (fRange < 360f) { if (segments.intValue < 5) { segments.intValue = 5; } EditorGUILayout.IntSlider(segments, 5, 20, new GUIContent("Segments", "Quantity of line segments is used for build mesh render of 2DLight. 5 at least in spot Lights")); } else { EditorGUILayout.IntSlider(segments, 3, 20, new GUIContent("Segments", "Quantity of line segments is used for build mesh render of 2DLight. 3 at least")); } EditorGUILayout.PropertyField(radius, new GUIContent("Radius")); EditorGUILayout.PropertyField(range, new GUIContent("Angle")); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(layerm, new GUIContent("Layer", "Current layer where light is working. Must be the same in the colliders")); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical("Box"); EditorGUILayout.LabelField("Material", EditorStyles.boldLabel); EditorGUILayout.BeginVertical("Box"); EditorGUILayout.PropertyField(lmaterial, new GUIContent("Light Material", "Material Object used for render into light mesh")); EditorGUILayout.PropertyField(lUseSolidColor, new GUIContent("Is Solid Color", "if TRUE, render properly texturized or vertex color lights, if is FALSE, allow work with procedural gradient shaders.")); if (lUseSolidColor.boolValue == true) { EditorGUILayout.PropertyField(lColor, new GUIContent("Light Color", "Only can be used with Is Solid Color check to TRUE")); } EditorGUILayout.PropertyField(strokeRender, new GUIContent("Offset Render", "Is the offset between vertices and the mesh of light. (Mostly Applicable on Stencil shaders)")); EditorGUILayout.EndVertical(); GUILayout.Space(20); EditorGUILayout.LabelField("Tessellation", EditorStyles.boldLabel); EditorGUILayout.BeginVertical("Box"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.PropertyField(uv_offset, new GUIContent("UV Offset", "")); EditorGUILayout.PropertyField(uv_scale, new GUIContent("UV Scale", "")); EditorGUILayout.EndVertical(); if (GUILayout.Button("restore", EditorStyles.miniButton, miniButtonWidth)) { uv_offset.vector2Value = new Vector2(.5f, .5f); uv_scale.vector2Value = new Vector2(.5f, .5f); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); //EditorGUILayout.HelpBox("Events", MessageType.None); //GUILayout.Label("--- Events ---", subTitleStyle); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical("Box"); useEvents.boolValue = EditorGUILayout.BeginToggleGroup("Events", useEvents.boolValue); EditorGUI.indentLevel++; //EditorGUILayout.PropertyField(useEvents, new GUIContent("--- Events ---", "Enable events when light touch casters")); //if(useEvents.boolValue == true){ //EditorGUILayout.PropertyField(usePersistFOV, new GUIContent("Persistent", "Enable 'OnInside' list. Do a persistent checking when caster is within sight of current 2DLight")); EditorGUILayout.PropertyField(DDLEvent_OnEnterFOV, new GUIContent("OnEnter", "List of callback functions called when caster stay in sight of current light")); EditorGUILayout.PropertyField(DDLEvent_OnExitFOV, new GUIContent("OnExit", "List of callback functions when caster just exit from sight of current light")); EditorGUILayout.Separator(); EditorGUILayout.Separator(); if (usePersistFOV.boolValue == true) { //EditorGUILayout.PropertyField(DDLEvent_InsideFOV, new GUIContent("OnInside", "List of callback functions when caster just exit from sight of current light")); //EditorGUILayout.Separator(); } usePersistFOV.boolValue = EditorGUILayout.BeginToggleGroup("Persistent", usePersistFOV.boolValue); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(DDLEvent_InsideFOV, new GUIContent("OnInside", "List of callback functions when caster just exit from sight of current light")); EditorGUI.indentLevel--; EditorGUILayout.EndToggleGroup(); EditorGUI.indentLevel--; EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); GUILayout.Space(20); EditorGUILayout.BeginVertical("Box"); GUILayout.Label("Optimizations", subTitleStyle); EditorGUILayout.BeginVertical("Box"); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(staticScene, new GUIContent("Static Scene", "Ignore any caster created after start scene, this means that you need preload all caster before run the app")); EditorGUILayout.PropertyField(intelliderConvex, new GUIContent("Ignore middle vertices", "Forces 2Dlight to ignore middle vertices per collider when is building the final mesh")); EditorGUI.indentLevel--; EditorGUILayout.EndVertical(); GUILayout.Space(20); GUILayout.Label("Rendering and Debug Options", subTitleStyle); EditorGUILayout.BeginVertical("Box"); EditorGUI.indentLevel++; recalcNorms.boolValue = EditorGUILayout.Toggle("Recalculate normals?", recalcNorms.boolValue); EditorGUILayout.PropertyField(debugLines); EditorGUI.indentLevel--; EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); // -------------- REFRESH BUTTON ---------------------------------- /* * GUILayout.Space(30); * GUILayout.BeginVertical(); * GUILayout.BeginHorizontal(); * GUILayout.FlexibleSpace(); * * GUILayoutOption[] thiButton ={GUILayout.Width(240f), GUILayout.Height(80)}; * if (GUILayout.Button("Refresh", thiButton)){ * //light.Rebuild(); * refreshLightObject(); * } * GUILayout.FlexibleSpace(); * GUILayout.EndHorizontal(); * GUILayout.EndVertical(); */ // -------------- REFRESH BUTTON ---------------------------------- GUILayout.Space(30); GUILayout.Label("Info", subTitleStyle); EditorGUILayout.HelpBox("2DDL PRO version: " + v, MessageType.Info, true); EditorGUILayout.Separator(); // -------------- MINI TOOLBAR BUTTONS (settings-about-support) ---------------------------------- GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); //EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Settings", EditorStyles.miniButtonLeft, miniButtonWidth)) { SettingsWindow.Init(); } GUILayout.Space(2); if (GUILayout.Button("Doc", EditorStyles.miniButtonMid, miniButtonWidth)) { Application.OpenURL("http://martinysa.com/2d-dynamic-lights-doc/"); } GUILayout.Space(2); if (GUILayout.Button("About", EditorStyles.miniButtonMid, miniButtonWidth)) { DynamicLightAboutWindow.Init(); } GUILayout.Space(2); if (GUILayout.Button("Support", EditorStyles.miniButtonRight, miniButtonWidth)) { Application.OpenURL("mailto:[email protected]"); } //EditorGUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(50); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { if (light == null) { return; } initStyles(); EditorGUI.BeginChangeCheck(); float fRange = range.floatValue; if (fRange > 360.001f) { fRange = 360f; } if (fRange < .999f) { fRange = 1f; } //Debug.Log(fRange - Mathf.FloorToInt(fRange)); if (Mathf.Abs(fRange - Mathf.FloorToInt(fRange)) > 0.5f) { fRange = Mathf.Round(fRange); range.floatValue = fRange; } if (range.floatValue != fRange) { range.floatValue = fRange; } float fradius = radius.floatValue; if (fradius < 0) { fradius *= -1; } if (radius.floatValue != fradius) { radius.floatValue = fradius; } string v = version.stringValue; EditorGUILayout.Separator(); GUILayout.Label("------ 2D Light Object ------", titleStyle); //GUILayout.Label("----------------"); EditorGUILayout.Separator(); //GUILayout.Label("Main Prefs", subTitleStyle); if (fRange < 360f) { if (segments.intValue < 5) { segments.intValue = 5; } EditorGUILayout.IntSlider(segments, 5, 360, new GUIContent("Segments", "Quantity of line segments is used for build mesh render of 2DLight. 5 at least in spot Lights")); } else { EditorGUILayout.IntSlider(segments, 3, 360, new GUIContent("Segments", "Quantity of line segments is used for build mesh render of 2DLight. 3 at least")); } EditorGUILayout.PropertyField(radius, new GUIContent("Radius", "Radius Size of current light ")); EditorGUILayout.PropertyField(range, new GUIContent("Angular Range", "from 0 to 360 degrees. Define the light amplitude in degrees")); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(lmaterial, new GUIContent("Light Material", "Material Object used for render into light mesh")); EditorGUILayout.PropertyField(lUseSolidColor, new GUIContent("Is Solid Color", "if TRUE, render properly texturized or vertex color lights, if is FALSE, allow work with procedural gradient shaders.")); if (lUseSolidColor.boolValue == true) { EditorGUILayout.PropertyField(lColor, new GUIContent("Light Color", "Only can be used with Is Solid Color check to TRUE")); } EditorGUILayout.PropertyField(strokeRender, new GUIContent("Offset Render", "Is the offset between vertices and the mesh of light. (Mostly Applicable on Stencil shaders)")); EditorGUILayout.Separator(); EditorGUILayout.Separator(); //GUILayout.Label("--- Layer ---", subTitleStyle); EditorGUILayout.PropertyField(layerm, new GUIContent("--- Layer ---", "Current layer where light is working. Must be the same in the colliders")); //EditorGUILayout.HelpBox("Events", MessageType.None); //GUILayout.Label("--- Events ---", subTitleStyle); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(useEvents, new GUIContent("--- Events ---", "Enable events when light touch casters")); if (useEvents.boolValue == true) { EditorGUILayout.PropertyField(usePersistFOV, new GUIContent("Persistent", "Enable 'OnInside' list. Do a persistent checking when caster is within sight of current 2DLight")); EditorGUILayout.PropertyField(DDLEvent_OnEnterFOV, new GUIContent("OnEnter", "List of callback functions called when caster stay in sight of current light")); EditorGUILayout.PropertyField(DDLEvent_OnExitFOV, new GUIContent("OnExit", "List of callback functions when caster just exit from sight of current light")); EditorGUILayout.Separator(); EditorGUILayout.Separator(); if (usePersistFOV.boolValue == true) { EditorGUILayout.PropertyField(DDLEvent_InsideFOV, new GUIContent("OnInside", "List of callback functions when caster just exit from sight of current light")); EditorGUILayout.Separator(); } } //EditorGUILayout.Separator(); GUILayout.Label("--- Optimizations ---", subTitleStyle); //EditorGUILayout.HelpBox("Optimizations", MessageType.None); //EditorGUILayout.PropertyField(lightMode); EditorGUILayout.PropertyField(staticScene, new GUIContent("Static Scene", "Ignore any caster created after start scene, this means that you need preload all caster before run the app")); EditorGUILayout.PropertyField(intelliderConvex, new GUIContent("Ignore middle vertices", "Forces 2Dlight to ignore middle vertices per collider when is building the final mesh")); //EditorGUILayout.Separator(); GUILayout.Label("--- Rendering and Debug Options ---", subTitleStyle); //EditorGUILayout.HelpBox("Rendering and Debug Options", MessageType.None); //EditorGUILayout.PropertyField(sortOrder); EditorGUILayout.PropertyField(recalcNorms); EditorGUILayout.PropertyField(debugLines); EditorGUILayout.Separator(); if (GUILayout.Button("Refresh")) { //light.Rebuild(); refreshLightObject(); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); GUILayout.Label("Info", subTitleStyle); EditorGUILayout.HelpBox("2DDL PRO version: " + v, MessageType.None); EditorGUILayout.Separator(); if (GUILayout.Button("Settings")) { SettingsWindow.Init(); } if (GUILayout.Button("About")) { DynamicLightAboutWindow.Init(); } EditorGUILayout.Separator(); if (GUILayout.Button("Support")) { Application.OpenURL("mailto:[email protected]"); } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(target); applyChanges(); serializedObject.ApplyModifiedProperties(); } }