コード例 #1
0
        internal static T GetTaggedComponent <T> (this GameObject go) where T : Component
        {
            Type taggedType = SystemUtils.VersionTaggedType(typeof(T));

            return((T)go.GetComponent(taggedType));
        }
コード例 #2
0
        public static UIPartActionScaleEdit CreateTemplate()
        {
            // Create the control
            GameObject            editGo = new GameObject("UIPartActionScaleEdit", SystemUtils.VersionTaggedType(typeof(UIPartActionScaleEdit)));
            UIPartActionScaleEdit edit   = editGo.GetTaggedComponent <UIPartActionScaleEdit>();

            editGo.SetActive(false);

            // TODO: since I don'type have access to EZE GUI, I'm copying out bits from other existing GUIs
            // if someone does have access, they could do this better although really it works pretty well.
            UIPartActionButton evtp            = UIPartActionController.Instance.eventItemPrefab;
            GameObject         srcTextGo       = evtp.transform.Find("Text").gameObject;
            GameObject         srcBackgroundGo = evtp.transform.Find("Background").gameObject;
            GameObject         srcButtonGo     = evtp.transform.Find("Btn").gameObject;

            UIPartActionFloatRange paFlt       = (UIPartActionFloatRange)UIPartActionController.Instance.fieldPrefabs.Find(cls => cls.GetType() == typeof(UIPartActionFloatRange));
            GameObject             srcSliderGo = paFlt.transform.Find("Slider").gameObject;


            // Start building our control
            GameObject backgroundGo = (GameObject)Instantiate(srcBackgroundGo);

            backgroundGo.transform.parent = editGo.transform;

            GameObject sliderGo = (GameObject)Instantiate(srcSliderGo);

            sliderGo.transform.parent     = editGo.transform;
            sliderGo.transform.localScale = new Vector3(0.65f, 1, 1);
            edit.slider = sliderGo.GetComponent <UIProgressSlider>();
            edit.slider.ignoreDefault = true;


            GameObject fieldNameGo = (GameObject)Instantiate(srcTextGo);

            fieldNameGo.transform.parent        = editGo.transform;
            fieldNameGo.transform.localPosition = new Vector3(40, -8, 0);
            edit.fieldName = fieldNameGo.GetComponent <SpriteText>();

            GameObject fieldValueGo = (GameObject)Instantiate(srcTextGo);

            fieldValueGo.transform.parent        = editGo.transform;
            fieldValueGo.transform.localPosition = new Vector3(110, -8, 0);
            edit.fieldValue = fieldValueGo.GetComponent <SpriteText>();


            GameObject incLargeDownGo = (GameObject)Instantiate(srcButtonGo);

            incLargeDownGo.transform.parent        = edit.transform;
            incLargeDownGo.transform.localScale    = new Vector3(0.45f, 1.1f, 1f);
            incLargeDownGo.transform.localPosition = new Vector3(11.5f, -9, 0); //>11
            edit.incLargeDown = incLargeDownGo.GetComponent <UIButton>();

            GameObject incLargeDownLabelGo = (GameObject)Instantiate(srcTextGo);

            incLargeDownLabelGo.transform.parent        = editGo.transform;
            incLargeDownLabelGo.transform.localPosition = new Vector3(5.5f, -7, 0); // <6
            edit.incLargeDownLabel      = incLargeDownLabelGo.GetComponent <SpriteText>();
            edit.incLargeDownLabel.Text = "<<";

            GameObject incLargeUpGo = (GameObject)Instantiate(srcButtonGo);

            incLargeUpGo.transform.parent        = edit.transform;
            incLargeUpGo.transform.localScale    = new Vector3(0.45f, 1.1f, 1f);
            incLargeUpGo.transform.localPosition = new Vector3(187.5f, -9, 0); // >187
            edit.incLargeUp = incLargeUpGo.GetComponent <UIButton>();

            GameObject incLargeUpLabelGo = (GameObject)Instantiate(srcTextGo);

            incLargeUpLabelGo.transform.parent        = editGo.transform;
            incLargeUpLabelGo.transform.localPosition = new Vector3(181.5f, -7, 0); //<182
            edit.incLargeUpLabel      = incLargeUpLabelGo.GetComponent <SpriteText>();
            edit.incLargeUpLabel.Text = ">>";
            return(edit);
        }