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

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

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

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

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

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

                Undo.RegisterCreatedObjectUndo(go, "Create Template Object");
            }
        }