207 lines
5.5 KiB
C#
207 lines
5.5 KiB
C#
using UIWidgets;
|
|
using UltimateWater;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class WaterSettings : MonoBehaviour
|
|
{
|
|
public WaterProfile waterProfileLight;
|
|
|
|
public WaterProfile waterProfileHeavy;
|
|
|
|
public Transform waterDirectionPointer;
|
|
|
|
[Space(10f)]
|
|
public ColorPicker colorPickerDiffuse;
|
|
|
|
public ColorPicker colorPickerAbsorption;
|
|
|
|
public ColorPicker colorPickerAbsorptionUnderwater;
|
|
|
|
public Toggle underwaterEffectToggle;
|
|
|
|
[HideInInspector]
|
|
public Water water;
|
|
|
|
public Color diffuseColor = Color.white;
|
|
|
|
public Color absorptionColor = Color.white;
|
|
|
|
public Color absorptionColorUnderwater = Color.white;
|
|
|
|
public Color startAbsorptionColorUnderwater = Color.white;
|
|
|
|
public float waterDirection;
|
|
|
|
public float waterDirectionality = 0.35f;
|
|
|
|
private void Awake()
|
|
{
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (!(water == null))
|
|
{
|
|
colorPickerDiffuse.Color = diffuseColor;
|
|
colorPickerAbsorption.Color = absorptionColor;
|
|
colorPickerAbsorptionUnderwater.Color = absorptionColorUnderwater;
|
|
}
|
|
}
|
|
|
|
public void UpdateWater()
|
|
{
|
|
SetColorDiffuse(diffuseColor);
|
|
SetColorAbsorption(absorptionColor);
|
|
SetColorAbsorptionUnderwater(absorptionColorUnderwater);
|
|
SetDirectionality(waterDirectionality);
|
|
water.WindWaves.WindDirectionPointer = waterDirectionPointer;
|
|
}
|
|
|
|
public void UpdateWaterGame(Color colorDiffuse, Color colorTransmission, float directionality, float direction)
|
|
{
|
|
}
|
|
|
|
public Color GetColorDiffuse()
|
|
{
|
|
return diffuseColor;
|
|
}
|
|
|
|
public void SetColorDiffuse(Color newColor)
|
|
{
|
|
diffuseColor = newColor;
|
|
if (!(water == null))
|
|
{
|
|
water.ProfilesManager.Profiles[0].Profile.DiffuseColor = newColor;
|
|
water.ProfilesManager.Profiles[1].Profile.DiffuseColor = newColor;
|
|
}
|
|
}
|
|
|
|
public void UpdateColorPickerDiffuse()
|
|
{
|
|
SetColorDiffuse(colorPickerDiffuse.Color);
|
|
}
|
|
|
|
public Color GetColorAbsorption()
|
|
{
|
|
return absorptionColor;
|
|
}
|
|
|
|
public void SetColorAbsorption(Color newColor, bool isTransmission = true)
|
|
{
|
|
absorptionColor = newColor;
|
|
if (!isTransmission)
|
|
{
|
|
absorptionColor.r = Mathf.Exp(0f - absorptionColor.r);
|
|
absorptionColor.g = Mathf.Exp(0f - absorptionColor.g);
|
|
absorptionColor.b = Mathf.Exp(0f - absorptionColor.b);
|
|
}
|
|
if (!(water == null))
|
|
{
|
|
if (isTransmission)
|
|
{
|
|
newColor.r = 0f - Mathf.Log(newColor.r);
|
|
newColor.g = 0f - Mathf.Log(newColor.g);
|
|
newColor.b = 0f - Mathf.Log(newColor.b);
|
|
}
|
|
water.ProfilesManager.Profiles[0].Profile.AbsorptionColor = newColor;
|
|
water.ProfilesManager.Profiles[1].Profile.AbsorptionColor = newColor;
|
|
}
|
|
}
|
|
|
|
public void UpdateColorPickerAbsorption()
|
|
{
|
|
SetColorAbsorption(colorPickerAbsorption.Color);
|
|
}
|
|
|
|
public Color GetColorAbsorptionUnderwater()
|
|
{
|
|
return absorptionColorUnderwater;
|
|
}
|
|
|
|
public void SetColorAbsorptionUnderwater(Color newColor, bool isTransmission = true)
|
|
{
|
|
absorptionColorUnderwater = newColor;
|
|
if (!isTransmission)
|
|
{
|
|
absorptionColorUnderwater.r = Mathf.Exp(0f - absorptionColorUnderwater.r);
|
|
absorptionColorUnderwater.g = Mathf.Exp(0f - absorptionColorUnderwater.g);
|
|
absorptionColorUnderwater.b = Mathf.Exp(0f - absorptionColorUnderwater.b);
|
|
}
|
|
if (!(water == null))
|
|
{
|
|
if (isTransmission)
|
|
{
|
|
newColor.r = 0f - Mathf.Log(newColor.r);
|
|
newColor.g = 0f - Mathf.Log(newColor.g);
|
|
newColor.b = 0f - Mathf.Log(newColor.b);
|
|
}
|
|
Gradient absorptionColorByDepth = water.ProfilesManager.Profiles[0].Profile.AbsorptionColorByDepth;
|
|
GradientColorKey[] array = new GradientColorKey[2];
|
|
GradientAlphaKey[] array2 = new GradientAlphaKey[2];
|
|
array[0].color = (array[1].color = newColor);
|
|
array2[0].alpha = (array2[1].alpha = 1f);
|
|
array[0].time = (array2[0].time = 0f);
|
|
array[1].time = (array2[1].time = 1f);
|
|
absorptionColorByDepth.SetKeys(array, array2);
|
|
water.ProfilesManager.Profiles[0].Profile.AbsorptionColorByDepth = absorptionColorByDepth;
|
|
water.ProfilesManager.Profiles[1].Profile.AbsorptionColorByDepth = absorptionColorByDepth;
|
|
water.ProfilesManager.Profiles[0].Profile.AbsorptionColorByDepth = absorptionColorByDepth;
|
|
water.ProfilesManager.Profiles[1].Profile.AbsorptionColorByDepth = absorptionColorByDepth;
|
|
}
|
|
}
|
|
|
|
public void UpdateColorPickerAbsorptionUnderwater()
|
|
{
|
|
SetColorAbsorptionUnderwater(colorPickerAbsorptionUnderwater.Color);
|
|
}
|
|
|
|
public float GetDirectionality()
|
|
{
|
|
return waterDirectionality;
|
|
}
|
|
|
|
public void SetDirectionality(float dir)
|
|
{
|
|
waterDirectionality = dir;
|
|
if (!(water == null))
|
|
{
|
|
water.ProfilesManager.Profiles[0].Profile.Directionality = dir;
|
|
water.ProfilesManager.Profiles[1].Profile.Directionality = dir;
|
|
}
|
|
}
|
|
|
|
public float GetDirection()
|
|
{
|
|
return waterDirection;
|
|
}
|
|
|
|
public void SetDirection(float dir)
|
|
{
|
|
waterDirection = Utilities.GetAngleNormalRange(dir);
|
|
Vector3 eulerAngles = waterDirectionPointer.eulerAngles;
|
|
eulerAngles.y = waterDirection;
|
|
waterDirectionPointer.eulerAngles = eulerAngles;
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
SetColorDiffuse(waterProfileLight.Data.DiffuseColor);
|
|
SetColorAbsorption(waterProfileLight.Data.AbsorptionColor, false);
|
|
SetColorAbsorptionUnderwater(startAbsorptionColorUnderwater);
|
|
colorPickerDiffuse.Color = diffuseColor;
|
|
colorPickerAbsorption.Color = absorptionColor;
|
|
colorPickerAbsorptionUnderwater.Color = absorptionColorUnderwater;
|
|
}
|
|
|
|
public void UpdateUnderwaterEffect()
|
|
{
|
|
FisheryEditor.Instance.ShowUnderwaterCamera(underwaterEffectToggle.isOn);
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
GlobalSettings.Instance.playerSettings.editorUnderwaterEffect = underwaterEffectToggle.isOn;
|
|
GlobalSettings.Instance.playerSettings.Save();
|
|
}
|
|
}
|
|
}
|