From 0bdd7b001db11a3992ff9a5a07aac29702865f06 Mon Sep 17 00:00:00 2001 From: Morgan Coyaux Date: Thu, 17 Oct 2024 23:28:27 +0200 Subject: [PATCH 1/5] Add MapEditorReborn Tools Menu with methods to affect the current selection --- .../SchematicHelper/SchematicHelper.cs | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Assets/DONT TOUCH/Scripts/SchematicHelper/SchematicHelper.cs diff --git a/Assets/DONT TOUCH/Scripts/SchematicHelper/SchematicHelper.cs b/Assets/DONT TOUCH/Scripts/SchematicHelper/SchematicHelper.cs new file mode 100644 index 0000000..ed50e18 --- /dev/null +++ b/Assets/DONT TOUCH/Scripts/SchematicHelper/SchematicHelper.cs @@ -0,0 +1,79 @@ +using UnityEditor; + +[InitializeOnLoad] +public class SchematicHelper : EditorWindow +{ + static SchematicHelper() + { + + } + + #region Selection + [MenuItem("MapEditorReborn Tools/Selection/Set Static")] + private static void SetStaticSelected() + { + EditorApplication.Beep(); + foreach (var go in Selection.gameObjects) + { + go.isStatic = true; + } + } + + [MenuItem("MapEditorReborn Tools/Selection/Set Dynamic")] + private static void SetDynamicSelected() + { + foreach (var go in Selection.gameObjects) + { + go.isStatic = false; + } + } + + [MenuItem("MapEditorReborn Tools/Selection/Set Collidable")] + private static void SetCollidableSelected() + { + foreach (var go in Selection.gameObjects) + { + if (go.TryGetComponent(out PrimitiveComponent collider)) + { + collider.Collidable = true; + } + } + } + + [MenuItem("MapEditorReborn Tools/Selection/Set Non-Collidable")] + private static void SetNonCollidableSelected() + { + foreach (var go in Selection.gameObjects) + { + if (go.TryGetComponent(out PrimitiveComponent collider)) + { + collider.Collidable = false; + } + } + } + + [MenuItem("MapEditorReborn Tools/Selection/Set Visible")] + private static void SetVisibleSelected() + { + foreach (var go in Selection.gameObjects) + { + if (go.TryGetComponent(out PrimitiveComponent collider)) + { + collider.Visible = true; + } + } + } + + [MenuItem("MapEditorReborn Tools/Selection/Set Invisible")] + private static void SetInvisibleSelected() + { + foreach (var go in Selection.gameObjects) + { + if (go.TryGetComponent(out PrimitiveComponent collider)) + { + collider.Visible = false; + } + } + } + #endregion +} \ No newline at end of file From 2e65343e1e70f936f1446b107c68e4b97a893387 Mon Sep 17 00:00:00 2001 From: Morgan Coyaux Date: Fri, 18 Oct 2024 04:43:59 +0200 Subject: [PATCH 2/5] add Static field on compile LightSource --- Assets/DONT TOUCH/Scripts/Schematic.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Assets/DONT TOUCH/Scripts/Schematic.cs b/Assets/DONT TOUCH/Scripts/Schematic.cs index 3784791..4addecd 100644 --- a/Assets/DONT TOUCH/Scripts/Schematic.cs +++ b/Assets/DONT TOUCH/Scripts/Schematic.cs @@ -80,6 +80,7 @@ public void CompileSchematic() { "Intensity", lightComponent.intensity }, { "Range", lightComponent.range }, { "Shadows", lightComponent.shadows != LightShadows.None }, + { "Static", lightComponent.gameObject.isStatic } }; } else // Empty transform From b21f9e847b68219870d14fa76727e7915c6ddfbb Mon Sep 17 00:00:00 2001 From: Morgan Coyaux Date: Sat, 19 Oct 2024 00:42:20 +0200 Subject: [PATCH 3/5] it was just a test but i forgot to remove it from the code --- Assets/DONT TOUCH/Scripts/SchematicHelper/SchematicHelper.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Assets/DONT TOUCH/Scripts/SchematicHelper/SchematicHelper.cs b/Assets/DONT TOUCH/Scripts/SchematicHelper/SchematicHelper.cs index ed50e18..07de243 100644 --- a/Assets/DONT TOUCH/Scripts/SchematicHelper/SchematicHelper.cs +++ b/Assets/DONT TOUCH/Scripts/SchematicHelper/SchematicHelper.cs @@ -12,7 +12,6 @@ static SchematicHelper() [MenuItem("MapEditorReborn Tools/Selection/Set Static")] private static void SetStaticSelected() { - EditorApplication.Beep(); foreach (var go in Selection.gameObjects) { go.isStatic = true; From c7ac287af066df86e13a00c6356cc46477b6dc02 Mon Sep 17 00:00:00 2001 From: Morgan Coyaux Date: Wed, 30 Oct 2024 22:19:39 +0100 Subject: [PATCH 4/5] Add audio source to blocktype enum and interpreter in compiler --- Assets/DONT TOUCH/Enums/BlockType.cs | 1 + Assets/DONT TOUCH/Scripts/Schematic.cs | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/Assets/DONT TOUCH/Enums/BlockType.cs b/Assets/DONT TOUCH/Enums/BlockType.cs index 0f7f8ad..fdcb9bf 100644 --- a/Assets/DONT TOUCH/Enums/BlockType.cs +++ b/Assets/DONT TOUCH/Enums/BlockType.cs @@ -8,4 +8,5 @@ Schematic = 5, Teleport = 6, Locker = 7, + AudioSource = 8, } diff --git a/Assets/DONT TOUCH/Scripts/Schematic.cs b/Assets/DONT TOUCH/Scripts/Schematic.cs index 4addecd..04ccb36 100644 --- a/Assets/DONT TOUCH/Scripts/Schematic.cs +++ b/Assets/DONT TOUCH/Scripts/Schematic.cs @@ -83,6 +83,21 @@ public void CompileSchematic() { "Static", lightComponent.gameObject.isStatic } }; } + // Audio Source + else if (obj.TryGetComponent(out AudioSource source)) + { + block.BlockType = BlockType.AudioSource; + block.Properties = new Dictionary + { + { "PlayOnAwake", source.playOnAwake }, + { "AudioPath", source.clip.name }, + { "Loop", source.loop }, + { "Volume", source.volume }, + { "IsSpatial", source.spatialBlend is 1f }, + { "MinDistance", source.minDistance }, + { "MaxDistance", source.maxDistance }, + }; + } else // Empty transform { obj.localScale = Vector3.one; From f105e4ad4375c4d97786eb6e154857721f7d79be Mon Sep 17 00:00:00 2001 From: Morgan Coyaux Date: Thu, 31 Oct 2024 09:59:18 +0100 Subject: [PATCH 5/5] add Audio source prefab --- Assets/Resources/Blocks/Audio Source.prefab | 130 ++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 Assets/Resources/Blocks/Audio Source.prefab diff --git a/Assets/Resources/Blocks/Audio Source.prefab b/Assets/Resources/Blocks/Audio Source.prefab new file mode 100644 index 0000000..392e16b --- /dev/null +++ b/Assets/Resources/Blocks/Audio Source.prefab @@ -0,0 +1,130 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &7279034928316163286 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7136889950038605761} + - component: {fileID: 451896642418324752} + m_Layer: 0 + m_Name: Audio Source + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7136889950038605761 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7279034928316163286} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!82 &451896642418324752 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7279034928316163286} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 0} + m_PlayOnAwake: 1 + m_Volume: 1 + m_Pitch: 1 + Loop: 0 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 9 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4