modify component requirements.

This commit is contained in:
hecomi
2016-11-16 02:07:57 +09:00
parent 77c95ab1bb
commit e9c8b4e571
2 changed files with 11 additions and 7 deletions
+1 -2
View File
@@ -5,8 +5,7 @@ using System.Collections.Generic;
namespace uDesktopDuplication namespace uDesktopDuplication
{ {
[AddComponentMenu("uDesktopDuplication/Cursor"), [AddComponentMenu("uDesktopDuplication/Cursor"), RequireComponent(typeof(Texture))]
RequireComponent(typeof(Texture))]
public class Cursor : MonoBehaviour public class Cursor : MonoBehaviour
{ {
[SerializeField] Vector2 modelScale = Vector2.one; [SerializeField] Vector2 modelScale = Vector2.one;
+10 -5
View File
@@ -3,7 +3,7 @@
namespace uDesktopDuplication namespace uDesktopDuplication
{ {
[AddComponentMenu("uDesktopDuplication/Texture")] [AddComponentMenu("uDesktopDuplication/Texture"), RequireComponent(typeof(Cursor))]
public class Texture : MonoBehaviour public class Texture : MonoBehaviour
{ {
private Monitor monitor_; private Monitor monitor_;
@@ -105,10 +105,7 @@ public class Texture : MonoBehaviour
void Awake() void Awake()
{ {
if (!GetComponent<Cursor>()) AddCursorIfNotAttached();
{
gameObject.AddComponent<Cursor>();
}
} }
void OnEnable() void OnEnable()
@@ -130,6 +127,14 @@ public class Texture : MonoBehaviour
UpdateMaterial(); UpdateMaterial();
} }
void AddCursorIfNotAttached()
{
if (!GetComponent<Cursor>())
{
gameObject.AddComponent<Cursor>();
}
}
void Reinitialize() void Reinitialize()
{ {
// Monitor instance is released here when initialized. // Monitor instance is released here when initialized.