/// <summary> /// Registers the Aura Volume to the global manager /// </summary> /// <param name="auravolume">The Aura Volume to register</param> public void RegisterVolume(AuraVolume auraVolume) { if (!RegisteredVolumesList.Contains(auraVolume)) { RegisteredVolumesList.Add(auraVolume); if (auraVolume.useAsLightProbesProxyVolume) { RegisteredLightProbesProxyVolumesList.Add(auraVolume); } if (auraVolume.UsesTexture2DMasking) { Texture2DMasksAtlasComposer.AddTexture(auraVolume.texture2DMask.texture); Texture2DMasksAtlasComposer.Generate(); SetTexture2DMasksId(); } if (auraVolume.UsesTexture3DMasking) { Texture3DMasksAtlasComposer.AddTexture(auraVolume.texture3DMask.texture); Texture3DMasksAtlasComposer.Generate(); SetTexture3DMasksId(); } if (OnRegisterVolume != null) { OnRegisterVolume(auraVolume); } } auraVolume.OnUninitialize += AuraVolume_OnUninitialize; }
/// <summary> /// Sets the id of the AuraVolumes's Texture3D mask in the atlas /// </summary> private void SetTexture3DMaskId(AuraVolume auraVolume) { if (auraVolume.UsesTexture3DMasking) { auraVolume.texture3DMask.textureIndex = Texture3DMasksAtlasComposer.GetTextureIndex(auraVolume.texture3DMask.texture); } }
/// <summary> /// Function called when the volume is being disabled /// </summary> private void AuraVolume_OnUninitialize(AuraVolume auraVolume) { if (RegisteredVolumesList.Contains(auraVolume)) { if (RegisteredLightProbesProxyVolumesList.Contains(auraVolume)) { RegisteredLightProbesProxyVolumesList.Remove(auraVolume); } if (OnUnregisterVolume != null) { OnUnregisterVolume(auraVolume); } if (Texture2DMasksAtlasComposer.RemoveTexture(auraVolume.texture2DMask.texture)) { SetTexture2DMasksId(); Texture2DMasksAtlasComposer.Generate(); } if (Texture3DMasksAtlasComposer.RemoveTexture(auraVolume.texture3DMask.texture)) { SetTexture3DMasksId(); Texture3DMasksAtlasComposer.Generate(); } RegisteredVolumesList.Remove(auraVolume); } auraVolume.OnUninitialize -= AuraVolume_OnUninitialize; }
private void OnEnable() { _volumeShapeProperty = serializedObject.FindProperty("volumeShape.shape"); _falloffFadeProperty = serializedObject.FindProperty("volumeShape.fading.falloffExponent"); _xPositiveCubeFadeProperty = serializedObject.FindProperty("volumeShape.fading.xPositiveCubeFade"); _xNegativeCubeFadeProperty = serializedObject.FindProperty("volumeShape.fading.xNegativeCubeFade"); _yPositiveCubeFadeProperty = serializedObject.FindProperty("volumeShape.fading.yPositiveCubeFade"); _yNegativeCubeFadeProperty = serializedObject.FindProperty("volumeShape.fading.yNegativeCubeFade"); _zPositiveCubeFadeProperty = serializedObject.FindProperty("volumeShape.fading.zPositiveCubeFade"); _zNegativeCubeFadeProperty = serializedObject.FindProperty("volumeShape.fading.zNegativeCubeFade"); _angularConeFadeProperty = serializedObject.FindProperty("volumeShape.fading.angularConeFade"); _distanceConeFadeProperty = serializedObject.FindProperty("volumeShape.fading.distanceConeFade"); _widthCylinderFadeProperty = serializedObject.FindProperty("volumeShape.fading.widthCylinderFade"); _yNegativeCylinderFadeProperty = serializedObject.FindProperty("volumeShape.fading.yNegativeCylinderFade"); _yPositiveCylinderFadeProperty = serializedObject.FindProperty("volumeShape.fading.yPositiveCylinderFade"); _distanceSphereFadeProperty = serializedObject.FindProperty("volumeShape.fading.distanceSphereFade"); _useAsLightProbesProxyVolumeProperty = serializedObject.FindProperty("useAsLightProbesProxyVolume"); _lightProbesMultiplierProperty = serializedObject.FindProperty("lightProbesMultiplier"); _texture2DMaskBoolProperty = serializedObject.FindProperty("texture2DMask.enable"); _texture2DMaskTextureProperty = serializedObject.FindProperty("texture2DMask.texture"); _texture2DMaskTransformProperty = serializedObject.FindProperty("texture2DMask.transform"); _texture3DMaskBoolProperty = serializedObject.FindProperty("texture3DMask.enable"); _texture3DMaskTextureProperty = serializedObject.FindProperty("texture3DMask.texture"); _texture3DMaskTransformProperty = serializedObject.FindProperty("texture3DMask.transform"); _noiseMaskBoolProperty = serializedObject.FindProperty("noiseMask.enable"); _noiseMaskSpeedProperty = serializedObject.FindProperty("noiseMask.speed"); _noiseMaskTransformProperty = serializedObject.FindProperty("noiseMask.transform"); _densityInjectionTitleContent = new GUIContent("Density", Aura.ResourcesCollection.densityIconTexture); _densityInjectionBoolProperty = serializedObject.FindProperty("densityInjection.enable"); _densityInjectionParametersProperty = serializedObject.FindProperty("densityInjection"); _scatteringInjectionTitleContent = new GUIContent("Scattering", Aura.ResourcesCollection.scatteringIconTexture); _scatteringInjectionBoolProperty = serializedObject.FindProperty("scatteringInjection.enable"); _scatteringInjectionParametersProperty = serializedObject.FindProperty("scatteringInjection"); _lightInjectionTitleContent = new GUIContent("Light", Aura.ResourcesCollection.illuminationColorIconTexture); _lightInjectionBoolProperty = serializedObject.FindProperty("lightInjection.injectionParameters.enable"); _lightInjectionColorProperty = serializedObject.FindProperty("lightInjection.color"); _lightInjectionParametersProperty = serializedObject.FindProperty("lightInjection.injectionParameters"); _tintInjectionTitleContent = new GUIContent("Tint", Aura.ResourcesCollection.tintIconTexture); _tintInjectionBoolProperty = serializedObject.FindProperty("tintInjection.injectionParameters.enable"); _tintInjectionColorProperty = serializedObject.FindProperty("tintInjection.color"); _tintInjectionParametersProperty = serializedObject.FindProperty("tintInjection.injectionParameters"); _ambientInjectionTitleContent = new GUIContent("Ambient Lighting", Aura.ResourcesCollection.illuminationIconTexture); _ambientInjectionBoolProperty = serializedObject.FindProperty("ambientInjection.enable"); _ambientInjectionParametersProperty = serializedObject.FindProperty("ambientInjection"); _boostInjectionTitleContent = new GUIContent("Boost", Aura.ResourcesCollection.boostIconTexture); _boostInjectionBoolProperty = serializedObject.FindProperty("boostInjection.enable"); _boostInjectionParametersProperty = serializedObject.FindProperty("boostInjection"); _currentVolume = (AuraVolume)target; }
/// <summary> /// Applies the "Forest" preset /// </summary> public static void ApplyForestPreset() { AuraCamera[] auraCameras = Aura.AddAuraToCameras(1); for (int i = 0; i < auraCameras.Length; ++i) { auraCameras[i].frustumSettings.BaseSettings.useDensity = true; auraCameras[i].frustumSettings.BaseSettings.density = 0.3f; auraCameras[i].frustumSettings.BaseSettings.useScattering = true; auraCameras[i].frustumSettings.BaseSettings.scattering = 0.75f; auraCameras[i].frustumSettings.BaseSettings.useAmbientLighting = true; auraCameras[i].frustumSettings.BaseSettings.ambientLightingStrength = 1.0f; } RenderSettings.fog = false; RenderSettings.ambientMode = AmbientMode.Trilight; Color tmp; ColorUtility.TryParseHtmlString("#406381", out tmp); RenderSettings.ambientSkyColor = tmp; ColorUtility.TryParseHtmlString("#37402C", out tmp); RenderSettings.ambientEquatorColor = tmp; ColorUtility.TryParseHtmlString("#212420", out tmp); RenderSettings.ambientGroundColor = tmp; AuraLight[] directionalLights = Aura.AddAuraToDirectionalLights(1); for (int i = 0; i < directionalLights.Length; ++i) { Vector3 tmpRotation = directionalLights[i].transform.rotation.eulerAngles; tmpRotation.x = 50.0f; directionalLights[i].transform.rotation = Quaternion.Euler(tmpRotation); directionalLights[i].GetComponent <Light>().color = Color.HSVToRGB(0.12f, 0.35f, 1.0f); directionalLights[i].GetComponent <Light>().intensity = 1.0f; directionalLights[i].strength = 0.5f; directionalLights[i].enableOutOfPhaseColor = false; } DeletePresetVolumes(); AuraVolume globalVolume = AuraVolume.CreateGameObject(_presetVolumesName, VolumeType.Global).GetComponent <AuraVolume>(); globalVolume.noiseMask.enable = true; globalVolume.noiseMask.speed = 0.15f; globalVolume.noiseMask.transform.space = Space.World; globalVolume.noiseMask.transform.scale = Vector3.one * 3.0f; globalVolume.densityInjection.enable = true; globalVolume.densityInjection.strength = 0.1f; globalVolume.densityInjection.noiseMaskLevelParameters.contrast = 15.0f; globalVolume.densityInjection.noiseMaskLevelParameters.outputLowValue = 0.0f; globalVolume.densityInjection.noiseMaskLevelParameters.outputHiValue = -1.0f; globalVolume.lightInjection.injectionParameters.enable = false; globalVolume.scatteringInjection.enable = false; }
/// <summary> /// Generic method for crating a GameObject with a AuraVolume component assigned /// </summary> /// <param name="name">Name of the created GameObject</param> /// <param name="shape">Desired volume shape</param> /// <returns>The created AuraVolume gameObject</returns> public static GameObject CreateGameObject(string name, VolumeType shape) { GameObject newGameObject = new GameObject(name); newGameObject.transform.localScale = Vector3.one * 3.0f; AuraVolume auraVolume = newGameObject.AddComponent <AuraVolume>(); auraVolume.volumeShape.shape = shape; SetDefaultValues(auraVolume); return(newGameObject); }
/// <summary> /// Set default values /// </summary> /// <param name="auraVolume"></param> private static void SetDefaultValues(AuraVolume auraVolume) { auraVolume.volumeShape.fading.falloffExponent = 3.0f; auraVolume.volumeShape.fading.xPositiveCubeFade = 0.25f; auraVolume.volumeShape.fading.xNegativeCubeFade = 0.25f; auraVolume.volumeShape.fading.yPositiveCubeFade = 0.25f; auraVolume.volumeShape.fading.yNegativeCubeFade = 0.25f; auraVolume.volumeShape.fading.zPositiveCubeFade = 0.25f; auraVolume.volumeShape.fading.zNegativeCubeFade = 0.25f; auraVolume.volumeShape.fading.angularConeFade = 0.5f; auraVolume.volumeShape.fading.distanceConeFade = 0.5f; auraVolume.volumeShape.fading.widthCylinderFade = 0.5f; auraVolume.volumeShape.fading.yNegativeCylinderFade = 0.25f; auraVolume.volumeShape.fading.yPositiveCylinderFade = 0.25f; auraVolume.volumeShape.fading.distanceSphereFade = 0.5f; auraVolume.texture2DMask.SetDefaultValues(); auraVolume.texture3DMask.SetDefaultValues(); auraVolume.noiseMask.speed = 0.125f; auraVolume.noiseMask.transform.scale = Vector3.one * 5.0f; auraVolume.densityInjection.useNoiseMask = true; auraVolume.densityInjection.useNoiseMaskLevels = true; auraVolume.densityInjection.noiseMaskLevelParameters.SetDefaultValues(); auraVolume.densityInjection.noiseMaskLevelParameters.contrast = 5.0f; auraVolume.densityInjection.useTexture2DMask = true; auraVolume.densityInjection.texture2DMaskLevelParameters.SetDefaultValues(); auraVolume.densityInjection.useTexture3DMask = true; auraVolume.densityInjection.texture3DMaskLevelParameters.SetDefaultValues(); auraVolume.densityInjection.enable = true; // To have something visible when a volume is added auraVolume.densityInjection.strength = 5.0f; // To have something visible when a volume is added auraVolume.scatteringInjection.useNoiseMask = true; auraVolume.scatteringInjection.useNoiseMaskLevels = true; auraVolume.scatteringInjection.noiseMaskLevelParameters.SetDefaultValues(); auraVolume.scatteringInjection.noiseMaskLevelParameters.contrast = 3.0f; auraVolume.scatteringInjection.noiseMaskLevelParameters.outputLowValue = -1.0f; auraVolume.scatteringInjection.useTexture2DMask = true; auraVolume.scatteringInjection.texture2DMaskLevelParameters.SetDefaultValues(); auraVolume.scatteringInjection.texture2DMaskLevelParameters.outputLowValue = -1.0f; auraVolume.scatteringInjection.useTexture3DMask = true; auraVolume.scatteringInjection.texture3DMaskLevelParameters.SetDefaultValues(); auraVolume.scatteringInjection.texture3DMaskLevelParameters.outputLowValue = -1.0f; auraVolume.scatteringInjection.strength = 0.25f; auraVolume.lightInjection.injectionParameters.useNoiseMask = true; auraVolume.lightInjection.injectionParameters.useNoiseMaskLevels = true; auraVolume.lightInjection.injectionParameters.noiseMaskLevelParameters.SetDefaultValues(); auraVolume.lightInjection.injectionParameters.noiseMaskLevelParameters.contrast = 5.0f; auraVolume.lightInjection.injectionParameters.useTexture2DMask = true; auraVolume.lightInjection.injectionParameters.texture2DMaskLevelParameters.SetDefaultValues(); auraVolume.lightInjection.injectionParameters.useTexture3DMask = true; auraVolume.lightInjection.injectionParameters.texture3DMaskLevelParameters.SetDefaultValues(); auraVolume.lightInjection.injectionParameters.strength = 1; auraVolume.lightInjection.color = Color.white; }
static void DrawGizmoForAuraVolume(AuraVolume component, GizmoType gizmoType) { bool isFaded = (int)gizmoType == (int)GizmoType.NonSelected || (int)gizmoType == (int)GizmoType.NotInSelectionHierarchy || (int)gizmoType == (int)GizmoType.NonSelected + (int)GizmoType.NotInSelectionHierarchy; if (isFaded && !AuraEditorPrefs.DisplayGizmosWhenUnselected || !isFaded && !AuraEditorPrefs.DisplayGizmosWhenSelected) { return; } float opacity = isFaded ? 0.5f : 1.0f; DrawGizmo(component, opacity); }
/// <summary> /// Draws a "Box" gizmo /// </summary> /// <param name="component">The target component</param> /// <param name="alpha">The base opacity</param> private static void DrawBox(AuraVolume component, float alpha) { float thickness = CustomGizmo.pixelWidth; Color color = CustomGizmo.color; color.a *= alpha; CustomGizmo.DrawCube(component.transform.localToWorldMatrix, color, thickness); float xPos = (1.0f - component.volumeShape.fading.xPositiveCubeFade) * 2 - 1; float xNeg = component.volumeShape.fading.xNegativeCubeFade * 2 - 1; float yPos = (1.0f - component.volumeShape.fading.yPositiveCubeFade) * 2 - 1; float yNeg = component.volumeShape.fading.yNegativeCubeFade * 2 - 1; float zPos = (1.0f - component.volumeShape.fading.zPositiveCubeFade) * 2 - 1; float zNeg = component.volumeShape.fading.zNegativeCubeFade * 2 - 1; Vector3 customPointA = new Vector3(xNeg, yPos, zNeg) * 0.5f; Vector3 customPointB = new Vector3(xPos, yPos, zNeg) * 0.5f; Vector3 customPointC = new Vector3(xPos, yNeg, zNeg) * 0.5f; Vector3 customPointD = new Vector3(xNeg, yNeg, zNeg) * 0.5f; Vector3 customPointE = new Vector3(xNeg, yPos, zPos) * 0.5f; Vector3 customPointF = new Vector3(xPos, yPos, zPos) * 0.5f; Vector3 customPointG = new Vector3(xPos, yNeg, zPos) * 0.5f; Vector3 customPointH = new Vector3(xNeg, yNeg, zPos) * 0.5f; CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerA, new Vector3(xNeg, yPos, zNeg) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerB, new Vector3(xPos, yPos, zNeg) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerC, new Vector3(xPos, yNeg, zNeg) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerD, new Vector3(xNeg, yNeg, zNeg) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerE, new Vector3(xNeg, yPos, zPos) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerF, new Vector3(xPos, yPos, zPos) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerG, new Vector3(xPos, yNeg, zPos) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(CustomGizmo.cubeCornerH, new Vector3(xNeg, yNeg, zPos) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(customPointA, customPointB, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(customPointB, customPointC, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(customPointC, customPointD, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(customPointD, customPointA, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(customPointE, customPointF, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(customPointF, customPointG, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(customPointG, customPointH, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(customPointH, customPointE, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(customPointE, customPointF, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(customPointA, customPointE, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(customPointB, customPointF, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(customPointC, customPointG, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(customPointD, customPointH, component.transform.localToWorldMatrix, color, thickness); }
/// <summary> /// Draws a "Global" gizmo /// </summary> /// <param name="component">The target component</param> /// <param name="alpha">The base opacity</param> private static void DrawGlobal(AuraVolume component, float alpha) { Color color = CustomGizmo.color; color.a = CustomGizmo.color.a * alpha; const int circlesAmount = 10; const float maxWidth = 5.0f; for (int i = 1; i <= circlesAmount; ++i) { float ratio = (float)i / (float)circlesAmount; float curvedRatio = Mathf.Pow(ratio, 2.5f); CustomGizmo.DrawCircle(component.transform.localToWorldMatrix, Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * maxWidth * curvedRatio), color, CustomGizmo.pixelWidth); } }
/// <summary> /// Draws a "Layer" gizmo /// </summary> /// <param name="component">The target component</param> /// <param name="alpha">The base opacity</param> private static void DrawLayer(AuraVolume component, float alpha) { Color color = CustomGizmo.color; color.a *= alpha; int count = 15; for (int i = 0; i < count; ++i) { float ratio = 1.0f - ((float)i / (float)count); float scaleFactor = 1.0f; // Mathf.Lerp(0.5f, 10.0f, ratio); //ratio = 1 - Mathf.Pow(ratio, component.volumeShape.fading.falloffExponent); CustomGizmo.DrawSquare(component.transform.localToWorldMatrix, Matrix4x4.TRS(Vector3.up * ratio, Quaternion.identity, Vector3.one * scaleFactor), color, CustomGizmo.pixelWidth); } }
/// <summary> /// Draws a "Cone" gizmo /// </summary> /// <param name="component">The target component</param> /// <param name="alpha">The base opacity</param> private static void DrawCone(AuraVolume component, float alpha) { float thickness = CustomGizmo.pixelWidth; Color color = CustomGizmo.color; color.a *= alpha; CustomGizmo.DrawCone(component.transform.localToWorldMatrix, color, thickness); float z = 1.0f - component.volumeShape.fading.distanceConeFade; float xy = Mathf.Lerp(0, 1.0f - component.volumeShape.fading.angularConeFade, z); CustomGizmo.DrawLineSegment(new Vector3(0.0f, 0.5f, 1), new Vector3(0, xy * 0.5f, z), component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(new Vector3(0.0f, -0.5f, 1), new Vector3(0, -xy * 0.5f, z), component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(new Vector3(0.5f, 0.0f, 1), new Vector3(xy * 0.5f, 0.0f, z), component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(new Vector3(-0.5f, 0.0f, 1), new Vector3(-xy * 0.5f, 0.0f, z), component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawCone(component.transform.localToWorldMatrix, Vector3.zero, Quaternion.identity, new Vector3(xy, xy, z), color, thickness); }
/// <summary> /// Draws a "Sphere" gizmo /// </summary> /// <param name="component">The target component</param> /// <param name="alpha">The base opacity</param> private static void DrawSphere(AuraVolume component, float alpha) { float thickness = CustomGizmo.pixelWidth; Color color = CustomGizmo.color; color.a *= alpha; CustomGizmo.DrawSphere(component.transform.localToWorldMatrix, color, CustomGizmo.pixelWidth); float x = 1.0f - component.volumeShape.fading.distanceSphereFade; CustomGizmo.DrawLineSegment(Vector3.up * 0.5f, Vector3.up * x * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(Vector3.down * 0.5f, Vector3.down * x * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(Vector3.left * 0.5f, Vector3.left * x * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(Vector3.right * 0.5f, Vector3.right * x * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(Vector3.back * 0.5f, Vector3.back * x * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(Vector3.forward * 0.5f, Vector3.forward * x * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawSphere(component.transform.localToWorldMatrix, Vector3.zero, Quaternion.identity, Vector3.one * x, color, thickness); }
/// <summary> /// Draws the gizmo /// </summary> /// <param name="component">The target component</param> /// <param name="opacity">The gizmo opacity</param> private static void DrawGizmo(AuraVolume component, float opacity) { switch (component.volumeShape.shape) { case VolumeType.Global: { DrawGlobal(component, opacity); } break; case VolumeType.Layer: { DrawLayer(component, opacity); } break; case VolumeType.Box: { DrawBox(component, opacity); } break; case VolumeType.Sphere: { DrawSphere(component, opacity); } break; case VolumeType.Cylinder: { DrawCylinder(component, opacity); } break; case VolumeType.Cone: { DrawCone(component, opacity); } break; } }
/// <summary> /// Draws a "Cylinder" gizmo /// </summary> /// <param name="component">The target component</param> /// <param name="alpha">The base opacity</param> private static void DrawCylinder(AuraVolume component, float alpha) { float thickness = CustomGizmo.pixelWidth; Color color = CustomGizmo.color; color.a *= alpha; CustomGizmo.DrawCylinder(component.transform.localToWorldMatrix, color, thickness); float x = 1.0f - component.volumeShape.fading.widthCylinderFade; float yPos = (1.0f - component.volumeShape.fading.yPositiveCylinderFade) * 2 - 1; float yNeg = component.volumeShape.fading.yNegativeCylinderFade * 2 - 1; CustomGizmo.DrawLineSegment(new Vector3(0.5f, 0.5f, 0), new Vector3(x, yPos, 0) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(new Vector3(-0.5f, 0.5f, 0), new Vector3(-x, yPos, 0) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(new Vector3(0.5f, -0.5f, 0), new Vector3(x, yNeg, 0) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(new Vector3(-0.5f, -0.5f, 0), new Vector3(-x, yNeg, 0) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(new Vector3(0.0f, 0.5f, 0.5f), new Vector3(0, yPos, x) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(new Vector3(0.0f, 0.5f, -0.5f), new Vector3(0, yPos, -x) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(new Vector3(0.0f, -0.5f, 0.5f), new Vector3(0, yNeg, x) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawLineSegment(new Vector3(0.0f, -0.5f, -0.5f), new Vector3(0, yNeg, -x) * 0.5f, component.transform.localToWorldMatrix, color, thickness); CustomGizmo.DrawCylinder(component.transform.localToWorldMatrix, (Vector3.up * ((1.0f - component.volumeShape.fading.yPositiveCylinderFade) + component.volumeShape.fading.yNegativeCylinderFade) * 0.5f) - Vector3.up * 0.5f, Quaternion.identity, new Vector3(x, 1.0f - component.volumeShape.fading.yPositiveCylinderFade - component.volumeShape.fading.yNegativeCylinderFade, x), color, thickness); }
/// <summary> /// Returns an array with all the aura volumes /// </summary> /// <returns>An array with the aura volumes</returns> public static AuraVolume[] GetAuraVolumes() { return(AuraVolume.FindObjectsOfType <AuraVolume>()); }
static void HierarchyWindowItemOnGUI(int instanceID, Rect selectionRect) { if (AuraEditorPrefs.DisplayButtonsInHierarchy) { GameObject gameObject = (GameObject)EditorUtility.InstanceIDToObject(instanceID); if (gameObject != null) { float size = selectionRect.height; Rect rect = new Rect(selectionRect.x + selectionRect.width, selectionRect.y, size, size); string tooltip; bool state; //// Cameras Camera camera = gameObject.GetComponent <Camera>(); AuraCamera auraCamera = gameObject.GetComponent <AuraCamera>(); if (camera != null && auraCamera == null) { tooltip = "Add Aura Camera Component"; rect.x -= size; if (GUI.Button(rect, new GUIContent(Aura.ResourcesCollection.addIconTexture, tooltip), GuiStyles.ButtonImageOnlyNoBorder)) { gameObject.AddComponent <AuraCamera>(); } } if (auraCamera != null) { state = auraCamera.enabled; tooltip = (state ? "Disable" : "Enable") + " Aura Camera"; rect.x -= size; if (GUI.Button(rect, new GUIContent(Aura.ResourcesCollection.cameraMiniIconTexture, tooltip), state ? GuiStyles.ButtonPressedImageOnlyNoBorder : GuiStyles.ButtonImageOnlyNoBorder)) // TODO : MAKE THIS A GENERIC HELPER { auraCamera.enabled = !state; } } //// Lights Light light = gameObject.GetComponent <Light>(); AuraLight auraLight = gameObject.GetComponent <AuraLight>(); if (light != null && auraLight == null) { tooltip = "Add Aura Light Component"; rect.x -= size; if (GUI.Button(rect, new GUIContent(Aura.ResourcesCollection.addIconTexture, tooltip), GuiStyles.ButtonImageOnlyNoBorder)) { gameObject.AddComponent <AuraLight>(); } } if (auraLight != null && auraLight.Type != LightType.Area) { state = auraLight.enabled; tooltip = (state ? "Disable" : "Enable") + " Aura Light"; rect.x -= size; Texture2D texture = Aura.ResourcesCollection.pointLightMiniIconTexture; switch (auraLight.Type) { case LightType.Directional: { texture = Aura.ResourcesCollection.directionalLightMiniIconTexture; } break; case LightType.Spot: { texture = Aura.ResourcesCollection.spotLightMiniIconTexture; } break; } if (GUI.Button(rect, new GUIContent(texture, tooltip), state ? GuiStyles.ButtonPressedImageOnlyNoBorder : GuiStyles.ButtonImageOnlyNoBorder)) // TODO : MAKE THIS A GENERIC HELPER { auraLight.enabled = !state; } } //// Volumes AuraVolume auraVolume = gameObject.GetComponent <AuraVolume>(); if (auraVolume != null) { state = auraVolume.enabled; tooltip = (state ? "Disable" : "Enable") + " Aura Volume"; rect.x -= size; if (GUI.Button(rect, new GUIContent(Aura.ResourcesCollection.shapeMiniIconTexture, tooltip), state ? GuiStyles.ButtonPressedImageOnlyNoBorder : GuiStyles.ButtonImageOnlyNoBorder)) // TODO : MAKE THIS A GENERIC HELPER { auraVolume.enabled = !state; } } //// Sprites SpriteRenderer spriteRenderer = gameObject.GetComponent <SpriteRenderer>(); AuraSprite auraSprite = gameObject.GetComponent <AuraSprite>(); if (spriteRenderer != null && auraSprite == null) { tooltip = "Add Aura Sprite Component"; rect.x -= size; if (GUI.Button(rect, new GUIContent(Aura.ResourcesCollection.addIconTexture, tooltip), GuiStyles.ButtonImageOnlyNoBorder)) { gameObject.AddComponent <AuraSprite>(); } } if (auraSprite != null) { tooltip = "Aura Sprite"; rect.x -= size; GUI.Label(rect, new GUIContent(Aura.ResourcesCollection.spriteMiniIconTexture, tooltip), GuiStyles.ButtonPressedImageOnlyNoBorder); } } } }
/// <summary> /// Called when a volume unregisters from the global list /// </summary> /// <param name="auraVolume">The unregistering volume</param> private void VolumesCommonDataManager_OnUnregisterVolume(AuraVolume auraVolume) { _culler.Unregister(auraVolume); }