From 3f29e95935f2a48eb71faf34746abffde8783ff6 Mon Sep 17 00:00:00 2001 From: Ju Hwijung Date: Wed, 4 May 2022 09:17:19 +0900 Subject: [PATCH] Add own GetOrAdd method. Remove unnecessary using directives. --- .../EZ2Screenshot/Editor/EZ2ScreenshotWindow.cs | 5 ----- .../Scripts/EZ2ScreenshotGameObjectExtension.cs | 14 ++++++++++++++ .../EZ2ScreenshotGameObjectExtension.cs.meta | 11 +++++++++++ .../Scripts/EZ2ScreenshotLocalizer.cs | 1 - .../EZ2Screenshot/Scripts/EZ2ScreenshotObject.cs | 3 --- 5 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotGameObjectExtension.cs create mode 100644 Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotGameObjectExtension.cs.meta diff --git a/Assets/JB STUDIO/EZ2Screenshot/Editor/EZ2ScreenshotWindow.cs b/Assets/JB STUDIO/EZ2Screenshot/Editor/EZ2ScreenshotWindow.cs index 29ddc2a..bfd453f 100644 --- a/Assets/JB STUDIO/EZ2Screenshot/Editor/EZ2ScreenshotWindow.cs +++ b/Assets/JB STUDIO/EZ2Screenshot/Editor/EZ2ScreenshotWindow.cs @@ -1,11 +1,6 @@ using System; -using System.Collections; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; -using System.Web.WebPages; -using Unity.VisualScripting; using UnityEditor; using UnityEngine; using UnityEngine.SceneManagement; diff --git a/Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotGameObjectExtension.cs b/Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotGameObjectExtension.cs new file mode 100644 index 0000000..35cc447 --- /dev/null +++ b/Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotGameObjectExtension.cs @@ -0,0 +1,14 @@ +using UnityEngine; + +public static class EZ2ScreenshotGameObjectExtension +{ + public static T GetOrAddComponent(this GameObject go) where T : Component + { + T component = go.GetComponent(); + + if (component == null) + component = go.AddComponent(); + + return component; + } +} \ No newline at end of file diff --git a/Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotGameObjectExtension.cs.meta b/Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotGameObjectExtension.cs.meta new file mode 100644 index 0000000..a7e6d16 --- /dev/null +++ b/Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotGameObjectExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: aa366d324677189448a7bab912026b0e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotLocalizer.cs b/Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotLocalizer.cs index 4a7492d..3289b7a 100644 --- a/Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotLocalizer.cs +++ b/Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotLocalizer.cs @@ -1,4 +1,3 @@ -using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; diff --git a/Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotObject.cs b/Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotObject.cs index d3785ec..f5d6db6 100644 --- a/Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotObject.cs +++ b/Assets/JB STUDIO/EZ2Screenshot/Scripts/EZ2ScreenshotObject.cs @@ -1,9 +1,6 @@ -using System; using System.Collections; -using System.Collections.Generic; using System.IO; using UnityEngine; -using UnityEngine.Rendering; [RequireComponent(typeof(Camera))] public class EZ2ScreenshotObject : MonoBehaviour