mirror of
https://github.com/maxartz15/VolumetricLighting.git
synced 2025-06-27 13:06:06 +02:00
Added the project.
This commit is contained in:
62
Assets/TubeLight/Editor/TubeLightEditor.cs
Normal file
62
Assets/TubeLight/Editor/TubeLightEditor.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.AnimatedValues;
|
||||
|
||||
[CustomEditor(typeof(TubeLight))]
|
||||
[CanEditMultipleObjects]
|
||||
public class TubeLightEditor : Editor {
|
||||
|
||||
AnimFloat m_ShowInfo;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
m_ShowInfo = new AnimFloat(0);
|
||||
m_ShowInfo.valueChanged.AddListener(Repaint);
|
||||
m_ShowInfo.speed = 0.5f;
|
||||
}
|
||||
|
||||
override public void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
|
||||
if (targets.Length > 1)
|
||||
return;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
if(GUILayout.Button("Add a shadow plane"))
|
||||
m_ShowInfo.value = AddShadowPlane() ? 0 : 100;
|
||||
|
||||
foreach (TubeLightShadowPlane shadowPlane in ((TubeLight)target).m_ShadowPlanes)
|
||||
if (shadowPlane != null)
|
||||
EditorGUILayout.ObjectField("Shadow Plane", shadowPlane, typeof(TubeLightShadowPlane), !EditorUtility.IsPersistent(target));
|
||||
|
||||
m_ShowInfo.target = 0;
|
||||
if (EditorGUILayout.BeginFadeGroup(Mathf.Min(1.0f, m_ShowInfo.value)))
|
||||
EditorGUILayout.HelpBox("Limit of " + TubeLight.maxPlanes + " planes reached. Delete an existing one.", MessageType.Info);
|
||||
EditorGUILayout.EndFadeGroup();
|
||||
}
|
||||
|
||||
bool AddShadowPlane()
|
||||
{
|
||||
TubeLight tubeLight = (TubeLight)target;
|
||||
|
||||
int i = 0;
|
||||
for (; i < TubeLight.maxPlanes; i++)
|
||||
{
|
||||
if (tubeLight.m_ShadowPlanes[i] != null)
|
||||
continue;
|
||||
|
||||
GameObject go = new GameObject("Shadow Plane");
|
||||
TubeLightShadowPlane shadowPlane = go.AddComponent<TubeLightShadowPlane>();
|
||||
|
||||
go.transform.position = tubeLight.transform.position + go.transform.forward;
|
||||
go.transform.parent = tubeLight.transform;
|
||||
tubeLight.m_ShadowPlanes[i] = shadowPlane;
|
||||
EditorUtility.SetDirty (tubeLight);
|
||||
break;
|
||||
}
|
||||
|
||||
return i < TubeLight.maxPlanes;
|
||||
}
|
||||
}
|
12
Assets/TubeLight/Editor/TubeLightEditor.cs.meta
Normal file
12
Assets/TubeLight/Editor/TubeLightEditor.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00a6ee99a4a9a44879507a5c4077d7a0
|
||||
timeCreated: 1446582855
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user