diff options
author | tylermurphy534 <tylermurphy534@gmail.com> | 2022-11-06 15:12:42 -0500 |
---|---|---|
committer | tylermurphy534 <tylermurphy534@gmail.com> | 2022-11-06 15:12:42 -0500 |
commit | eb84bb298d2b95aec7b2ae12cbf25ac64f25379a (patch) | |
tree | efd616a157df06ab661c6d56651853431ac6b08b /VRCSDK3Worlds/Assets/Bakery/BakeryLightMesh.cs | |
download | unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.tar.gz unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.tar.bz2 unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.zip |
move to self host
Diffstat (limited to '')
-rw-r--r-- | VRCSDK3Worlds/Assets/Bakery/BakeryLightMesh.cs | 83 | ||||
-rw-r--r-- | VRCSDK3Worlds/Assets/Bakery/BakeryLightMesh.cs.meta | 12 |
2 files changed, 95 insertions, 0 deletions
diff --git a/VRCSDK3Worlds/Assets/Bakery/BakeryLightMesh.cs b/VRCSDK3Worlds/Assets/Bakery/BakeryLightMesh.cs new file mode 100644 index 00000000..77c2ed42 --- /dev/null +++ b/VRCSDK3Worlds/Assets/Bakery/BakeryLightMesh.cs @@ -0,0 +1,83 @@ +using UnityEngine; + +#if UNITY_EDITOR +using UnityEditor; +#endif + +using System; +using System.Collections; +using System.Collections.Generic; + +[ExecuteInEditMode] +[DisallowMultipleComponent] +public class BakeryLightMesh : MonoBehaviour +{ + public int UID; + + public Color color = Color.white; + public float intensity = 1.0f; + public Texture2D texture = null; + public float cutoff = 100; + public int samples = 256; + public int samples2 = 16; + public int bitmask = 1; + public bool selfShadow = true; + public bool bakeToIndirect = true; + public float indirectIntensity = 1.0f; + + public int lmid = -2; + + public static int lightsChanged = 0; + +#if UNITY_EDITOR + void OnValidate() + { + if (lightsChanged == 0) lightsChanged = 1; + } + + public void Start() + { + if (gameObject.GetComponent<BakeryDirectLight>() != null || + gameObject.GetComponent<BakeryPointLight>() != null || + gameObject.GetComponent<BakerySkyLight>() != null) + { + EditorUtility.DisplayDialog("Bakery", "Can't have more than one Bakery light on one object", "OK"); + DestroyImmediate(this); + return; + } + + if (EditorApplication.isPlayingOrWillChangePlaymode) return; + + if (UID == 0) UID = Guid.NewGuid().GetHashCode(); + ftUniqueIDRegistry.Register(UID, gameObject.GetInstanceID()); + } + + void OnDestroy() + { + if (UID == 0) return; + if (EditorApplication.isPlayingOrWillChangePlaymode) return; + ftUniqueIDRegistry.Deregister(UID); + } + + void Update() + { + if (EditorApplication.isPlayingOrWillChangePlaymode) return; + if (!ftUniqueIDRegistry.Mapping.ContainsKey(UID)) ftUniqueIDRegistry.Register(UID, gameObject.GetInstanceID()); + if (gameObject.GetInstanceID() != ftUniqueIDRegistry.GetInstanceId(UID)) + { + UID = Guid.NewGuid().GetHashCode(); + ftUniqueIDRegistry.Register(UID, gameObject.GetInstanceID()); + } + } +#endif + + void OnDrawGizmosSelected() + { + Gizmos.color = Color.yellow; + var mr = gameObject.GetComponent<MeshRenderer>(); + if (mr!=null) Gizmos.DrawWireSphere(mr.bounds.center, cutoff); + } +} + + + diff --git a/VRCSDK3Worlds/Assets/Bakery/BakeryLightMesh.cs.meta b/VRCSDK3Worlds/Assets/Bakery/BakeryLightMesh.cs.meta new file mode 100644 index 00000000..ee2a563d --- /dev/null +++ b/VRCSDK3Worlds/Assets/Bakery/BakeryLightMesh.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a28e27cacfc7e70479097f0a63c37217 +timeCreated: 1526382158 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |