Exemple #1
0
    private void OnEnable()
    {
        int n = 0;

        for (int i = 0; i < menus.Length; i++)
        {
            if (menus[i].activeSelf)
            {
                n++;
            }
        }
        // float sep = 360 / n;

        // Vector3 startPos = new Vector3(0, distance, 0);
        for (int i = 0; i < menus.Length; i++)
        {
            if (!menus[i].activeSelf)
            {
                continue;
            }

            /*float angle = sep * i - 45;
             * Vector3 pos = Quaternion.Euler(0, 0, angle) * startPos;
             * menus[i].transform.localPosition = pos;*/
            int j = i;
            UGUIClickEventListener.Get(menus[i]).onClick = () => {
                if (onClick != null)
                {
                    onClick(j);
                }
            };
        }
    }
Exemple #2
0
            public void Show(int uuid, BattlefieldObject obj = null, int type = 0, params string [] effectNames)
            {
                if ((uuid >= 0 && obj == null) || selectors.ContainsKey(uuid))
                {
                    return;
                }

                if (uuid == -1)
                {
                    obj = partnerSelector;
                }
                else if (uuid < 0)
                {
                    obj = enemySelector;
                }

                GameObject selector = null;

                if (selectorPool.Count == 0)
                {
                    selector = Instantiate(prefab);
                    selector.GetComponent <RectTransform>().SetParent(GetComponent <RectTransform>(), false);
                }
                else
                {
                    selector = selectorPool[0];
                    selectorPool.RemoveAt(0);
                }

                selector.transform.localPosition = Vector3.zero;
                selector.transform.localScale    = Vector3.one;
                selector.transform.localRotation = Quaternion.identity;

                selector.SetActive(true);

                if (uuid < 0)
                {
                    selector.transform.localScale = Vector3.one * 1.5f;
                }
                else
                {
                    selector.transform.localScale = Vector3.one;
                }

                selector.name = string.Format("targetSelector_{0}", obj.name);
                UGUIClickEventListener.Get(selector).onClick = () => {
                    onSelected(uuid);
                };

                selectors [uuid] = new SelectInfo(uuid, selector, obj, type);

                selectors[uuid].Update();

                if (effectNames.Length > 0)
                {
                    for (int i = 0; i < effectNames.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(effectNames[i]))
                        {
                            string fullPath = string.Format("prefabs/effect/{0}.prefab", effectNames[i]);
                            ResourcesManager.LoadAsync(this, fullPath, (o) => {
                                if (selectors.ContainsKey(uuid) == true)
                                {
                                    GameObject effect = SGK.GameObjectPoolManager.getInstance().Get(fullPath);

                                    effect.transform.localPosition = Vector3.zero;
                                    effect.transform.localScale    = Vector3.one;
                                    effect.transform.localRotation = Quaternion.identity;

                                    effect.SetActive(true);

                                    selectors[uuid].addFollower(effect);
                                }
                            });
                        }
                    }
                }
            }
Exemple #3
0
    public static void ReplaceButtonTitle()
    {
        Object[] objects = Selection.GetFiltered(typeof(GameObject), SelectionMode.DeepAssets);
        int      n       = objects.Length;

        for (int i = 0; i < n; i++)
        {
            GameObject obj = objects[i] as GameObject;
            if (obj == null)
            {
                continue;
            }
            Debug.Log(AssetDatabase.GetAssetPath(obj));
            EditorUtility.DisplayProgressBar(string.Format("working {0}/{1}", i + 1, objects.Length), AssetDatabase.GetAssetPath(obj), i * 1.0f / objects.Length);
            // continue;
            Image[] images = obj.GetComponentsInChildren <Image>();
            for (int j = 0; j < images.Length; j++)
            {
                Image  image = images[j];
                string path  = AssetDatabase.GetAssetPath(image.sprite);

/*
 *              Color color;
 *              if (path == "Assets/UI7/common/bn_07.png") {
 *                  color = Color.
 *              }
 *
 *                  按钮上的字30号,按钮在这里的宽度:226,高度是默认的。
 *
 * 按钮上的字色:
 *
 * 红 431409
 *
 * 黄 43230b
 *
 * 蓝 042a33
 *
 * 绿 1d4309
 *
 * 灰 5e5e5e
 *              }
 */
                if (path.StartsWith("Assets/UI7/common/"))
                {
                    Debug.Log(path);
                    if (path == "Assets/UI7/common/bn_guanbi.png")
                    {
                        image.SetNativeSize();
                        UGUIClickEventListener.Get(image.gameObject).disableTween = true;
                        Button btn = image.gameObject.GetComponent <Button>();
                        if (btn == null)
                        {
                            btn = image.gameObject.AddComponent <Button>();
                        }
                        btn.transition    = Selectable.Transition.SpriteSwap;
                        btn.targetGraphic = image;
                        // btn.spriteState = spriteState;
                    }
                    else if (image.type == Image.Type.Sliced)
                    {
                        RectTransform transform = image.GetComponent <RectTransform>();
                        if (transform.rect.size.y < image.sprite.rect.height || transform.rect.size.x < image.sprite.rect.width)
                        {
                            if (transform.anchorMin == transform.anchorMax)
                            {
                                transform.sizeDelta = new Vector2(
                                    Mathf.Max(transform.rect.size.x, image.sprite.rect.width),
                                    Mathf.Max(transform.rect.size.y, image.sprite.rect.height));
                            }
                        }
                    }
                }
            }
        }
        EditorUtility.ClearProgressBar();
    }