public void Init(UIModule widget, GameObject hardpointtext, GameObject jjtext, Vector2 position)
        {
            var hp_layout = hardpointtext.transform.parent.parent;

            var horizontal = hp_layout.GetComponent <HorizontalLayoutGroup>();

            GameObject.DestroyImmediate(horizontal);
            var jj_layout = jjtext.transform.parent.parent;



            var grid = hp_layout.gameObject.AddComponent <GridLayoutGroup>();

            //grid.childControlHeight = true;
            //vertical.childControlWidth = true;
            grid.padding         = new RectOffset(3, 3, 3, 3);
            grid.spacing         = new Vector2(1, 1);
            grid.childAlignment  = TextAnchor.MiddleCenter;
            grid.constraint      = GridLayoutGroup.Constraint.FixedColumnCount;
            grid.constraintCount = 5;
            grid.cellSize        = new Vector2(60, 32);
            var transform = hp_layout.GetComponent <RectTransform>();

            transform.anchoredPosition = position;
            transform.sizeDelta        = new Vector2(295, 66);
            grid.enabled = true;

            var fitter = hp_layout.gameObject.AddComponent <ContentSizeFitter>();

            fitter.verticalFit   = ContentSizeFitter.FitMode.MinSize;
            fitter.horizontalFit = ContentSizeFitter.FitMode.MinSize;


            var jj     = jj_layout.GetChild(0);
            var sample = make_samlpe(hp_layout);

            foreach (Transform child in hp_layout)
            {
                if (child != sample)
                {
                    GameObject.Destroy(child.gameObject);
                }
            }

            var jjgo = GameObject.Instantiate(sample.gameObject);

            jjhardpoint = new JJHardpointHeler(jjgo, jj);
            hardpoints  = new Dictionary <int, HardpointHelper>();

            jjgo.transform.SetParent(hp_layout);
            foreach (var hpinfo in HardpointController.Instance.HardpointsList.Where(i => i.Visible))
            {
                var hpgo = GameObject.Instantiate(sample.gameObject);
                hardpoints[hpinfo.WeaponCategory.ID] = new MechlabHardpointHelper(hpgo, hpinfo);
                hpgo.transform.SetParent(hp_layout);
            }

            GameObject.Destroy(sample.gameObject);
            GameObject.Destroy(jj_layout.gameObject);
        }
예제 #2
0
        public void Init(TooltipPrefab widget, GameObject hardpoint)
        {
            try
            {
                //Control.Log($"hardpoint name is {hardpoint.name}");
                var hp_layout = hardpoint.transform.parent;

                var horizontal = hp_layout.GetComponent <HorizontalLayoutGroup>();
                GameObject.DestroyImmediate(horizontal);

                var grid = hp_layout.gameObject.AddComponent <GridLayoutGroup>();
                //grid.childControlHeight = true;
                //vertical.childControlWidth = true;
                grid.padding         = new RectOffset(3, 3, 3, 3);
                grid.spacing         = new Vector2(1, 1);
                grid.childAlignment  = TextAnchor.MiddleCenter;
                grid.constraint      = GridLayoutGroup.Constraint.FixedColumnCount;
                grid.constraintCount = 5;
                grid.cellSize        = new Vector2(73, 35);
                var transform = hp_layout.GetComponent <RectTransform>();
                //transform.anchoredPosition = position;
                //transform.sizeDelta = new Vector2(295, 66);
                grid.enabled = true;

                var fitter = hp_layout.gameObject.AddComponent <ContentSizeFitter>();
                fitter.verticalFit   = ContentSizeFitter.FitMode.MinSize;
                fitter.horizontalFit = ContentSizeFitter.FitMode.MinSize;


                var sample = make_samlpe(hardpoint.transform);
                foreach (Transform child in hp_layout)
                {
                    child.gameObject.SetActive(false);
                }

                var jjgo = GameObject.Instantiate(sample.gameObject);

                jjhardpoint = new JJHardpointHeler(jjgo, sample);
                hardpoints  = new Dictionary <int, HardpointHelper>();
                jjgo.transform.SetParent(hp_layout);
                jjgo.SetActive(true);
                foreach (var hpinfo in HardpointController.Instance.HardpointsList.Where(i => i.Visible))
                {
                    var hpgo = GameObject.Instantiate(sample.gameObject);
                    hardpoints[hpinfo.WeaponCategory.ID] = new MechlabHardpointHelper(hpgo, hpinfo);
                    hpgo.transform.SetParent(hp_layout);
                    hpgo.SetActive(true);
                }
                sample.gameObject.SetActive(false);

                //GameObject.Destroy(sample.gameObject);
            }
            catch (Exception e)
            {
                Control.LogError(e);
            }
        }
예제 #3
0
        public void Init(MechLabPanel panel)
        {
            var top_layout = panel.transform
                             .Find("Representation/OBJGROUP_LEFT/OBJ_meta/OBJ_status");

            var hp_layout  = top_layout.Find("layout_hardpoints");
            var horizontal = hp_layout.GetComponent <HorizontalLayoutGroup>();

            GameObject.DestroyImmediate(horizontal);
            var jj_layout = top_layout.Find("layout_jumpjets");



            var vertical = hp_layout.gameObject.AddComponent <VerticalLayoutGroup>();

            vertical.childControlHeight = true;
            vertical.childControlWidth  = true;
            vertical.padding            = new RectOffset(5, 5, 5, 5);
            vertical.spacing            = 0;
            vertical.childAlignment     = TextAnchor.MiddleCenter;
            vertical.enabled            = true;

            var fitter = hp_layout.gameObject.AddComponent <ContentSizeFitter>();

            fitter.verticalFit   = ContentSizeFitter.FitMode.MinSize;
            fitter.horizontalFit = ContentSizeFitter.FitMode.MinSize;

            var transform = vertical.GetComponent <RectTransform>();

            transform.anchoredPosition = new Vector2(-80, transform.anchoredPosition.y);

            var jj     = jj_layout.GetChild(0);
            var sample = make_samlpe(hp_layout);

            foreach (Transform child in hp_layout)
            {
                if (child != sample)
                {
                    GameObject.Destroy(child.gameObject);
                }
            }

            var jjgo = GameObject.Instantiate(sample.gameObject);

            jjhardpoint = new JJHardpointHeler(jjgo, jj);
            hardpoints  = new Dictionary <int, HardpointHelper>();

            jjgo.transform.SetParent(hp_layout);
            foreach (var hpinfo in HardpointController.Instance.HardpointsList.Where(i => i.Visible))
            {
                var hpgo = GameObject.Instantiate(sample.gameObject);
                hardpoints[hpinfo.WeaponCategory.ID] = new MechlabHardpointHelper(hpgo, hpinfo);
                hpgo.transform.SetParent(hp_layout);
            }

            GameObject.Destroy(sample.gameObject);
            GameObject.Destroy(jj_layout.gameObject);

            var button = top_layout.Find("OBJ_stockBttn");

            button.SetParent(hp_layout);
            var l = button.gameObject.AddComponent <LayoutElement>();

            l.minHeight = 50;
        }