From 52b90c9ab87aab5558f74190b5da3d3095fa6046 Mon Sep 17 00:00:00 2001 From: tatsuhiko yamamura Date: Tue, 18 Nov 2014 14:28:54 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E3=82=B9=E3=83=86=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=82=92=E3=82=B7=E3=83=BC=E3=83=B3=E3=82=92=E5=86=8D=E7=94=9F?= =?UTF-8?q?=E3=81=9B=E3=81=9A=E3=81=A8=E3=82=82=E6=A7=8B=E7=AF=89=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scenes/Main.unity | 72 ++++++++++++--- .../UnityChanStage/Director/SetupDirector.cs | 87 +++++++++++++++++++ .../Director/SetupDirector.cs.meta | 8 ++ .../UnityChanStage/Director/StageDirector.cs | 28 ++---- .../Director/StageDirector.cs.meta | 0 5 files changed, 158 insertions(+), 37 deletions(-) mode change 100755 => 100644 Assets/Scenes/Main.unity create mode 100644 Assets/UnityChanStage/Director/SetupDirector.cs create mode 100644 Assets/UnityChanStage/Director/SetupDirector.cs.meta mode change 100755 => 100644 Assets/UnityChanStage/Director/StageDirector.cs.meta diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity old mode 100755 new mode 100644 index da0ef37b..ff59ef62 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -74,6 +74,60 @@ NavMeshSettings: widthInaccuracy: 16.666666 heightInaccuracy: 10 m_NavMesh: {fileID: 0} +--- !u!1 &1000416606 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1000416608} + - 114: {fileID: 1000416607} + m_Layer: 0 + m_Name: Scene Setup (Editor Only) + m_TagString: EditorOnly + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1000416607 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1000416606} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 22ae93bccfb6544be844049c8151b41a, type: 3} + m_Name: + m_EditorClassIdentifier: + cameraRigPrefab: {fileID: 100000, guid: 0f58e0fe394b24ed58b332f76fa9c423, type: 2} + musicPlayer: {fileID: 100000, guid: 2b9a716c1d31d45a5b906738bd5ee33e, type: 2} + objectNeedsActivation: + - {fileID: 100006, guid: db5cc803f9eaf4239ae82229a11bd471, type: 2} + - {fileID: 100270, guid: c2455b87c898eb646a195c31546b1481, type: 2} + objectsOnTimeline: + - {fileID: 100238, guid: 44374dd563c03d64aaff55a08495dd9f, type: 2} + - {fileID: 100000, guid: 6f8c40c56b04d4982ae56eadeeb099fb, type: 2} + mips: + - {fileID: 100000, guid: 0329b91dd79424babb86c8dbc3919134, type: 2} + - {fileID: 100000, guid: f468251a01e8242df8066e377619a712, type: 2} + - {fileID: 100000, guid: 0291ac2d4e1e54df6bfa4776e3683a24, type: 2} + - {fileID: 100000, guid: c70aff9297e6d4e9fa6e82c0038ded02, type: 2} + - {fileID: 100000, guid: f1efd132732334185ad79bc7263913ec, type: 2} + generatedItemList: [] +--- !u!4 &1000416608 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1000416606} + 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_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 --- !u!1 &1748610909 GameObject: m_ObjectHideFlags: 0 @@ -226,25 +280,15 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: ignoreFastForward: 1 - musicPlayerPrefab: {fileID: 100000, guid: 2b9a716c1d31d45a5b906738bd5ee33e, type: 2} - mainCameraRigPrefab: {fileID: 100000, guid: 0f58e0fe394b24ed58b332f76fa9c423, type: 2} - prefabsNeedsActivation: - - {fileID: 100006, guid: db5cc803f9eaf4239ae82229a11bd471, type: 2} - - {fileID: 100270, guid: c2455b87c898eb646a195c31546b1481, type: 2} - prefabsOnTimeline: - - {fileID: 100238, guid: 44374dd563c03d64aaff55a08495dd9f, type: 2} - - {fileID: 100000, guid: 6f8c40c56b04d4982ae56eadeeb099fb, type: 2} - miscPrefabs: - - {fileID: 100000, guid: 0329b91dd79424babb86c8dbc3919134, type: 2} - - {fileID: 100000, guid: f468251a01e8242df8066e377619a712, type: 2} - - {fileID: 100000, guid: f1efd132732334185ad79bc7263913ec, type: 2} - - {fileID: 100000, guid: c70aff9297e6d4e9fa6e82c0038ded02, type: 2} - - {fileID: 100000, guid: 0291ac2d4e1e54df6bfa4776e3683a24, type: 2} cameraPoints: - {fileID: 1750265709} - {fileID: 2112224815} - {fileID: 1821063586} overlayIntensity: 1 + musicPlayer: {fileID: 0} + objectsNeedsActivation: [] + objectsOnTimeline: [] + cameraRig: {fileID: 0} --- !u!4 &2134378501 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/UnityChanStage/Director/SetupDirector.cs b/Assets/UnityChanStage/Director/SetupDirector.cs new file mode 100644 index 00000000..d1774462 --- /dev/null +++ b/Assets/UnityChanStage/Director/SetupDirector.cs @@ -0,0 +1,87 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; + +public class SetupDirector : MonoBehaviour +{ +#if UNITY_EDITOR + [SerializeField] + private GameObject cameraRigPrefab, musicPlayer; + + [SerializeField] + private GameObject[] objectNeedsActivation = null, + objectsOnTimeline = null, + mips = null; + + [SerializePrivateVariables] + public List generatedItemList = new List(); + + [ContextMenu("Stage Setup")] + void Setup() + { + Clean(); + + var stageDirector = FindObjectOfType(); + if( stageDirector == null ) + { + Debug.LogWarning("Stage Director is not found"); + return; + } + + stageDirector.cameraRig = Instantate(cameraRigPrefab); + + stageDirector.musicPlayer = Instantate(musicPlayer); + + stageDirector.objectsNeedsActivation = Instantate(objectNeedsActivation); + stageDirector.objectsOnTimeline = Instantate(objectsOnTimeline); + Instantate(mips); + } + + [ContextMenu("Stage Clean")] + void Clean() + { + var stageDirector = FindObjectOfType(); + if( stageDirector == null ) + { + Debug.LogWarning("Stage Director is not found"); + return; + } + + foreach( var item in generatedItemList ) + DestroyImmediate(item); + + stageDirector.objectsOnTimeline = new GameObject[0]; + stageDirector.objectsNeedsActivation = new GameObject[0]; + stageDirector.cameraRig = null; + stageDirector.musicPlayer = null; + + generatedItemList.Clear(); + } + + public T Instantate(T obj) where T : Object + { + + T item; + + if( UnityEditor.EditorApplication.isPlaying ) + { + item = (T)GameObject.Instantiate(obj); + }else{ + item = (T)UnityEditor.PrefabUtility.InstantiatePrefab(obj); + } + generatedItemList.Add(item); + return item; + } + + public T[] Instantate(T[] obj) where T : Object + { + T[] item = new T[obj.Length]; + + for(int i=0; i(obj[i]); + } + return item; + } +#endif +} diff --git a/Assets/UnityChanStage/Director/SetupDirector.cs.meta b/Assets/UnityChanStage/Director/SetupDirector.cs.meta new file mode 100644 index 00000000..3bf13495 --- /dev/null +++ b/Assets/UnityChanStage/Director/SetupDirector.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 22ae93bccfb6544be844049c8151b41a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/UnityChanStage/Director/StageDirector.cs b/Assets/UnityChanStage/Director/StageDirector.cs index a30cc135..e873fd09 100755 --- a/Assets/UnityChanStage/Director/StageDirector.cs +++ b/Assets/UnityChanStage/Director/StageDirector.cs @@ -6,12 +6,6 @@ public class StageDirector : MonoBehaviour // Control options. public bool ignoreFastForward = true; - // Prefabs. - public GameObject musicPlayerPrefab; - public GameObject mainCameraRigPrefab; - public GameObject[] prefabsNeedsActivation; - public GameObject[] prefabsOnTimeline; - public GameObject[] miscPrefabs; // Camera points. public Transform[] cameraPoints; @@ -20,30 +14,18 @@ public class StageDirector : MonoBehaviour public float overlayIntensity = 1.0f; // Objects to be controlled. - GameObject musicPlayer; + public GameObject musicPlayer; CameraSwitcher mainCameraSwitcher; ScreenOverlay[] screenOverlays; - GameObject[] objectsNeedsActivation; - GameObject[] objectsOnTimeline; + public GameObject[] objectsNeedsActivation; + public GameObject[] objectsOnTimeline; + + public GameObject cameraRig; void Awake() { - // Instantiate the prefabs. - musicPlayer = (GameObject)Instantiate(musicPlayerPrefab); - - var cameraRig = (GameObject)Instantiate(mainCameraRigPrefab); mainCameraSwitcher = cameraRig.GetComponentInChildren(); screenOverlays = cameraRig.GetComponentsInChildren(); - - objectsNeedsActivation = new GameObject[prefabsNeedsActivation.Length]; - for (var i = 0; i < prefabsNeedsActivation.Length; i++) - objectsNeedsActivation[i] = (GameObject)Instantiate(prefabsNeedsActivation[i]); - - objectsOnTimeline = new GameObject[prefabsOnTimeline.Length]; - for (var i = 0; i < prefabsOnTimeline.Length; i++) - objectsOnTimeline[i] = (GameObject)Instantiate(prefabsOnTimeline[i]); - - foreach (var p in miscPrefabs) Instantiate(p); } void Update() diff --git a/Assets/UnityChanStage/Director/StageDirector.cs.meta b/Assets/UnityChanStage/Director/StageDirector.cs.meta old mode 100755 new mode 100644 From b1875044a7f4bd9ca52d569d75e64123ccb7f353 Mon Sep 17 00:00:00 2001 From: tatsuhiko yamamura Date: Tue, 18 Nov 2014 14:57:43 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E7=94=9F=E6=88=90=E6=B8=88=E3=81=BF?= =?UTF-8?q?=E3=82=AA=E3=83=96=E3=82=B8=E3=82=A7=E3=82=AF=E3=83=88=E7=BE=A4?= =?UTF-8?q?=E3=81=AE=E5=8F=82=E7=85=A7=E3=82=92=E9=9D=9E=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=AB=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/UnityChanStage/Director/SetupDirector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/UnityChanStage/Director/SetupDirector.cs b/Assets/UnityChanStage/Director/SetupDirector.cs index d1774462..fab3dfc5 100644 --- a/Assets/UnityChanStage/Director/SetupDirector.cs +++ b/Assets/UnityChanStage/Director/SetupDirector.cs @@ -13,7 +13,7 @@ public class SetupDirector : MonoBehaviour objectsOnTimeline = null, mips = null; - [SerializePrivateVariables] + [HideInInspector] public List generatedItemList = new List(); [ContextMenu("Stage Setup")]