Пример #1
0
        /// <summary>
        /// テンプレートをHierarchyに作成
        /// </summary>
        public static void SetTemplate()
        {
            NCMBUTRankingConnection connection = (NCMBUTRankingConnection)GameObject.FindObjectOfType(typeof(NCMBUTRankingConnection));

            if (connection == null)
            {
                GameObject prefab = (GameObject)PrefabUtility.InstantiatePrefab(Resources.Load("Prefabs/" + typeof(NCMBUTRankingConnection).Name, typeof(GameObject)));
                prefab.name = typeof(NCMBUTRankingConnection).Name;
                connection  = prefab.GetComponent <NCMBUTRankingConnection>();

                Undo.RegisterCreatedObjectUndo(prefab, "Create Prefab Object");
            }

            NCMBUTRankingTemplate template = (NCMBUTRankingTemplate)GameObject.FindObjectOfType(typeof(NCMBUTRankingTemplate));

            if (template == null)
            {
                GameObject go = new GameObject();
                go.name             = typeof(NCMBUTRankingTemplate).Name;
                template            = go.AddComponent <NCMBUTRankingTemplate>();
                template.Connection = connection;

                Undo.RegisterCreatedObjectUndo(go, "Create Template Object");
            }
        }
Пример #2
0
        /// <summary>
        /// テンプレート配置のアクティブ条件
        /// </summary>
        /// <returns>ConnectionとTemplateの片方でも無い場合は<c>true</c>、両方無い場合は<c>false</c></returns>
        public static bool IsSetTemplate()
        {
            NCMBUTRankingConnection connection = (NCMBUTRankingConnection)GameObject.FindObjectOfType(typeof(NCMBUTRankingConnection));
            NCMBUTRankingTemplate   template   = (NCMBUTRankingTemplate)GameObject.FindObjectOfType(typeof(NCMBUTRankingTemplate));

            return(connection == null || template == null);
        }