Ejemplo n.º 1
0
 public static void _OnClose(UIFunctionPanel __instance)
 {
     if (blueprintGroup != null)
     {
         blueprintGroup._Close();
     }
 }
Ejemplo n.º 2
0
    public static void _OnOpen(UIFunctionPanel __instance)
    {
        if (!blueprintPanelInit)
        {
            UIBuildMenu menu    = __instance.buildMenu;
            Transform   mainTrs = menu.gameObject.transform.Find("main-group");
            if (mainTrs == null)
            {
                return;
            }

            GameObject buttonPrefab = MultiBuildUI.bundle.LoadAsset <GameObject>("assets/blueprints/ui/button.prefab");
            GameObject button       = Object.Instantiate(buttonPrefab, Vector3.zero, Quaternion.identity, mainTrs);
            button.transform.localPosition = new Vector3(260, 0, 0);
            menu.categoryButtons[10].transform.localPosition += new Vector3(52, 0, 0);
            menu.mainCanvas.transform.localPosition          += new Vector3(-26, 0, 0);
            Button blueprintButton = button.GetComponent <Button>();

            GameObject prefab = MultiBuildUI.bundle.LoadAsset <GameObject>("assets/blueprints/ui/blueprint-group.prefab");
            GameObject group  = Object.Instantiate(prefab, menu.transform, false);
            blueprintGroup = group.GetComponent <UIBlueprintGroup>();
            blueprintGroup.Init(menu, button.GetComponent <UIButton>());
            blueprintGroup._Close();

            blueprintGroup.InfoText.GetComponent <RectTransform>().offsetMin = new Vector2(3f, -66f);

            blueprintGroup.InfoText.resizeTextForBestFit = true;
            blueprintGroup.InfoText.resizeTextMinSize    = 10;
            blueprintGroup.InfoText.resizeTextMaxSize    = 14;

            blueprintGroup.infoTitle.text = "Stored blueprint";
            blueprintGroup.InfoText.text  = "None";

            blueprintButton.onClick.AddListener(() =>
            {
                if (blueprintGroup.isOpen)
                {
                    menu.SetCurrentCategory(0);
                }
                else
                {
                    blueprintGroup._Open();
                }
            });


            blueprintPanelInit = true;
        }
    }