@@ -353,7 +353,7 @@ private static void CreateDescribePanel(GameObject parent)
353353 private static GameObject CreateManagers ( )
354354 {
355355 const string path = "JCS_Managers.prefab" ;
356- GameObject spawned = CreateHierarchyObject ( path ) ;
356+ GameObject spawned = CreateHierarchyObject ( path , true ) ;
357357
358358 Undo . RegisterCreatedObjectUndo ( spawned , "Create JCS Managers" ) ;
359359
@@ -367,7 +367,7 @@ private static GameObject CreateManagers()
367367 private static GameObject CreateSettings ( )
368368 {
369369 const string path = "JCS_Settings.prefab" ;
370- GameObject spawned = CreateHierarchyObject ( path ) ;
370+ GameObject spawned = CreateHierarchyObject ( path , true ) ;
371371
372372 Undo . RegisterCreatedObjectUndo ( spawned , "Create JCS Settings" ) ;
373373
@@ -381,7 +381,7 @@ private static GameObject CreateSettings()
381381 private static void CreateBGMPlayer ( )
382382 {
383383 const string path = "Sound/JCS_BGMPlayer.prefab" ;
384- GameObject spawned = CreateHierarchyObject ( path ) ;
384+ GameObject spawned = CreateHierarchyObject ( path , true ) ;
385385
386386 Undo . RegisterCreatedObjectUndo ( spawned , "Create BGM Player" ) ;
387387 }
@@ -393,7 +393,7 @@ private static void CreateBGMPlayer()
393393 private static void CreateDebugTools ( )
394394 {
395395 const string path = "Tools/JCS_Tools.prefab" ;
396- GameObject spawned = CreateHierarchyObject ( path ) ;
396+ GameObject spawned = CreateHierarchyObject ( path , true ) ;
397397
398398 Undo . RegisterCreatedObjectUndo ( spawned , "Create Debug Tools" ) ;
399399 }
@@ -426,7 +426,7 @@ private static GameObject CreateJCSCanvas()
426426 {
427427 /* Canvas */
428428 const string path = "UI/JCS_Canvas.prefab" ;
429- GameObject canvasObj = CreateHierarchyObject ( path ) ;
429+ GameObject canvasObj = CreateHierarchyObject ( path , true ) ;
430430
431431 var canvas = canvasObj . GetComponent < Canvas > ( ) ;
432432 {
@@ -443,7 +443,7 @@ private static GameObject CreateJCSCanvas()
443443
444444 /* Event System */
445445 const string esPath = "UI/EventSystem.prefab" ;
446- GameObject evtSystemObj = CreateHierarchyObject ( esPath ) ;
446+ GameObject evtSystemObj = CreateHierarchyObject ( esPath , true ) ;
447447
448448 Undo . RegisterCreatedObjectUndo ( evtSystemObj , "Create Event System" ) ;
449449
@@ -515,7 +515,7 @@ private static void UpdateJCSUnity()
515515 private static GameObject Create2DCurosr ( )
516516 {
517517 const string path = "UI/JCS_2DCursor.prefab" ;
518- GameObject spawned = CreateHierarchyObject ( path ) ;
518+ GameObject spawned = CreateHierarchyObject ( path , true ) ;
519519
520520 Undo . RegisterCreatedObjectUndo ( spawned , "Create 3D Cursor" ) ;
521521
@@ -530,7 +530,7 @@ private static GameObject Create2DCurosr()
530530 private static GameObject Create3DCurosr ( )
531531 {
532532 const string path = "UI/JCS_3DCursor.prefab" ;
533- GameObject spawned = CreateHierarchyObject ( path ) ;
533+ GameObject spawned = CreateHierarchyObject ( path , true ) ;
534534
535535 Undo . RegisterCreatedObjectUndo ( spawned , "Create 3D Cursor" ) ;
536536
@@ -662,7 +662,7 @@ private static void CreateSlidePanel()
662662 }
663663
664664 const string slideScreenCameraPath = "Camera/JCS_2DSlideScreenCamera.prefab" ;
665- var slideScreenCamera = CreateHierarchyObject ( slideScreenCameraPath ) . GetComponent < JCS_2DSlideScreenCamera > ( ) ;
665+ var slideScreenCamera = CreateHierarchyObject ( slideScreenCameraPath , false ) . GetComponent < JCS_2DSlideScreenCamera > ( ) ;
666666
667667 Undo . RegisterCreatedObjectUndo ( slideScreenCamera , "Create 2D Slide Screen Camera" ) ;
668668
@@ -706,7 +706,7 @@ private static GameObject CreateTweenPanel()
706706 private static GameObject CreateUndoRedoSystem ( )
707707 {
708708 const string path = "UI/JCS_UndoRedoSystem.prefab" ;
709- GameObject spawned = CreateHierarchyObject ( path ) ;
709+ GameObject spawned = CreateHierarchyObject ( path , false ) ;
710710
711711 Undo . RegisterCreatedObjectUndo ( spawned , "Create Undo Redo System" ) ;
712712
@@ -726,7 +726,7 @@ private static GameObject CreateUndoRedoSystem()
726726 private static void Create2DCamera ( )
727727 {
728728 const string path = "Camera/JCS_2DCamera.prefab" ;
729- GameObject spawned = CreateHierarchyObject ( path ) ;
729+ GameObject spawned = CreateHierarchyObject ( path , false ) ;
730730
731731 // set camera depth to default -10.
732732 spawned . transform . position = new Vector3 ( 0 , 0 , - 10 ) ;
@@ -740,7 +740,7 @@ private static void Create2DCamera()
740740 private static void CreateMixDamageTextPool ( )
741741 {
742742 const string path = "UI/DamageText/JCS_MixDamageTextPool.prefab" ;
743- GameObject spawned = CreateHierarchyObject ( path ) ;
743+ GameObject spawned = CreateHierarchyObject ( path , false ) ;
744744
745745 Undo . RegisterCreatedObjectUndo ( spawned , "Create Min Damage Text Pool" ) ;
746746 }
@@ -756,7 +756,7 @@ private static void CreateMixDamageTextPool()
756756 private static void Create3DCamera ( )
757757 {
758758 const string path = "Camera/JCS_3DCamera.prefab" ;
759- GameObject spawned = CreateHierarchyObject ( path ) ;
759+ GameObject spawned = CreateHierarchyObject ( path , false ) ;
760760
761761 Undo . RegisterCreatedObjectUndo ( spawned , "Create JCS 3D Camera" ) ;
762762 }
@@ -778,12 +778,21 @@ private static T LoadAssetAtPath<T>(string path)
778778 /// <summary>
779779 /// Create the Game Object during editing time.
780780 /// </summary>
781- private static GameObject CreateHierarchyObject ( string path )
781+ private static GameObject CreateHierarchyObject ( string path , bool prefab )
782782 {
783- var obj = LoadAssetAtPath < GameObject > ( path ) ;
783+ var obj = LoadAssetAtPath < Object > ( path ) ;
784784
785785 // spawn the game object.
786- GameObject spawned = Instantiate ( obj ) ;
786+ GameObject spawned ;
787+
788+ if ( prefab )
789+ {
790+ spawned = PrefabUtility . InstantiatePrefab ( obj ) as GameObject ;
791+ }
792+ else
793+ {
794+ spawned = Instantiate ( obj ) as GameObject ;
795+ }
787796
788797 // take away clone sign.
789798 JCS_Util . RemoveCloneString ( spawned ) ;
@@ -824,7 +833,7 @@ private static GameObject CreateHierarchyObjectUnderCanvas(string settingPath, J
824833 }
825834
826835 // spawn the object first.
827- GameObject hierarchyObj = CreateHierarchyObject ( settingPath ) ;
836+ GameObject hierarchyObj = CreateHierarchyObject ( settingPath , false ) ;
828837
829838 // set the canvas as parent.
830839 hierarchyObj . transform . SetParent ( canvas . transform ) ;
0 commit comments