1348 lines
47 KiB
C#
1348 lines
47 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System.IO;
|
|
using System;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.Rendering.HighDefinition;
|
|
using TMPro;
|
|
|
|
public class LightModeManager : MonoBehaviour
|
|
{
|
|
//Make an array
|
|
public GameObject LightModePanel;
|
|
public GameObject LightModePanelHUD;
|
|
public GameObject SelectLightPanel;
|
|
public GameObject EditLightPanel;
|
|
public GameObject EditPoint_SpotLightsHUD;
|
|
public GameObject EditNaturalLightHUD;
|
|
public GameObject BottomHelpButtonsHUD_PC;
|
|
public GameObject BottomHelpButtonsHUD_Controller;
|
|
|
|
public GameObject lightPrefab;
|
|
public List<GameObject> Lights;
|
|
|
|
public Renderer[] Lights1GUI3D;
|
|
public Renderer[] Lights2GUI3D;
|
|
public Renderer[] Lights3GUI3D;
|
|
|
|
[SerializeField] private List<SpotLight3DGizmos> spotLight3DGizmos;
|
|
[SerializeField] private List<SphereLight3DGizmos> sphereLight3DGizmos;
|
|
|
|
public List <bool> UpdateLightsGUI3D;
|
|
|
|
public List<bool> lightIsSpawned;
|
|
public List<bool> lightIsActive;
|
|
public List<bool> canPressButtonToTurnOnLight;
|
|
|
|
public bool light1IsSpawned;
|
|
public bool light1IsActive;
|
|
public bool light1DataAdded;
|
|
|
|
public List<bool> lightDataAdded;
|
|
|
|
public bool light2IsSpawned;
|
|
public bool light2IsActive;
|
|
public bool light2DataAdded;
|
|
|
|
public bool light3IsSpawned;
|
|
public bool light3IsActive;
|
|
public bool light3DataAdded;
|
|
|
|
public bool EditLight1;
|
|
public bool EditLight2;
|
|
public bool EditLight3;
|
|
public bool EditNaturalLight;
|
|
public bool UpdateLightType = true;
|
|
|
|
public Slider colorSlider;
|
|
public Slider colorIntensitySlider;
|
|
public Slider lightIntensity;
|
|
public Slider lightDistanceSlider;
|
|
public Slider lightSpreadSlider;
|
|
public Slider spotlightSoftnessSlider;
|
|
|
|
#region Buttons Variables
|
|
[Header("Buttons")]
|
|
[Header("Lightmode select light mode: buttons")]
|
|
[SerializeField] private Button _selectALightButton;
|
|
[SerializeField] private Button _editLightButton;
|
|
|
|
private Animator _selectALightButtonAnimator;
|
|
private Animator _editLightButtonAnimator;
|
|
|
|
[Header("Select a light buttons")]
|
|
public List<Button> lightONButton = new List<Button>(3);
|
|
public List<Button> lightOFFButton = new List<Button>(3);
|
|
public List<GameObject> lightONCheckUI = new List<GameObject>(3);
|
|
public List<GameObject> lightOFFCheckUI = new List<GameObject>(3);
|
|
|
|
public Button Light1ONButton;
|
|
public Button Light1OFFButton;
|
|
public GameObject Light1ONCheckUI;
|
|
public GameObject Light1OFFCheckUI;
|
|
|
|
public Button Light2ONButton;
|
|
public Button Light2OFFButton;
|
|
public GameObject Light2ONCheckUI;
|
|
public GameObject Light2OFFCheckUI;
|
|
|
|
public Button Light3ONButton;
|
|
public Button Light3OFFButton;
|
|
public GameObject Light3ONCheckUI;
|
|
public GameObject Light3OFFCheckUI;
|
|
|
|
public Button CastShadowsONButton;
|
|
public Button CastShadowsOFFButton;
|
|
public GameObject CastShadowsONCheckUI;
|
|
public GameObject CastShadowsOFFCheckUI;
|
|
|
|
|
|
#region Edit light buttons
|
|
[Header("Edit light buttons")]
|
|
public Button ButtonPreviousSelectedLight;
|
|
public Button ButtonNextSelectedLight;
|
|
public Button ButtonPreviousLightType;
|
|
public Button ButtonNextLightType;
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
[Header("UI")]
|
|
[SerializeField] private TextMeshProUGUI SelectedLightText;
|
|
[SerializeField] private TextMeshProUGUI LightTypeText;
|
|
[SerializeField] private GameObject LightAttentionMessagePanel;
|
|
[SerializeField] private TextMeshProUGUI LightAttentionMessageText;
|
|
private Animator LightAttentionMessagePanelAnimator;
|
|
|
|
[SerializeField] private List<HDAdditionalLightData> lightData;
|
|
[SerializeField] private List<ArrowLightMovement> ArrowLightMovement;
|
|
|
|
public int selectedLightIndex;
|
|
public int selectedLightIndexMax = 4;
|
|
public int currentLightSelected;
|
|
public List<int> lightTypeIndex;
|
|
|
|
|
|
public List<bool> lightShadowsIsActive;
|
|
|
|
public List<bool> SpotLightIsActive;
|
|
|
|
public List<bool> spotLight3DGizmosIsAdded;
|
|
|
|
public List<bool> sphereLight3DGizmosIsAdded;
|
|
|
|
[HideInInspector] public int SelectLightOrEditLightIndex;
|
|
|
|
#region Default values
|
|
public List<float> colorSlider_Light_DefaultValue;
|
|
|
|
public List<float> colorSliderIntensity_Light_DefaultValue;
|
|
|
|
public List<float> lightIntensitySlider_Light_DefaultValue;
|
|
|
|
public List<float> lightDistanceSlider_Light_DefaultValue;
|
|
|
|
public List<float> lightSpreadSlider_Light_DefaultValue;
|
|
|
|
public List<float> spotlightSoftnessSlider_Light_DefaultValue;
|
|
#endregion
|
|
|
|
float SpotLightRadiusScaleFinalValue;
|
|
public bool ValuesInitialized;
|
|
|
|
|
|
private static LightModeManager _instance;
|
|
public static LightModeManager GetInstance() { return _instance; }
|
|
|
|
IEnumerator DeleteLights()
|
|
{
|
|
Array.Clear(Lights1GUI3D, 0, Lights1GUI3D.Length);
|
|
Array.Clear(Lights2GUI3D, 0, Lights2GUI3D.Length);
|
|
Array.Clear(Lights3GUI3D, 0, Lights3GUI3D.Length);
|
|
Lights1GUI3D = new Renderer[0];
|
|
Lights2GUI3D = new Renderer[0];
|
|
Lights3GUI3D = new Renderer[0];
|
|
|
|
//int lights = Lights.Count;
|
|
|
|
for (int i = 0; i < Lights.Count; i++)
|
|
{
|
|
Destroy(Lights[i]);
|
|
//Lights.RemoveAt(i);
|
|
if (i == Lights.Count - 1)
|
|
{
|
|
Lights.Clear();
|
|
yield return null;
|
|
}
|
|
}
|
|
//Lights.Clear();
|
|
lightShadowsIsActive.Clear();
|
|
SpotLightIsActive.Clear();
|
|
colorSlider_Light_DefaultValue.Clear();
|
|
colorSliderIntensity_Light_DefaultValue.Clear();
|
|
lightDistanceSlider_Light_DefaultValue.Clear();
|
|
lightIntensitySlider_Light_DefaultValue.Clear();
|
|
lightSpreadSlider_Light_DefaultValue.Clear();
|
|
spotlightSoftnessSlider_Light_DefaultValue.Clear();
|
|
spotLight3DGizmosIsAdded.Clear();
|
|
spotLight3DGizmos.Clear();
|
|
sphereLight3DGizmos.Clear();
|
|
sphereLight3DGizmosIsAdded.Clear();
|
|
lightDataAdded.Clear();
|
|
lightData.Clear();
|
|
lightIsSpawned.Clear();
|
|
lightIsActive.Clear();
|
|
UpdateLightsGUI3D.Clear();
|
|
canPressButtonToTurnOnLight.Clear();
|
|
ArrowLightMovement.Clear();
|
|
lightTypeIndex.Clear();
|
|
|
|
print("Lights deleted");
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
if (!_instance)
|
|
{
|
|
_instance = this;
|
|
}
|
|
|
|
LightAttentionMessagePanelAnimator = LightAttentionMessagePanel.GetComponent<Animator>();
|
|
_selectALightButtonAnimator = _selectALightButton.GetComponent<Animator>();
|
|
_editLightButtonAnimator = _editLightButton.GetComponent<Animator>();
|
|
|
|
Lights.Clear();
|
|
lightShadowsIsActive.Clear();
|
|
SpotLightIsActive.Clear();
|
|
colorSlider_Light_DefaultValue.Clear();
|
|
colorSliderIntensity_Light_DefaultValue.Clear();
|
|
lightDistanceSlider_Light_DefaultValue.Clear();
|
|
lightIntensitySlider_Light_DefaultValue.Clear();
|
|
lightSpreadSlider_Light_DefaultValue.Clear();
|
|
spotlightSoftnessSlider_Light_DefaultValue.Clear();
|
|
spotLight3DGizmosIsAdded.Clear();
|
|
spotLight3DGizmos.Clear();
|
|
sphereLight3DGizmos.Clear();
|
|
sphereLight3DGizmosIsAdded.Clear();
|
|
lightDataAdded.Clear();
|
|
lightIsSpawned.Clear();
|
|
lightIsActive.Clear();
|
|
UpdateLightsGUI3D.Clear();
|
|
canPressButtonToTurnOnLight.Clear();
|
|
ArrowLightMovement.Clear();
|
|
lightData.Clear();
|
|
lightTypeIndex.Clear();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
InitializeValues();
|
|
}
|
|
|
|
private void InitializeValues()
|
|
{
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
Lights.Add(null);
|
|
lightData.Add(null);
|
|
lightShadowsIsActive.Add(false);
|
|
SpotLightIsActive.Add(false);
|
|
colorSlider_Light_DefaultValue.Add(0);
|
|
colorSliderIntensity_Light_DefaultValue.Add(3);
|
|
lightDistanceSlider_Light_DefaultValue.Add(10);
|
|
lightSpreadSlider_Light_DefaultValue.Add(2);
|
|
spotlightSoftnessSlider_Light_DefaultValue.Add(0);
|
|
lightIntensitySlider_Light_DefaultValue.Add(16);
|
|
spotLight3DGizmosIsAdded.Add(false);
|
|
spotLight3DGizmos.Add(null);
|
|
sphereLight3DGizmos.Add(null);
|
|
sphereLight3DGizmosIsAdded.Add(false);
|
|
lightDataAdded.Add(false);
|
|
lightIsSpawned.Add(false);
|
|
lightIsActive.Add(false);
|
|
UpdateLightsGUI3D.Add(false);
|
|
canPressButtonToTurnOnLight.Add(true);
|
|
ArrowLightMovement.Add(null);
|
|
UpdateLightType = true;
|
|
ValuesInitialized = true;
|
|
lightTypeIndex.Add(0);
|
|
|
|
print("Values initialized");
|
|
}
|
|
}
|
|
|
|
private void Lock_Buttons_Sliders()
|
|
{
|
|
ButtonNextLightType.interactable = false;
|
|
ButtonPreviousLightType.interactable = false;
|
|
lightIntensity.interactable = false;
|
|
colorSlider.interactable = false;
|
|
colorIntensitySlider.interactable = false;
|
|
lightSpreadSlider.interactable = false;
|
|
spotlightSoftnessSlider.interactable = false;
|
|
lightDistanceSlider.interactable = false;
|
|
CastShadowsOFFButton.interactable = false;
|
|
CastShadowsONButton.interactable = false;
|
|
}
|
|
|
|
private void Unlock_Buttons_Sliders()
|
|
{
|
|
ButtonNextLightType.interactable = true;
|
|
ButtonPreviousLightType.interactable = true;
|
|
lightIntensity.interactable = true;
|
|
colorSlider.interactable = true;
|
|
colorIntensitySlider.interactable = true;
|
|
lightSpreadSlider.interactable = true;
|
|
spotlightSoftnessSlider.interactable = true;
|
|
lightDistanceSlider.interactable = true;
|
|
CastShadowsOFFButton.interactable = true;
|
|
CastShadowsONButton.interactable = true;
|
|
}
|
|
|
|
public enum SelectedLight
|
|
{
|
|
None,
|
|
Light1,
|
|
Light2,
|
|
Light3,
|
|
NaturalLight
|
|
}
|
|
public SelectedLight selectedLightState = SelectedLight.None;
|
|
|
|
IEnumerator Disable_LightAttentionMessagePanel()
|
|
{
|
|
LightAttentionMessagePanelAnimator.SetBool("FadeIn", false);
|
|
yield return new WaitForSecondsRealtime(0.2f);
|
|
LightAttentionMessagePanel.SetActive(false);
|
|
}
|
|
|
|
void SelectedLightUpdate()
|
|
{
|
|
switch (selectedLightState)
|
|
{
|
|
case SelectedLight.None:
|
|
EditLight1 = false;
|
|
EditLight2 = false;
|
|
EditLight3 = false;
|
|
EditNaturalLight = false;
|
|
SelectedLightText.text = "None";
|
|
|
|
EditNaturalLightHUD.SetActive(false);
|
|
EditPoint_SpotLightsHUD.SetActive(false);
|
|
|
|
if (LightAttentionMessagePanel.activeSelf)
|
|
{
|
|
StartCoroutine(Disable_LightAttentionMessagePanel());
|
|
}
|
|
|
|
if (lightIsActive.Count > 0)
|
|
{
|
|
if (lightIsActive[0]) //Updates the 3D GUI (Arrows etc)
|
|
{
|
|
foreach (Renderer lightsGUI3D in Lights1GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
UpdateLightsGUI3D[0] = false;
|
|
}
|
|
ArrowLightMovement[0].enabled = false;
|
|
}
|
|
if (lightIsActive[1]) //Updates the 3D GUI (Arrows etc)
|
|
{
|
|
foreach (Renderer lightsGUI3D in Lights2GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
UpdateLightsGUI3D[1] = false;
|
|
}
|
|
ArrowLightMovement[1].enabled = false;
|
|
}
|
|
if (lightIsActive[2]) //Updates the 3D GUI (Arrows etc)
|
|
{
|
|
foreach (Renderer lightsGUI3D in Lights3GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
UpdateLightsGUI3D[2] = false;
|
|
}
|
|
ArrowLightMovement[2].enabled = false;
|
|
}
|
|
}
|
|
break;
|
|
case SelectedLight.Light1:
|
|
EditLight1 = true;
|
|
EditLight2 = false;
|
|
EditLight3 = false;
|
|
EditNaturalLight = false;
|
|
SelectedLightText.text = "Light 1";
|
|
|
|
EditNaturalLightHUD.SetActive(false);
|
|
EditPoint_SpotLightsHUD.SetActive(true);
|
|
|
|
if (lightIsActive[0]) //Updates the 3D GUI (Arrows etc)
|
|
{
|
|
UpdateLightType = true;
|
|
if (LightAttentionMessagePanel.activeSelf)
|
|
{
|
|
StartCoroutine(Disable_LightAttentionMessagePanel());
|
|
}
|
|
foreach (Renderer lightsGUI3D in Lights1GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = true;
|
|
print("Light GUI 3D Updated");
|
|
UpdateLightsGUI3D[0] = false;
|
|
}
|
|
ArrowLightMovement[0].enabled = true;
|
|
Unlock_Buttons_Sliders();
|
|
}
|
|
else
|
|
{
|
|
UpdateLightType = false;
|
|
LightAttentionMessagePanel.SetActive(true);
|
|
LightAttentionMessagePanelAnimator.SetBool("FadeIn", true);
|
|
LightAttentionMessageText.text = "Light 1 is not active!";
|
|
Lock_Buttons_Sliders();
|
|
print("light 1 is not active");
|
|
}
|
|
if (lightIsActive[1]) //Updates the 3D GUI (Arrows etc)
|
|
{
|
|
foreach (Renderer lightsGUI3D in Lights2GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
UpdateLightsGUI3D[1] = false;
|
|
}
|
|
ArrowLightMovement[1].enabled = false;
|
|
}
|
|
if (lightIsActive[2]) //Updates the 3D GUI (Arrows etc)
|
|
{
|
|
foreach (Renderer lightsGUI3D in Lights3GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
UpdateLightsGUI3D[2] = false;
|
|
}
|
|
ArrowLightMovement[2].enabled = false;
|
|
}
|
|
break;
|
|
case SelectedLight.Light2:
|
|
EditLight1 = false;
|
|
EditLight2 = true;
|
|
EditLight3 = false;
|
|
EditNaturalLight = false;
|
|
SelectedLightText.text = "Light 2";
|
|
|
|
EditNaturalLightHUD.SetActive(false);
|
|
EditPoint_SpotLightsHUD.SetActive(true);
|
|
|
|
if (lightIsActive[0]) //Updates the 3D GUI (Arrows etc)
|
|
{
|
|
foreach (Renderer lightsGUI3D in Lights1GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
print("Light GUI 3D Updated");
|
|
UpdateLightsGUI3D[0] = false;
|
|
}
|
|
ArrowLightMovement[0].enabled = false;
|
|
}
|
|
if (lightIsActive[1]) //Updates the 3D GUI (Arrows etc)
|
|
{
|
|
UpdateLightType = true;
|
|
if (LightAttentionMessagePanel.activeSelf)
|
|
{
|
|
StartCoroutine(Disable_LightAttentionMessagePanel());
|
|
}
|
|
foreach (Renderer lightsGUI3D in Lights2GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = true;
|
|
UpdateLightsGUI3D[1] = false;
|
|
}
|
|
ArrowLightMovement[1].enabled = true;
|
|
Unlock_Buttons_Sliders();
|
|
}
|
|
else
|
|
{
|
|
UpdateLightType = false;
|
|
LightAttentionMessagePanel.SetActive(true);
|
|
LightAttentionMessagePanelAnimator.SetBool("FadeIn", true);
|
|
LightAttentionMessageText.text = "Light 2 is not active!";
|
|
Lock_Buttons_Sliders();
|
|
print("light 2 is not active");
|
|
}
|
|
if (lightIsActive[2]) //Updates the 3D GUI (Arrows etc)
|
|
{
|
|
foreach (Renderer lightsGUI3D in Lights3GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
UpdateLightsGUI3D[2] = false;
|
|
}
|
|
ArrowLightMovement[2].enabled = false;
|
|
}
|
|
break;
|
|
case SelectedLight.Light3:
|
|
EditLight1 = false;
|
|
EditLight2 = false;
|
|
EditLight3 = true;
|
|
EditNaturalLight = false;
|
|
SelectedLightText.text = "Light 3";
|
|
|
|
EditNaturalLightHUD.SetActive(false);
|
|
EditPoint_SpotLightsHUD.SetActive(true);
|
|
|
|
if (lightIsActive[0]) //Updates the 3D GUI (Arrows etc)
|
|
{
|
|
foreach (Renderer lightsGUI3D in Lights1GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
print("Light GUI 3D Updated");
|
|
UpdateLightsGUI3D[0] = false;
|
|
}
|
|
ArrowLightMovement[0].enabled = false;
|
|
}
|
|
if (lightIsActive[1]) //Updates the 3D GUI (Arrows etc)
|
|
{
|
|
foreach (Renderer lightsGUI3D in Lights2GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
UpdateLightsGUI3D[1] = false;
|
|
}
|
|
ArrowLightMovement[1].enabled = false;
|
|
}
|
|
if (lightIsActive[2]) //Updates the 3D GUI (Arrows etc)
|
|
{
|
|
UpdateLightType = true;
|
|
if (LightAttentionMessagePanel.activeSelf)
|
|
{
|
|
StartCoroutine(Disable_LightAttentionMessagePanel());
|
|
}
|
|
foreach (Renderer lightsGUI3D in Lights3GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = true;
|
|
UpdateLightsGUI3D[2] = false;
|
|
}
|
|
ArrowLightMovement[2].enabled = true;
|
|
Unlock_Buttons_Sliders();
|
|
}
|
|
else
|
|
{
|
|
UpdateLightType = false;
|
|
LightAttentionMessagePanel.SetActive(true);
|
|
LightAttentionMessagePanelAnimator.SetBool("FadeIn", true);
|
|
LightAttentionMessageText.text = "Light 3 is not active!";
|
|
Lock_Buttons_Sliders();
|
|
print("light 3 is not active");
|
|
}
|
|
break;
|
|
case SelectedLight.NaturalLight:
|
|
EditLight1 = false;
|
|
EditLight2 = false;
|
|
EditLight3 = false;
|
|
EditNaturalLight = true;
|
|
SelectedLightText.text = "Natural Light";
|
|
|
|
EditNaturalLightHUD.SetActive(true);
|
|
EditPoint_SpotLightsHUD.SetActive(false);
|
|
|
|
if (LightAttentionMessagePanel.activeSelf)
|
|
{
|
|
StartCoroutine(Disable_LightAttentionMessagePanel());
|
|
}
|
|
|
|
if (lightIsActive[0]) //Updates the 3D GUI (Arrows etc)
|
|
{
|
|
foreach (Renderer lightsGUI3D in Lights1GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
print("Light GUI 3D Updated");
|
|
UpdateLightsGUI3D[0] = false;
|
|
}
|
|
ArrowLightMovement[0].enabled = false;
|
|
}
|
|
if (lightIsActive[1]) //Updates the 3D GUI (Arrows etc)
|
|
{
|
|
foreach (Renderer lightsGUI3D in Lights2GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
UpdateLightsGUI3D[1] = false;
|
|
}
|
|
ArrowLightMovement[1].enabled = false;
|
|
}
|
|
if (lightIsActive[2]) //Updates the 3D GUI (Arrows etc)
|
|
{
|
|
if (LightAttentionMessagePanel.activeSelf)
|
|
{
|
|
StartCoroutine(Disable_LightAttentionMessagePanel());
|
|
}
|
|
foreach (Renderer lightsGUI3D in Lights3GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
UpdateLightsGUI3D[2] = false;
|
|
}
|
|
ArrowLightMovement[2].enabled = false;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void NextSelectedLight()
|
|
{
|
|
print("Next selected light");
|
|
|
|
selectedLightIndex += 1;
|
|
if (selectedLightIndex > selectedLightIndexMax)
|
|
{
|
|
selectedLightIndex = 0;
|
|
}
|
|
ChangeSelectedLight();
|
|
//if(lightIsActive[selectedLightIndex-2] && selectedLightIndex -2 >= 0 || selectedLightIndex - 2 >= 1 || selectedLightIndex - 2 >= 2/*&& lightTypeIndex[selectedLightIndex - 1] >=1*/ && selectedLightIndex != 3 || selectedLightIndex != 4 || selectedLightIndex != 0)
|
|
// lightData[selectedLightIndex -2].gameObject.GetComponent<SpotLightMovement>().enabled = false;
|
|
|
|
LightIndexUpdate();
|
|
//if(SpotLightIsActive[0] || SpotLightIsActive[1] || SpotLightIsActive[2])
|
|
// lightData[selectedLightIndex - 2].gameObject.GetComponent<SpotLightMovement>().enabled = false;
|
|
}
|
|
public void PreviousSelectedLight()
|
|
{
|
|
print("Previous selected light");
|
|
selectedLightIndex -= 1;
|
|
if (selectedLightIndex < 0)
|
|
{
|
|
selectedLightIndex = selectedLightIndexMax;
|
|
}
|
|
ChangeSelectedLight();
|
|
//if (lightIsActive[selectedLightIndex + 1] && selectedLightIndex + 1 >= 0 || selectedLightIndex + 1 >= 1 || selectedLightIndex + 1 >= 2/*&& lightTypeIndex[selectedLightIndex - 1] >=1*/&& selectedLightIndex != 3 || selectedLightIndex != 4 || selectedLightIndex != 0)
|
|
// lightData[selectedLightIndex /*+ 1*/].gameObject.GetComponent<SpotLightMovement>().enabled = false;
|
|
LightIndexUpdate();
|
|
}
|
|
|
|
public void LightIndexUpdate()
|
|
{
|
|
switch (selectedLightIndex)
|
|
{
|
|
case 0/*It is in none light state*/:
|
|
currentLightSelected = 1; //Disable light 0.
|
|
break;
|
|
case 1/*Light 0*/:
|
|
currentLightSelected = 0;
|
|
break;
|
|
case 2/*Light 1*/:
|
|
currentLightSelected = 1;
|
|
break;
|
|
case 3/*Light 2*/:
|
|
currentLightSelected = 2;
|
|
break;
|
|
case 4/*It is in natural light state*/:
|
|
currentLightSelected = 1; //Disable light 2.
|
|
break;
|
|
}
|
|
switch (currentLightSelected)
|
|
{
|
|
case 0:
|
|
if(SpotLightIsActive[1])
|
|
lightData[1].gameObject.GetComponent<SpotLightMovement>().enabled = false;
|
|
break;
|
|
case 1:
|
|
if (SpotLightIsActive[0])
|
|
lightData[0].gameObject.GetComponent<SpotLightMovement>().enabled = false;
|
|
if (SpotLightIsActive[2])
|
|
lightData[2].gameObject.GetComponent<SpotLightMovement>().enabled = false;
|
|
break;
|
|
case 2:
|
|
if (SpotLightIsActive[1])
|
|
lightData[1].gameObject.GetComponent<SpotLightMovement>().enabled = false;
|
|
break;
|
|
}
|
|
print("Disable SpotLightMovement in light:" + currentLightSelected);
|
|
}
|
|
|
|
private void DisableAllSpotLightsMovement()
|
|
{
|
|
if (SpotLightIsActive[0])
|
|
lightData[0].gameObject.GetComponent<SpotLightMovement>().enabled = false;
|
|
if (SpotLightIsActive[1])
|
|
lightData[1].gameObject.GetComponent<SpotLightMovement>().enabled = false;
|
|
if (SpotLightIsActive[2])
|
|
lightData[2].gameObject.GetComponent<SpotLightMovement>().enabled = false;
|
|
}
|
|
|
|
void ChangeSelectedLight()
|
|
{
|
|
switch (selectedLightIndex)
|
|
{
|
|
case 0:
|
|
selectedLightState = SelectedLight.None;
|
|
UpdateLightType = true;
|
|
SelectedLightUpdate();
|
|
break;
|
|
case 1:
|
|
selectedLightState = SelectedLight.Light1;
|
|
//UpdateLightType = true;
|
|
SelectedLightUpdate();
|
|
break;
|
|
case 2:
|
|
selectedLightState = SelectedLight.Light2;
|
|
//UpdateLightType = true;
|
|
SelectedLightUpdate();
|
|
break;
|
|
case 3:
|
|
selectedLightState = SelectedLight.Light3;
|
|
//UpdateLightType = true;
|
|
SelectedLightUpdate();
|
|
break;
|
|
case 4:
|
|
selectedLightState = SelectedLight.NaturalLight;
|
|
SelectedLightUpdate();
|
|
UpdateLightType = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//public void NextLightModeMode()
|
|
//{
|
|
// LightmodeCurrentModeIndex += 1;
|
|
// if(LightmodeCurrentModeIndex > 1)
|
|
// {
|
|
// LightmodeCurrentModeIndex = 0;
|
|
// }
|
|
|
|
// if(LightmodeCurrentModeIndex == 1)
|
|
// {
|
|
// LightModeEditLight_Mode();
|
|
// }
|
|
//}
|
|
|
|
//public void PreviousLightModeMode()
|
|
//{
|
|
|
|
//}
|
|
|
|
public void LightModeSelectALight_Mode()
|
|
{
|
|
EditLightPanel.SetActive(false);
|
|
SelectLightPanel.SetActive(true);
|
|
lightModeState = LightModeStates.SelectALight;
|
|
//DisableCurrentSpotLightMovement();
|
|
LightIndexUpdate();
|
|
#region Button color
|
|
ColorBlock SelectALightColorBlock = _selectALightButton.colors;
|
|
SelectALightColorBlock.normalColor = new Color(0, 0, 0, 255);
|
|
SelectALightColorBlock.selectedColor = new Color(0, 0, 0, 255);
|
|
_selectALightButton.colors = SelectALightColorBlock;
|
|
|
|
ColorBlock EditLightColorBlock = _editLightButton.colors;
|
|
EditLightColorBlock.normalColor = new Color(255, 255, 255, 255);
|
|
EditLightColorBlock.selectedColor = new Color(255, 255, 255, 255);
|
|
_editLightButton.colors = EditLightColorBlock;
|
|
#endregion
|
|
_selectALightButtonAnimator.enabled = true;
|
|
_editLightButtonAnimator.enabled = false;
|
|
selectedLightIndex = 0;
|
|
DisableAllSpotLightsMovement();
|
|
ChangeSelectedLight();
|
|
}
|
|
|
|
public void LightModeEditLight_Mode()
|
|
{
|
|
EditLightPanel.SetActive(true);
|
|
SelectLightPanel.SetActive(false);
|
|
lightModeState = LightModeStates.EditLight;
|
|
#region Button color
|
|
ColorBlock SelectALightColorBlock = _selectALightButton.colors;
|
|
SelectALightColorBlock.normalColor = new Color(255, 255, 255, 255);
|
|
SelectALightColorBlock.selectedColor = new Color(255, 255, 255, 255);
|
|
_selectALightButton.colors = SelectALightColorBlock;
|
|
|
|
ColorBlock EditLightColorBlock = _editLightButton.colors;
|
|
EditLightColorBlock.normalColor = new Color(0, 0, 0, 255);
|
|
EditLightColorBlock.selectedColor = new Color(0, 0, 0, 255);
|
|
_editLightButton.colors = EditLightColorBlock;
|
|
#endregion
|
|
_selectALightButtonAnimator.enabled = false;
|
|
_editLightButtonAnimator.enabled = true;
|
|
}
|
|
|
|
|
|
public enum LightModeStates
|
|
{
|
|
None,
|
|
SelectALight,
|
|
EditLight
|
|
}
|
|
|
|
public LightModeStates lightModeState = LightModeStates.None;
|
|
|
|
public void LightModeStatesUpdate()
|
|
{
|
|
if (InputControlManager.Getinstance().IsUsingJoystick)
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.JoystickButton5) || Input.GetKeyDown(KeyCode.JoystickButton4))
|
|
{
|
|
SelectLightOrEditLightIndex += 1;
|
|
if(SelectLightOrEditLightIndex > 1)
|
|
{
|
|
SelectLightOrEditLightIndex = 0;
|
|
}
|
|
if(SelectLightOrEditLightIndex < 0)
|
|
{
|
|
SelectLightOrEditLightIndex = 1;
|
|
}
|
|
switch (SelectLightOrEditLightIndex)
|
|
{
|
|
case 0:
|
|
LightModeSelectALight_Mode();
|
|
break;
|
|
case 1:
|
|
LightModeEditLight_Mode();
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
switch (lightModeState)
|
|
{
|
|
case LightModeStates.None:
|
|
//Nothing
|
|
break;
|
|
case LightModeStates.SelectALight:
|
|
SelectALight();
|
|
//LightModeControllerManager.GetInstance().ControllerNavigation_SelectALight();
|
|
break;
|
|
case LightModeStates.EditLight:
|
|
//LightModeControllerManager.GetInstance().ControllerNavigation_EditLight();
|
|
EditLight();
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
#region DEBUGGING
|
|
//if (Input.GetKeyDown(KeyCode.E))
|
|
//{
|
|
// Light1Spawn_TurnON();
|
|
//}
|
|
//if (Input.GetKeyDown(KeyCode.R))
|
|
//{
|
|
// DeleteLight1();
|
|
//}
|
|
|
|
//LightModeStatesUpdate(); //DELETE LATER AND CALL IT FROM PHOTOMODE.
|
|
#endregion
|
|
}
|
|
|
|
public void SelectALight()
|
|
{
|
|
//#region Light 1
|
|
//lightONButton[0].onClick.AddListener(() => { LightSpawn_TurnON(0); });
|
|
//lightOFFButton[0].onClick.AddListener(() => { TurnOffLight(0); });
|
|
//#endregion
|
|
|
|
//#region Light 2
|
|
//lightONButton[1].onClick.AddListener(() => { LightSpawn_TurnON(1); });
|
|
//lightOFFButton[1].onClick.AddListener(() => { TurnOffLight(1); });
|
|
//#endregion
|
|
|
|
//#region Light 3
|
|
//lightONButton[2].onClick.AddListener(() => { LightSpawn_TurnON(2); });
|
|
//lightOFFButton[2].onClick.AddListener(() => { TurnOffLight(2); });
|
|
//#endregion
|
|
|
|
if (!ValuesInitialized)
|
|
{
|
|
InitializeValues();
|
|
}
|
|
|
|
//Lights GUI
|
|
if (!UpdateLightsGUI3D[0] && lightIsActive[0])
|
|
{
|
|
foreach (Renderer lightsGUI3D in Lights1GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
}
|
|
UpdateLightsGUI3D[0] = true;
|
|
}
|
|
|
|
if (!UpdateLightsGUI3D[1] && lightIsActive[1])
|
|
{
|
|
foreach (Renderer lightsGUI3D in Lights2GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
}
|
|
UpdateLightsGUI3D[1] = true;
|
|
}
|
|
|
|
if (!UpdateLightsGUI3D[2] && lightIsActive[2])
|
|
{
|
|
foreach (Renderer lightsGUI3D in Lights3GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
}
|
|
UpdateLightsGUI3D[2] = true;
|
|
}
|
|
}
|
|
|
|
#region Light1
|
|
public void LightSpawn_TurnON(int lightIndex)
|
|
{
|
|
#region UI
|
|
lightONCheckUI[lightIndex].SetActive(true);
|
|
lightOFFCheckUI[lightIndex].SetActive(false);
|
|
#endregion
|
|
|
|
lightIsActive[lightIndex] = true;
|
|
|
|
if (!lightIsSpawned[lightIndex])
|
|
{
|
|
Vector3 SpawnPosition = new Vector3(PoseManager.Getinstance().currentCharacter.transform.position.x, PoseManager.Getinstance().currentCharacter.transform.position.y, PoseManager.Getinstance().currentCharacter.transform.position.z + 0.2f);
|
|
GameObject Light = Instantiate(lightPrefab, SpawnPosition, Quaternion.identity);
|
|
Lights[lightIndex] = Light;
|
|
|
|
if (lightIndex == 0)
|
|
{
|
|
Lights1GUI3D = Lights[lightIndex].transform.GetComponentsInChildren<Renderer>();
|
|
ArrowLightMovement[lightIndex] = Lights[lightIndex].transform.GetComponent<ArrowLightMovement>();
|
|
ArrowLightMovement[lightIndex].enabled = false;
|
|
|
|
foreach (Renderer lightsGUI3D in Lights1GUI3D)
|
|
{
|
|
print("Fucking shit");
|
|
lightsGUI3D.enabled = false;
|
|
}
|
|
|
|
lightIsSpawned[lightIndex] = true;
|
|
}
|
|
if (lightIndex == 1)
|
|
{
|
|
Lights2GUI3D = Lights[lightIndex].transform.GetComponentsInChildren<Renderer>();
|
|
ArrowLightMovement[lightIndex] = Lights[lightIndex].transform.GetComponent<ArrowLightMovement>();
|
|
ArrowLightMovement[lightIndex].enabled = false;
|
|
|
|
foreach (Renderer lightsGUI3D in Lights2GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
}
|
|
|
|
lightIsSpawned[lightIndex] = true;
|
|
}
|
|
if (lightIndex == 2)
|
|
{
|
|
Lights3GUI3D = Lights[lightIndex].transform.GetComponentsInChildren<Renderer>();
|
|
ArrowLightMovement[lightIndex] = Lights[lightIndex].transform.GetComponent<ArrowLightMovement>();
|
|
ArrowLightMovement[lightIndex].enabled = false;
|
|
|
|
foreach (Renderer lightsGUI3D in Lights3GUI3D)
|
|
{
|
|
lightsGUI3D.enabled = false;
|
|
}
|
|
|
|
lightIsSpawned[lightIndex] = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Lights[lightIndex].SetActive(true);
|
|
}
|
|
|
|
//if (lightIsActive[lightIndex] && canPressButtonToTurnOnLight[lightIndex])
|
|
//{
|
|
// selectedLightIndexMax += 1;
|
|
// canPressButtonToTurnOnLight[lightIndex] = false;
|
|
//}
|
|
}
|
|
|
|
public void TurnOffLight(int lightIndex)
|
|
{
|
|
Lights[lightIndex].SetActive(false);
|
|
//lightIsActive[lightIndex] = false;
|
|
|
|
#region UI
|
|
lightONCheckUI[lightIndex].SetActive(false);
|
|
lightOFFCheckUI[lightIndex].SetActive(true);
|
|
#endregion
|
|
|
|
if (lightIsActive[lightIndex])
|
|
{
|
|
//selectedLightIndexMax -= 1;
|
|
//canPressButtonToTurnOnLight[lightIndex] = true;
|
|
lightIsActive[lightIndex] = false;
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region EDIT LIGHT
|
|
public void EditLight()
|
|
{
|
|
#region Buttons
|
|
// ButtonPreviousSelectedLight.onClick.AddListener(() => { PreviousSelectedLight(); });
|
|
// ButtonNextSelectedLight.onClick.AddListener(() => { NextSelectedLight(); });
|
|
#endregion
|
|
|
|
if (EditLight1 && lightIsActive[0])
|
|
{
|
|
#region OldMacaronadaCode
|
|
//if (UpdateLightType)
|
|
//{
|
|
// if (!light1DataAdded)
|
|
// {
|
|
// sphereLight3DGizmos[0] = Lights[0].GetComponentInChildren<SphereLight3DGizmos>(); //Gets the sphere light 3d gizmos script.
|
|
// sphereLight3DGizmosIsAdded[0] = true;
|
|
// lightData.Add(Lights[0].GetComponentInChildren<HDAdditionalLightData>());
|
|
// light1DataAdded = true;
|
|
// }
|
|
// #region Load light data
|
|
// LoadLightData(0);
|
|
// #endregion
|
|
// UpdateLightType = false;
|
|
//}
|
|
//if (UpdateLightsGUI3D) //Updates the 3D GUI (Arrows etc)
|
|
//{
|
|
// foreach (MeshRenderer lightsGUI3D in Lights1GUI3D)
|
|
// {
|
|
// lightsGUI3D.enabled = true;
|
|
// UpdateLightsGUI3D = false;
|
|
// }
|
|
//}
|
|
|
|
//lightData[0].color = Color.HSVToRGB(colorSlider.value, colorIntensitySlider.value, 1);
|
|
//lightData[0].SetRange(lightDistanceSlider.value);
|
|
//lightData[0].lightDimmer = lightIntensity.value;
|
|
|
|
//#region Buttons
|
|
//CastShadowsONButton.onClick.AddListener(() => { CastShadows(0, true); });
|
|
//CastShadowsOFFButton.onClick.AddListener(() => { CastShadows(0, false); });
|
|
//#endregion
|
|
|
|
//Spread(0);
|
|
//SpotLightSoftnessUpdate(0);
|
|
//SphereLightUpdateColor(0);
|
|
|
|
//SaveLightData(0);
|
|
#endregion
|
|
|
|
EditLightUpdate(0);
|
|
}
|
|
else if (EditLight2 && lightIsActive[1])
|
|
{
|
|
EditLightUpdate(1);
|
|
}
|
|
else if (EditLight3 && lightIsActive[2])
|
|
{
|
|
EditLightUpdate(2);
|
|
}
|
|
else if (EditNaturalLight)
|
|
{
|
|
NaturalLightMovement.GetInstance().UpdateNaturalLightValues();
|
|
}
|
|
}
|
|
|
|
private void EditLightUpdate(int lightIndex)
|
|
{
|
|
if (UpdateLightType)
|
|
{
|
|
if (!lightDataAdded[lightIndex])
|
|
{
|
|
sphereLight3DGizmos[lightIndex] = Lights[lightIndex].GetComponentInChildren<SphereLight3DGizmos>(); //Gets the sphere light 3d gizmos script.
|
|
sphereLight3DGizmosIsAdded[lightIndex] = true;
|
|
//lightData.Add(Lights[lightIndex].GetComponentInChildren<HDAdditionalLightData>());
|
|
lightData[lightIndex] = Lights[lightIndex].GetComponentInChildren<HDAdditionalLightData>();
|
|
lightDataAdded[lightIndex] = true;
|
|
}
|
|
#region Load light data
|
|
LoadLightData(lightIndex);
|
|
#endregion
|
|
LightTypeUpdate(selectedLightIndex - 1);
|
|
UpdateLightType = false;
|
|
}
|
|
|
|
#region Old Macaroni code
|
|
//if (UpdateLightsGUI3D[0]) //Updates the 3D GUI (Arrows etc)
|
|
//{
|
|
// foreach (MeshRenderer lightsGUI3D in Lights1GUI3D)
|
|
// {
|
|
// lightsGUI3D.enabled = true;
|
|
// print("Light GUI 3D Updated");
|
|
// UpdateLightsGUI3D[0] = false;
|
|
// }
|
|
//}
|
|
//else if (UpdateLightsGUI3D[1]) //Updates the 3D GUI (Arrows etc)
|
|
//{
|
|
// foreach (MeshRenderer lightsGUI3D in Lights2GUI3D)
|
|
// {
|
|
// lightsGUI3D.enabled = true;
|
|
// UpdateLightsGUI3D[1] = false;
|
|
// }
|
|
//}
|
|
//else if (UpdateLightsGUI3D[2]) //Updates the 3D GUI (Arrows etc)
|
|
//{
|
|
// foreach (MeshRenderer lightsGUI3D in Lights3GUI3D)
|
|
// {
|
|
// lightsGUI3D.enabled = true;
|
|
// UpdateLightsGUI3D[2] = false;
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
lightData[lightIndex].color = Color.HSVToRGB(colorSlider.value, colorIntensitySlider.value, 1);
|
|
lightData[lightIndex].SetRange(lightDistanceSlider.value);
|
|
lightData[lightIndex].lightDimmer = lightIntensity.value;
|
|
|
|
#region Buttons
|
|
//CastShadowsONButton.onClick.AddListener(() => { CastShadows(lightIndex, true); });
|
|
//CastShadowsOFFButton.onClick.AddListener(() => { CastShadows(lightIndex, false); });
|
|
#endregion
|
|
|
|
Spread(lightIndex);
|
|
SpotLightSoftnessUpdate(lightIndex);
|
|
SphereLightUpdateColor(lightIndex);
|
|
|
|
SaveLightData(lightIndex);
|
|
}
|
|
|
|
public void SpotLightSoftnessUpdate(int lightIndex)
|
|
{
|
|
if (SpotLightIsActive[lightIndex])
|
|
{
|
|
spotlightSoftnessSlider.interactable = true;
|
|
lightData[lightIndex].innerSpotPercent = spotlightSoftnessSlider.value;
|
|
}
|
|
else if (SpotLightIsActive[lightIndex] == false)
|
|
{
|
|
spotlightSoftnessSlider.interactable = false;
|
|
}
|
|
}
|
|
|
|
public void Spread(int lightIndex)
|
|
{
|
|
if (SpotLightIsActive[lightIndex])
|
|
{
|
|
lightSpreadSlider.interactable = true;
|
|
float spread = lightSpreadSlider.value * 25f;
|
|
lightData[lightIndex].SetSpotAngle(spread);
|
|
|
|
//3D Gizmos:
|
|
spotLight3DGizmos[lightIndex].SpotLight3DGizmosScaleUpdate();
|
|
spotLight3DGizmos[lightIndex].spotLight3DGizmosScale = lightSpreadSlider.value -0.5f;
|
|
spotLight3DGizmos[lightIndex].UpdateSpotLight3DGizmosColor(Color.HSVToRGB(colorSlider.value, colorIntensitySlider.value, 1)); //Updates the Color of Spotlight's 3D Gizmos.
|
|
}
|
|
else if(SpotLightIsActive[lightIndex] == false)
|
|
{
|
|
lightSpreadSlider.interactable = false;
|
|
}
|
|
}
|
|
|
|
public void SphereLightUpdateColor(int lightIndex)
|
|
{
|
|
if (sphereLight3DGizmosIsAdded[lightIndex])
|
|
{
|
|
sphereLight3DGizmos[lightIndex].UpdateSphereLight3DGizmosColor(Color.HSVToRGB(colorSlider.value, colorIntensitySlider.value, 1));
|
|
}
|
|
}
|
|
|
|
public void NextLightType()
|
|
{
|
|
print("Next selected light");
|
|
lightTypeIndex[selectedLightIndex - 1] += 1;
|
|
if (lightTypeIndex[selectedLightIndex - 1] > 1)
|
|
{
|
|
lightTypeIndex[selectedLightIndex - 1] = 0;
|
|
}
|
|
LightTypeUpdate(selectedLightIndex -1);
|
|
}
|
|
public void PreviousLightType()
|
|
{
|
|
print("Previous selected light");
|
|
lightTypeIndex[selectedLightIndex - 1] -= 1;
|
|
if (lightTypeIndex[selectedLightIndex - 1] < 0)
|
|
{
|
|
lightTypeIndex[selectedLightIndex - 1] = 1;
|
|
}
|
|
LightTypeUpdate(selectedLightIndex -1);
|
|
}
|
|
|
|
void LightTypeUpdate(int lightIndex)
|
|
{
|
|
switch (lightTypeIndex[selectedLightIndex - 1])
|
|
{
|
|
case 0:
|
|
lightData[lightIndex].SetLightTypeAndShape(HDLightTypeAndShape.Point);
|
|
SpotLightIsActive[lightIndex] = false;
|
|
//Lights[lightIndex].GetComponentInChildren<SpotLight3DGizmos>().DisableSpotLightGizmos();
|
|
if (!spotLight3DGizmosIsAdded[lightIndex])
|
|
{
|
|
spotLight3DGizmos[lightIndex] = Lights[lightIndex].GetComponentInChildren<SpotLight3DGizmos>();
|
|
spotLight3DGizmosIsAdded[lightIndex] = true;
|
|
}
|
|
if (sphereLight3DGizmosIsAdded[lightIndex] == false)
|
|
{
|
|
sphereLight3DGizmosIsAdded[lightIndex] = true;
|
|
}
|
|
sphereLight3DGizmos[lightIndex].EnableSphereLightGizmos();
|
|
spotLight3DGizmos[lightIndex].DisableSpotLightGizmos();
|
|
lightData[lightIndex].gameObject.GetComponent<SpotLightMovement>().enabled = false;
|
|
LightTypeText.text = "Sphere light";
|
|
break;
|
|
case 1:
|
|
lightData[lightIndex].SetLightTypeAndShape(HDLightTypeAndShape.ConeSpot);
|
|
SpotLightIsActive[lightIndex] = true;
|
|
//Lights[lightIndex].GetComponentInChildren<SpotLight3DGizmos>().EnableSpotLightGizmos();
|
|
if (!spotLight3DGizmosIsAdded[lightIndex])
|
|
{
|
|
spotLight3DGizmos[lightIndex] = Lights[lightIndex].GetComponentInChildren<SpotLight3DGizmos>();
|
|
spotLight3DGizmosIsAdded[lightIndex] = true;
|
|
}
|
|
if (sphereLight3DGizmosIsAdded[lightIndex])
|
|
{
|
|
sphereLight3DGizmosIsAdded[lightIndex] = false;
|
|
}
|
|
sphereLight3DGizmos[lightIndex].DisableSphereLightGizmos();
|
|
spotLight3DGizmos[lightIndex].EnableSpotLightGizmos();
|
|
lightData[lightIndex].gameObject.GetComponent<SpotLightMovement>().enabled = true;
|
|
LightTypeText.text = "Spot light";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void DisableCurrentSpotLightMovement()
|
|
{
|
|
if (lightIsActive[selectedLightIndex - 2] && selectedLightIndex - 2 >= 0 || selectedLightIndex - 2 >= 1 || selectedLightIndex - 2 >= 2 && selectedLightIndex != 3 || selectedLightIndex != 4 || selectedLightIndex != 0)
|
|
lightData[selectedLightIndex -1].gameObject.GetComponent<SpotLightMovement>().enabled = false;
|
|
}
|
|
|
|
public void SaveLightData(int lightIndex)
|
|
{
|
|
colorSlider_Light_DefaultValue[lightIndex] = colorSlider.value;
|
|
colorSliderIntensity_Light_DefaultValue[lightIndex] = colorIntensitySlider.value;
|
|
lightDistanceSlider_Light_DefaultValue[lightIndex] = lightDistanceSlider.value;
|
|
lightSpreadSlider_Light_DefaultValue[lightIndex] = lightSpreadSlider.value;
|
|
spotlightSoftnessSlider_Light_DefaultValue[lightIndex] = spotlightSoftnessSlider.value;
|
|
lightIntensitySlider_Light_DefaultValue[lightIndex] = lightIntensity.value;
|
|
|
|
if (lightShadowsIsActive[lightIndex])
|
|
{
|
|
lightData[lightIndex].EnableShadows(true);
|
|
}
|
|
else
|
|
{
|
|
lightData[lightIndex].EnableShadows(false);
|
|
}
|
|
}
|
|
|
|
public void LoadLightData(int lightIndex)
|
|
{
|
|
colorSlider.value = colorSlider_Light_DefaultValue[lightIndex];
|
|
colorIntensitySlider.value = colorSliderIntensity_Light_DefaultValue[lightIndex];
|
|
lightDistanceSlider.value = lightDistanceSlider_Light_DefaultValue[lightIndex];
|
|
lightSpreadSlider.value = lightSpreadSlider_Light_DefaultValue[lightIndex];
|
|
spotlightSoftnessSlider.value = spotlightSoftnessSlider_Light_DefaultValue[lightIndex];
|
|
lightIntensity.value = lightIntensitySlider_Light_DefaultValue[lightIndex];
|
|
|
|
if (lightShadowsIsActive[lightIndex])
|
|
{
|
|
lightData[lightIndex].EnableShadows(true);
|
|
CastShadowsONCheckUI.SetActive(true);
|
|
CastShadowsOFFCheckUI.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
lightData[lightIndex].EnableShadows(false);
|
|
CastShadowsONCheckUI.SetActive(false);
|
|
CastShadowsOFFCheckUI.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void CastShadowsON()
|
|
{
|
|
if (EditLight1)
|
|
{
|
|
CastShadows(0,true);
|
|
}
|
|
if (EditLight2)
|
|
{
|
|
CastShadows(1, true);
|
|
}
|
|
if (EditLight3)
|
|
{
|
|
CastShadows(2, true);
|
|
}
|
|
}
|
|
|
|
public void CastShadowsOFF()
|
|
{
|
|
if (EditLight1)
|
|
{
|
|
CastShadows(0, false);
|
|
}
|
|
if (EditLight2)
|
|
{
|
|
CastShadows(1, false);
|
|
}
|
|
if (EditLight3)
|
|
{
|
|
CastShadows(2, false);
|
|
}
|
|
}
|
|
|
|
void CastShadows(int LightIndex, bool EnableShadows)
|
|
{
|
|
lightData[LightIndex].EnableShadows(EnableShadows);
|
|
Debug.Log("Shadows enabled in" +LightIndex);
|
|
if (EnableShadows)
|
|
{
|
|
CastShadowsONCheckUI.SetActive(true);
|
|
CastShadowsOFFCheckUI.SetActive(false);
|
|
lightShadowsIsActive[LightIndex] = true;
|
|
}
|
|
else
|
|
{
|
|
CastShadowsONCheckUI.SetActive(false);
|
|
CastShadowsOFFCheckUI.SetActive(true);
|
|
lightShadowsIsActive[LightIndex] = false;
|
|
}
|
|
}
|
|
|
|
public void ResetSettings()
|
|
{
|
|
NaturalLightMovement.GetInstance().RestoreDirectionalLightDefaultValues();
|
|
StartCoroutine(DeleteLights());
|
|
for (int i = 0; i < lightONCheckUI.Count; i++)
|
|
{
|
|
lightONCheckUI[i].SetActive(false);
|
|
lightOFFCheckUI[i].SetActive(true);
|
|
}
|
|
ValuesInitialized = false;
|
|
lightModeState = LightModeStates.None;
|
|
selectedLightState = SelectedLight.None;
|
|
SelectLightOrEditLightIndex = 0;
|
|
StartCoroutine(AfterResetSettings());
|
|
}
|
|
|
|
IEnumerator AfterResetSettings()
|
|
{
|
|
yield return new WaitForSecondsRealtime(0.01f);
|
|
if (PhotomodeManager.GetInstance().IsInLightMode)
|
|
{
|
|
lightModeState = LightModeStates.SelectALight;
|
|
LightModeSelectALight_Mode();
|
|
}
|
|
}
|
|
|
|
//public void UpdateLightsGUI3D_TRUE()
|
|
//{
|
|
// UpdateLightsGUI3D = true;
|
|
//}
|
|
|
|
//public void UpdateLightsGUI3D_FALSE()
|
|
//{
|
|
// UpdateLightsGUI3D = false;
|
|
//}
|
|
|
|
//public void ColorValueChangeCheck()
|
|
//{
|
|
// colorSlider.color = Color.HSVToRGB(colorSlider.value, 1, 1);
|
|
//}
|
|
#endregion
|
|
}
|