Exemplo n.º 1
0
    public void InitControl()
    {
        if (_root != null)
        {
            DestroyImmediate(_root.gameObject);
        }

        if (ContainerPrefab != null)
        {
            // create
            var own = GetComponent <RectTransform>();
            _root = Instantiate(ContainerPrefab, own.position, own.rotation);
            _root.transform.SetParent(transform, false);
            _scrollControl = _root.ItemPanel.GetComponent <ScrollRect> ();
            _scrollControl.scrollSensitivity = ScrollSensitivity;
            var rt = _root.GetComponent <RectTransform>();
            rt.pivot = new Vector2(0.5f, 0.5f);
            //root.anchoredPosition = Vector2.zero;
            rt.anchorMin = Vector2.zero;
            rt.anchorMax = Vector2.one;
            rt.offsetMax = Vector2.zero;
            rt.offsetMin = Vector2.zero;
            _root.gameObject.hideFlags = HideFlags.HideInHierarchy;             // should really be HideAndDontSave, but unity crashes
            _root.ItemPanel.alpha      = 0.0f;

            // create menu item
            var toCreate = ItemMenuPrefab;
            if (toCreate == null)
            {
                toCreate = ItemPrefab;
            }
            CreateMenuButton(toCreate);
        }
    }
Exemplo n.º 2
0
 public void InitControl()
 {
     if (root != null)
     {
         Object.DestroyImmediate(root.gameObject);
     }
     if (containerPrefab != null)
     {
         RectTransform component = GetComponent <RectTransform>();
         root = (Object.Instantiate(containerPrefab, component.position, component.rotation) as StyledComboBoxPrefab);
         root.transform.SetParent(base.transform, worldPositionStays: false);
         RectTransform component2 = root.GetComponent <RectTransform>();
         component2.pivot          = new Vector2(0.5f, 0.5f);
         component2.anchorMin      = Vector2.zero;
         component2.anchorMax      = Vector2.one;
         component2.offsetMax      = Vector2.zero;
         component2.offsetMin      = Vector2.zero;
         root.gameObject.hideFlags = HideFlags.HideInHierarchy;
         root.itemPanel.gameObject.SetActive(isToggled);
     }
 }
Exemplo n.º 3
0
 public void InitControl()
 {
     if (this.root != null)
     {
         UnityEngine.Object.DestroyImmediate(this.root.gameObject);
     }
     if (this.containerPrefab != null)
     {
         RectTransform component = base.GetComponent <RectTransform>();
         this.root = UnityEngine.Object.Instantiate(this.containerPrefab, component.position, component.rotation) as StyledComboBoxPrefab;
         this.root.transform.SetParent(base.transform, false);
         RectTransform transform2 = this.root.GetComponent <RectTransform>();
         transform2.pivot               = new Vector2(0.5f, 0.5f);
         transform2.anchorMin           = Vector2.zero;
         transform2.anchorMax           = Vector2.one;
         transform2.offsetMax           = Vector2.zero;
         transform2.offsetMin           = Vector2.zero;
         this.root.gameObject.hideFlags = HideFlags.HideInHierarchy;
         this.root.itemPanel.gameObject.SetActive(this.isToggled);
     }
 }
Exemplo n.º 4
0
    public void InitControl()
    {
        if (root != null)
            DestroyImmediate(root.gameObject);

        if (containerPrefab != null)
        {
            // create
            RectTransform own = GetComponent<RectTransform>();
            root = Instantiate(containerPrefab, own.position, own.rotation) as StyledComboBoxPrefab;
            root.transform.parent = this.transform;

            RectTransform rt = root.GetComponent<RectTransform>();
            rt.pivot = new Vector2(0.5f, 0.5f);
            //root.anchoredPosition = Vector2.zero;
            rt.anchorMin = Vector2.zero;
            rt.anchorMax = Vector2.one;
            rt.offsetMax = Vector2.zero;
            rt.offsetMin = Vector2.zero;
            root.gameObject.hideFlags = HideFlags.HideInHierarchy; // should really be HideAndDontSave, but unity crashes
            root.itemPanel.alpha = 0.0f;

            // create menu item
            StyledItem toCreate = itemMenuPrefab;
            if (toCreate == null)
                toCreate = itemPrefab;
            CreateMenuButton(toCreate);
        }
    }