예제 #1
0
        /// <summary>
        /// 用来加速的按钮
        /// </summary>
        //private ETCButton m_speedUpBtn;


#if !UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS
        /// <summary>
        /// 初始化,用来在当前场景添加GameInput对象
        /// </summary>
        public static void Create()
        {
            if (m_instance != null)
            {
                throw new Exception("GameInput 不能重复初始化");
            }

            // 实例化GameInput的prefab
            GameObject prefab = Resources.Load <GameObject>("GameInputForPC");
            GameObject go     = GameObject.Instantiate(prefab);

            m_instance = GameObjectUtils.EnsureComponent <GameInput>(go);
        }
예제 #2
0
        public static void Create()
        {
            Camera c = GameObject.FindObjectOfType <Camera>();

            if (c != null)
            {
                GameObjectUtils.EnsureComponent <GameCamera>(c.gameObject);
            }
            else
            {
                MyLogger.LogError("GameCamera", "Create()", "Cannot Find Camera In Scene!");
            }
        }
예제 #3
0
        /// <summary>
        /// 初始化,用来在当前场景添加GameInput对象
        /// </summary>
        public static void Create()
        {
            if (m_instance != null)
            {
                throw new Exception("GameInput 不能重复初始化");
            }

            // 实例化GameInput的prefab,里面预制了EasyJoystick脚本
            // 因为EasyJoystick有一些参数,在prefab中容易配置一些
            GameObject prefab = Resources.Load <GameObject>("GameInput");
            GameObject go     = GameObject.Instantiate(prefab);

            m_instance = GameObjectUtils.EnsureComponent <GameInput>(go);
        }
예제 #4
0
        /// <summary>
        /// 初始化,用来在当前场景添加GameInput对象
        /// </summary>
        public static void Create()
        {
            if (m_Instance != null)
            {
                throw new Exception("GameInput 不能重复初始化!");
                return;
            }

            //实例化GameInput的Prefab参数,里面预置了EasyJoystick脚本!
            //因为EasyJoystick有一些参数,在Prefab里比较容易配置
            GameObject prefab = Resources.Load <GameObject>("GameInput");
            GameObject go     = GameObject.Instantiate(prefab);

            m_Instance = GameObjectUtils.EnsureComponent <GameInput>(go);
        }
예제 #5
0
        /// <summary>
        /// create GameInput instance in current scene
        /// </summary>
        public static void Create()
        {
            if (m_Instance != null)
            {
                throw new Exception("GameInput Already created!");
                return;
            }

            //instantiate EasyJoyStick prefab
            //since it is easier to configure EasyJoyStick using prefab
            GameObject prefab = Resources.Load <GameObject>("GameInput");
            GameObject go     = GameObject.Instantiate(prefab);

            m_Instance = GameObjectUtils.EnsureComponent <GameInput>(go);
        }
예제 #6
0
        private void LoadDataToChapterPanel()
        {
            List <ChapterMapConfigsData> chapterMaps = MapModule.Instance.GetChapterModeConfigs();

            if (chapterMaps == null || chapterMaps.Count <= 0)
            {
                return;
            }

            UserModule userModule = UserModule.Instance;

            List <Button>     chapterSelectedBtns = new List <Button>(chapterMaps.Count);
            List <GameObject> smallChapterPanels  = new List <GameObject>(chapterMaps.Count);

            m_chapterModels = new Dictionary <int, KeyValuePair <UIChapterNoBtnModel, List <UIMapItemModel> > >(chapterMaps.Count);

            foreach (ChapterMapConfigsData data in chapterMaps)
            {
                // 生成选择按钮
                GameObject selectedBtnGo = GameObject.Instantiate <GameObject>(ChapterSelectedBtnPrefab, ChapterSelectedContent.transform);

                // 保存预制体的Button脚本
                UIChapterNoBtn      selectedChapterNoBtn = selectedBtnGo.GetComponent <UIChapterNoBtn>();
                UIChapterNoBtnModel chapterNoBtnModel    = new UIChapterNoBtnModel(data.chapterNo, userModule.IsChapterUnlocked(data.chapterNo));
                selectedChapterNoBtn.SetModel(chapterNoBtnModel);
                chapterSelectedBtns.Add(selectedBtnGo.GetComponent <Button>());

                // 保存章节按钮和小章节的映射
                List <UIMapItemModel> uiMapItemModels = new List <UIMapItemModel>(data.chapterConfigs.Count);
                KeyValuePair <UIChapterNoBtnModel, List <UIMapItemModel> > chapterModelKV = new KeyValuePair <UIChapterNoBtnModel, List <UIMapItemModel> >(chapterNoBtnModel, uiMapItemModels);
                m_chapterModels.Add(data.chapterNo, chapterModelKV);

                // 生成小章节面板
                GameObject smallChapterPanelGo = GameObject.Instantiate <GameObject>(SmallChapterPanelPrefab, SmallChapterRootPanel.transform);
                smallChapterPanels.Add(smallChapterPanelGo);

                // 获取小章节面板的滚动脚本
                UIScrollView smallChapterScrollView = GameObjectUtils.EnsureComponent <UIScrollView>(smallChapterPanelGo);

                // 添加数据到小章节面板
                foreach (MapConfigData mapData in data.chapterConfigs)
                {
                    GameObject mapItem = GameObject.Instantiate <GameObject>(ChapterMapItemPrefab);
                    smallChapterScrollView.AddChild(mapItem);

                    // 保存小章节数据的model
                    UIMapItemModel mapItemModel = new UIMapItemModel(mapData, userModule.IsChapterUnlocked(data.chapterNo, mapData.no));
                    SetDataToMapItem(mapItem, mapItemModel);
                    uiMapItemModels.Add(mapItemModel);
                }
            }

            UIDynamicLabelBtnGroup chapterBtnGroup = GameObjectUtils.EnsureComponent <UIDynamicLabelBtnGroup>(ChapterSelectedContent);

            chapterBtnGroup.Init(chapterSelectedBtns, (int index) =>
            {
                UIDynamicPanelGroup panelGroup = SmallChapterRootPanel.GetComponent <UIDynamicPanelGroup>();
                if (panelGroup == null)
                {
                    return;
                }

                panelGroup.ActivePanel(index);
            });

            UIDynamicPanelGroup smallChapterPanelGroup = GameObjectUtils.EnsureComponent <UIDynamicPanelGroup>(SmallChapterRootPanel.gameObject);

            smallChapterPanelGroup.Init(smallChapterPanels);
        }
        private static void AddConponent()
        {
            var tempObj = Selection.activeGameObject;

            GameObjectUtils.EnsureComponent <HighlightableObject>(tempObj);
        }