@@ -264,7 +264,7 @@ private void Part_Project()
264264 /* List of project sub folders. */
265265 {
266266 ScriptableObject target = this ;
267- SerializedObject so = new SerializedObject ( target ) ;
267+ var so = new SerializedObject ( target ) ;
268268 SerializedProperty stringsProperty = so . FindProperty ( "ProjectSubFolders" ) ;
269269
270270 EditorGUILayout . PropertyField ( stringsProperty , true ) ;
@@ -336,14 +336,14 @@ private static void ConvertTo3D()
336336
337337 private static void CreateDescribePanel ( GameObject parent )
338338 {
339- const string desc_path = "UI/JCS Describe Panel" ;
339+ const string path = "UI/JCS Describe Panel.prefab " ;
340340
341- GameObject desc_obj = JCS_Util . Instantiate ( desc_path ) ;
342- JCS_Util . RemoveCloneString ( desc_obj ) ;
341+ GameObject spawned = JCS_Util . Instantiate ( path ) ;
342+ JCS_Util . RemoveCloneString ( spawned ) ;
343343
344- desc_obj . transform . SetParent ( parent . transform ) ;
345- desc_obj . transform . localPosition = Vector3 . zero ;
346- desc_obj . transform . localScale = Vector3 . one ;
344+ spawned . transform . SetParent ( parent . transform ) ;
345+ spawned . transform . localPosition = Vector3 . zero ;
346+ spawned . transform . localScale = Vector3 . one ;
347347 }
348348
349349 /// <summary>
@@ -352,12 +352,12 @@ private static void CreateDescribePanel(GameObject parent)
352352 [ MenuItem ( MI_BaseName + "/Basic/Create Managers" , false , MI_BasePriority + 10 ) ]
353353 private static GameObject CreateManagers ( )
354354 {
355- const string manager_path = "JCS_Managers" ;
356- GameObject gameObj = CreateHierarchyObject ( manager_path ) ;
355+ const string path = "JCS_Managers.prefab " ;
356+ GameObject spawned = CreateHierarchyObject ( path ) ;
357357
358- Undo . RegisterCreatedObjectUndo ( gameObj , "Create JCS Managers" ) ;
358+ Undo . RegisterCreatedObjectUndo ( spawned , "Create JCS Managers" ) ;
359359
360- return gameObj ;
360+ return spawned ;
361361 }
362362
363363 /// <summary>
@@ -366,12 +366,12 @@ private static GameObject CreateManagers()
366366 [ MenuItem ( MI_BaseName + "/Basic/Create Settings" , false , MI_BasePriority + 10 ) ]
367367 private static GameObject CreateSettings ( )
368368 {
369- const string setting_path = "JCS_Settings" ;
370- GameObject gameObj = CreateHierarchyObject ( setting_path ) ;
369+ const string path = "JCS_Settings.prefab " ;
370+ GameObject spawned = CreateHierarchyObject ( path ) ;
371371
372- Undo . RegisterCreatedObjectUndo ( gameObj , "Create JCS Settings" ) ;
372+ Undo . RegisterCreatedObjectUndo ( spawned , "Create JCS Settings" ) ;
373373
374- return gameObj ;
374+ return spawned ;
375375 }
376376
377377 /// <summary>
@@ -380,10 +380,10 @@ private static GameObject CreateSettings()
380380 [ MenuItem ( MI_BaseName + "/Basic/Create BGM Player" , false , MI_BasePriority + 11 ) ]
381381 private static void CreateBGMPlayer ( )
382382 {
383- const string player_path = "Sound/JCS_BGMPlayer" ;
384- GameObject gameObj = CreateHierarchyObject ( player_path ) ;
383+ const string path = "Sound/JCS_BGMPlayer.prefab " ;
384+ GameObject spawned = CreateHierarchyObject ( path ) ;
385385
386- Undo . RegisterCreatedObjectUndo ( gameObj , "Create BGM Player" ) ;
386+ Undo . RegisterCreatedObjectUndo ( spawned , "Create BGM Player" ) ;
387387 }
388388
389389 /// <summary>
@@ -392,10 +392,10 @@ private static void CreateBGMPlayer()
392392 [ MenuItem ( MI_BaseName + "/Basic/Create Debug Tools" , false , MI_BasePriority + 12 ) ]
393393 private static void CreateDebugTools ( )
394394 {
395- const string tools_path = "Tools/JCS_Tools" ;
396- GameObject gameObj = CreateHierarchyObject ( tools_path ) ;
395+ const string path = "Tools/JCS_Tools.prefab " ;
396+ GameObject spawned = CreateHierarchyObject ( path ) ;
397397
398- Undo . RegisterCreatedObjectUndo ( gameObj , "Create Debug Tools" ) ;
398+ Undo . RegisterCreatedObjectUndo ( spawned , "Create Debug Tools" ) ;
399399 }
400400
401401 /// <summary>
@@ -425,8 +425,8 @@ private static void RevertDefaultInputManager()
425425 private static GameObject CreateJCSCanvas ( )
426426 {
427427 /* Canvas */
428- const string canvas_path = "UI/JCS_Canvas" ;
429- GameObject canvasObj = CreateHierarchyObject ( canvas_path ) ;
428+ const string path = "UI/JCS_Canvas.prefab " ;
429+ GameObject canvasObj = CreateHierarchyObject ( path ) ;
430430
431431 var canvas = canvasObj . GetComponent < Canvas > ( ) ;
432432 {
@@ -442,8 +442,8 @@ private static GameObject CreateJCSCanvas()
442442 Undo . RegisterCreatedObjectUndo ( canvasObj , "Create JCS Canvas" ) ;
443443
444444 /* Event System */
445- const string eventSystem_path = "UI/EventSystem" ;
446- GameObject evtSystemObj = CreateHierarchyObject ( eventSystem_path ) ;
445+ const string esPath = "UI/EventSystem.prefab " ;
446+ GameObject evtSystemObj = CreateHierarchyObject ( esPath ) ;
447447
448448 Undo . RegisterCreatedObjectUndo ( evtSystemObj , "Create Event System" ) ;
449449
@@ -514,29 +514,29 @@ private static void UpdateJCSUnity()
514514 /// </summary>
515515 private static GameObject Create2DCurosr ( )
516516 {
517- const string setting_path = "UI/JCS_2DCursor" ;
518- GameObject gameObj = CreateHierarchyObject ( setting_path ) ;
517+ const string path = "UI/JCS_2DCursor.prefab " ;
518+ GameObject spawned = CreateHierarchyObject ( path ) ;
519519
520- Undo . RegisterCreatedObjectUndo ( gameObj , "Create 3D Cursor" ) ;
520+ Undo . RegisterCreatedObjectUndo ( spawned , "Create 3D Cursor" ) ;
521521
522- gameObj . name = "_2DCursor (Created)" ;
522+ spawned . name = "_2DCursor (Created)" ;
523523
524- return gameObj ;
524+ return spawned ;
525525 }
526526
527527 /// <summary>
528528 /// Create the cursor game object.
529529 /// </summary>
530530 private static GameObject Create3DCurosr ( )
531531 {
532- const string setting_path = "UI/JCS_3DCursor" ;
533- GameObject gameObj = CreateHierarchyObject ( setting_path ) ;
532+ const string path = "UI/JCS_3DCursor.prefab " ;
533+ GameObject spawned = CreateHierarchyObject ( path ) ;
534534
535- Undo . RegisterCreatedObjectUndo ( gameObj , "Create 3D Cursor" ) ;
535+ Undo . RegisterCreatedObjectUndo ( spawned , "Create 3D Cursor" ) ;
536536
537- gameObj . name = "_3DCursor (Created)" ;
537+ spawned . name = "_3DCursor (Created)" ;
538538
539- return gameObj ;
539+ return spawned ;
540540 }
541541
542542 /// <summary>
@@ -556,8 +556,8 @@ private static GameObject CreateBasePanel()
556556 return null ;
557557 }
558558
559- const string setting_path = "UI/JCS_BasePanel" ;
560- GameObject basePanel = CreateHierarchyObjectUnderCanvas ( setting_path ) ;
559+ const string path = "UI/JCS_BasePanel.prefab " ;
560+ GameObject basePanel = CreateHierarchyObjectUnderCanvas ( path ) ;
561561
562562 Undo . RegisterCreatedObjectUndo ( basePanel , "Create Base Panel" ) ;
563563
@@ -584,15 +584,15 @@ private static GameObject CreateDialoguePanel()
584584 return null ;
585585 }
586586
587- const string setting_path = "UI/JCS_DialoguePanel" ;
588- GameObject dialoguePanel = CreateHierarchyObjectUnderCanvas ( setting_path ) ;
587+ const string path = "UI/JCS_DialoguePanel.prefab " ;
588+ GameObject panel = CreateHierarchyObjectUnderCanvas ( path ) ;
589589
590- Undo . RegisterCreatedObjectUndo ( dialoguePanel , "Create Dialogue Panel" ) ;
590+ Undo . RegisterCreatedObjectUndo ( panel , "Create Dialogue Panel" ) ;
591591
592- dialoguePanel . transform . localScale = Vector3 . one ;
593- dialoguePanel . name = "_DialoguePanel (Created)" ;
592+ panel . transform . localScale = Vector3 . one ;
593+ panel . name = "_DialoguePanel (Created)" ;
594594
595- return dialoguePanel ;
595+ return panel ;
596596 }
597597
598598 /// <summary>
@@ -613,18 +613,18 @@ private static void CreateSlidePanel()
613613 return ;
614614 }
615615
616- const string settingPath = "UI/System/JCS_SlideScreenPanelHolder" ;
616+ const string path = "UI/System/JCS_SlideScreenPanelHolder.prefab " ;
617617
618618 // spawn the pane holder.
619- JCS_SlideScreenPanelHolder panelHolder9x9 = CreateHierarchyObjectUnderCanvas ( settingPath , canvas ) . GetComponent < JCS_SlideScreenPanelHolder > ( ) ;
619+ JCS_SlideScreenPanelHolder panelHolder9x9 = CreateHierarchyObjectUnderCanvas ( path , canvas ) . GetComponent < JCS_SlideScreenPanelHolder > ( ) ;
620620
621621 // create the array of panel.
622622 panelHolder9x9 . slidePanels = new RectTransform [ 9 ] ;
623623
624624 int starting_pos_x = - 1920 ;
625625 int starting_pos_y = 1080 ;
626626
627- const string slidePanelPath = "UI/System/JCS_SlidePanel" ;
627+ const string slidePanelPath = "UI/System/JCS_SlidePanel.prefab " ;
628628
629629 int index = 0 ;
630630
@@ -661,7 +661,7 @@ private static void CreateSlidePanel()
661661 }
662662 }
663663
664- const string slideScreenCameraPath = "Camera/JCS_2DSlideScreenCamera" ;
664+ const string slideScreenCameraPath = "Camera/JCS_2DSlideScreenCamera.prefab " ;
665665 var slideScreenCamera = CreateHierarchyObject ( slideScreenCameraPath ) . GetComponent < JCS_2DSlideScreenCamera > ( ) ;
666666
667667 Undo . RegisterCreatedObjectUndo ( slideScreenCamera , "Create 2D Slide Screen Camera" ) ;
@@ -688,15 +688,15 @@ private static GameObject CreateTweenPanel()
688688 return null ;
689689 }
690690
691- const string setting_path = "UI/JCS_TweenPanel" ;
692- GameObject tweenPanel = CreateHierarchyObjectUnderCanvas ( setting_path ) ;
691+ const string path = "UI/JCS_TweenPanel.prefab " ;
692+ GameObject spawned = CreateHierarchyObjectUnderCanvas ( path ) ;
693693
694- Undo . RegisterCreatedObjectUndo ( tweenPanel , "Create Tween Panel" ) ;
694+ Undo . RegisterCreatedObjectUndo ( spawned , "Create Tween Panel" ) ;
695695
696- tweenPanel . transform . localScale = Vector3 . one ;
697- tweenPanel . name = "_TweenPanel (Created)" ;
696+ spawned . transform . localScale = Vector3 . one ;
697+ spawned . name = "_TweenPanel (Created)" ;
698698
699- return tweenPanel ;
699+ return spawned ;
700700 }
701701
702702 /// <summary>
@@ -705,14 +705,14 @@ private static GameObject CreateTweenPanel()
705705 /// <returns></returns>
706706 private static GameObject CreateUndoRedoSystem ( )
707707 {
708- const string setting_path = "UI/JCS_UndoRedoSystem" ;
709- GameObject undoRedoSystem = CreateHierarchyObject ( setting_path ) ;
708+ const string path = "UI/JCS_UndoRedoSystem.prefab " ;
709+ GameObject spawned = CreateHierarchyObject ( path ) ;
710710
711- Undo . RegisterCreatedObjectUndo ( undoRedoSystem , "Create Undo Redo System" ) ;
711+ Undo . RegisterCreatedObjectUndo ( spawned , "Create Undo Redo System" ) ;
712712
713- undoRedoSystem . name = "_UndoRedoSystem (Created)" ;
713+ spawned . name = "_UndoRedoSystem (Created)" ;
714714
715- return undoRedoSystem ;
715+ return spawned ;
716716 }
717717
718718 /**
@@ -725,24 +725,24 @@ private static GameObject CreateUndoRedoSystem()
725725 /// </summary>
726726 private static void Create2DCamera ( )
727727 {
728- const string camera_path = "Camera/JCS_2DCamera" ;
729- GameObject gameObj = CreateHierarchyObject ( camera_path ) ;
728+ const string path = "Camera/JCS_2DCamera.prefab " ;
729+ GameObject spawned = CreateHierarchyObject ( path ) ;
730730
731731 // set camera depth to default -10.
732- gameObj . transform . position = new Vector3 ( 0 , 0 , - 10 ) ;
732+ spawned . transform . position = new Vector3 ( 0 , 0 , - 10 ) ;
733733
734- Undo . RegisterCreatedObjectUndo ( gameObj , "Create JCS 2D Camera" ) ;
734+ Undo . RegisterCreatedObjectUndo ( spawned , "Create JCS 2D Camera" ) ;
735735 }
736736
737737 /// <summary>
738738 /// Create a mix damage text pool.
739739 /// </summary>
740740 private static void CreateMixDamageTextPool ( )
741741 {
742- const string setting_path = "UI/DamageText/JCS_MixDamageTextPool" ;
743- GameObject gameObj = CreateHierarchyObject ( setting_path ) ;
742+ const string path = "UI/DamageText/JCS_MixDamageTextPool.prefab " ;
743+ GameObject spawned = CreateHierarchyObject ( path ) ;
744744
745- Undo . RegisterCreatedObjectUndo ( gameObj , "Create Min Damage Text Pool" ) ;
745+ Undo . RegisterCreatedObjectUndo ( spawned , "Create Min Damage Text Pool" ) ;
746746 }
747747
748748 /**
@@ -755,29 +755,40 @@ private static void CreateMixDamageTextPool()
755755 /// </summary>
756756 private static void Create3DCamera ( )
757757 {
758- const string camera_path = "Camera/JCS_3DCamera" ;
759- GameObject gameObj = CreateHierarchyObject ( camera_path ) ;
758+ const string path = "Camera/JCS_3DCamera.prefab " ;
759+ GameObject spawned = CreateHierarchyObject ( path ) ;
760760
761- Undo . RegisterCreatedObjectUndo ( gameObj , "Create JCS 3D Camera" ) ;
761+ Undo . RegisterCreatedObjectUndo ( spawned , "Create JCS 3D Camera" ) ;
762762 }
763763
764764 /**
765765 * Utils
766766 */
767767
768+ /// <summary>
769+ /// Like `AssetDatabase.LoadAssetAtPath` but redirect to
770+ /// framework's folder instead.
771+ /// </summary>
772+ private static T LoadAssetAtPath < T > ( string path )
773+ where T : Object
774+ {
775+ return AssetDatabase . LoadAssetAtPath < T > ( $ "Assets/JCSUnity/Prefabs/{ path } ") ;
776+ }
777+
768778 /// <summary>
769779 /// Create the Game Object during editing time.
770780 /// </summary>
771- /// <returns></returns>
772- private static GameObject CreateHierarchyObject ( string settingPath )
781+ private static GameObject CreateHierarchyObject ( string path )
773782 {
783+ var obj = LoadAssetAtPath < GameObject > ( path ) ;
784+
774785 // spawn the game object.
775- GameObject hierarchyObj = JCS_Util . Instantiate ( settingPath ) ;
786+ GameObject spawned = Instantiate ( obj ) ;
776787
777788 // take away clone sign.
778- JCS_Util . RemoveCloneString ( hierarchyObj ) ;
789+ JCS_Util . RemoveCloneString ( spawned ) ;
779790
780- return hierarchyObj ;
791+ return spawned ;
781792 }
782793
783794 /// <summary>
0 commit comments