From e9c8b4e5714ac887fdc85fa890fd894cc70eb4e7 Mon Sep 17 00:00:00 2001 From: hecomi Date: Wed, 16 Nov 2016 02:07:57 +0900 Subject: [PATCH] modify component requirements. --- Assets/uDesktopDuplication/Scripts/Cursor.cs | 3 +-- Assets/uDesktopDuplication/Scripts/Texture.cs | 15 ++++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Assets/uDesktopDuplication/Scripts/Cursor.cs b/Assets/uDesktopDuplication/Scripts/Cursor.cs index a918a4c..cd63397 100644 --- a/Assets/uDesktopDuplication/Scripts/Cursor.cs +++ b/Assets/uDesktopDuplication/Scripts/Cursor.cs @@ -5,8 +5,7 @@ using System.Collections.Generic; namespace uDesktopDuplication { -[AddComponentMenu("uDesktopDuplication/Cursor"), - RequireComponent(typeof(Texture))] +[AddComponentMenu("uDesktopDuplication/Cursor"), RequireComponent(typeof(Texture))] public class Cursor : MonoBehaviour { [SerializeField] Vector2 modelScale = Vector2.one; diff --git a/Assets/uDesktopDuplication/Scripts/Texture.cs b/Assets/uDesktopDuplication/Scripts/Texture.cs index 498a3fe..7ec2ffb 100644 --- a/Assets/uDesktopDuplication/Scripts/Texture.cs +++ b/Assets/uDesktopDuplication/Scripts/Texture.cs @@ -3,7 +3,7 @@ namespace uDesktopDuplication { -[AddComponentMenu("uDesktopDuplication/Texture")] +[AddComponentMenu("uDesktopDuplication/Texture"), RequireComponent(typeof(Cursor))] public class Texture : MonoBehaviour { private Monitor monitor_; @@ -105,10 +105,7 @@ public class Texture : MonoBehaviour void Awake() { - if (!GetComponent()) - { - gameObject.AddComponent(); - } + AddCursorIfNotAttached(); } void OnEnable() @@ -130,6 +127,14 @@ public class Texture : MonoBehaviour UpdateMaterial(); } + void AddCursorIfNotAttached() + { + if (!GetComponent()) + { + gameObject.AddComponent(); + } + } + void Reinitialize() { // Monitor instance is released here when initialized.