void OnMapInit(GameObject gom, AvailableMap amp) { Atom coreControl = SuperController.singleton.GetComponent <Atom>(); lm = coreControl.GetComponent <MapLoaderControl>(); if (lm.controlAtom != null) { gom.transform.SetParent(getTransformByNameAndRoot("object", lm.controlAtom.transform), false); } if (lm) { lm.am = amp; } }
public void OnLevelWasInitialized(int level) { //Make sure we're in the main VAM scenes if ((level == 1 || level == 6)) { Atom coreControl = SuperController.singleton.GetAtomByUid("CoreControl"); lm = coreControl.gameObject.GetComponent <MapLoaderControl>(); if (!lm) { lm = coreControl.gameObject.AddComponent <MapLoaderControl>(); coreControl.RegisterAdditionalStorable(lm); } Transform buttonPrefab = getTransformByNameAndRoot("Quit Button", SuperController.singleton.mainMenuUI); Transform HRButtonPrefab = getTransformByNameAndRoot("Hard Reset Button", SuperController.singleton.mainMenuUI); Button mapLoadButtonUI = createMenuButton("Load External Map"); Button unloadButtonUI = createMenuButton("Unload External Map"); RectTransform buttonPrefabRT = buttonPrefab.GetComponent <RectTransform>(); //RectTransform hardResetRT = HRButtonPrefab.GetComponent<RectTransform>(); RectTransform mapButtonRT = mapLoadButtonUI.gameObject.GetComponent <RectTransform>(); RectTransform unloadButtonRT = unloadButtonUI.gameObject.GetComponent <RectTransform>(); mapButtonRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, mapButtonRT.rect.width / 2f); mapButtonRT.anchoredPosition = new Vector2(mapButtonRT.anchoredPosition.x - (mapButtonRT.rect.width / 2f), mapButtonRT.anchoredPosition.y + mapButtonRT.rect.height + 80f); unloadButtonRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, unloadButtonRT.rect.width / 2f); unloadButtonRT.anchoredPosition = new Vector2(unloadButtonRT.anchoredPosition.x - (unloadButtonRT.rect.width / 2f), unloadButtonRT.anchoredPosition.y + 70f); ScrollRect scrollRect = createMapScrollRect(); GameObject mapLoadPanelGO = scrollRect.gameObject; Scrollbar scrollBarMB = createScrollBar(mapLoadPanelGO); scrollRect.verticalScrollbar = scrollBarMB; scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; scrollRect.verticalScrollbarSpacing = -3; mapLoadButtonUI.onClick.AddListener(() => { if (mapLoadPanelGO.activeSelf) { mapLoadPanelGO.SetActive(false); } else { mapLoadPanelGO.SetActive(true); } }); unloadButtonUI.onClick.AddListener(() => { if (currentLoader != null && currentLoadedScene != null) { currentLoader.unloadMap(currentLoadedScene); currentLoader = null; currentLoadedScene = null; } }); GameObject mapLoadContentGO = mapLoadPanelGO.GetComponent <ScrollRect>().content.gameObject; foreach (KeyValuePair <AvailableMap, MapLoader> map in availableMaps) { createMapLoadButton(mapLoadContentGO, map.Key, map.Value); } mapLoadPanelGO.SetActive(false); } }