상속: MonoBehaviour
예제 #1
0
    void Awake()
    {
        m_transform = transform;
        gameObject.SetActive(false);
        ClimbTowerUILogicManager.Instance.Initialize(this);
        m_rewardList = m_transform.FindChild("RightBox/RewardList");
        m_towerList = m_transform.FindChild("TowerList");
        m_report = m_transform.FindChild("report").gameObject;
        m_reportList = m_transform.FindChild("report/BattleReportList");
        m_rewardTitle = m_transform.FindChild("report/img/lblTitle").GetComponentsInChildren<UILabel>(true)[0];
        m_highHistory = m_transform.FindChild("RightBox/historyHigh").GetComponentsInChildren<UILabel>(true)[0];
        //m_currentLevel = m_transform.FindChild("RightBox/TriPager/lblCurrentLevel").GetComponentsInChildren<UILabel>(true)[0];
        m_leftChallengeCount = m_transform.FindChild("LeftBox/lblContainer/lblChallengeCount").GetComponentsInChildren<UILabel>(true)[0];
        m_lblGuide = m_transform.FindChild("LeftBox/lblContainer/lblGuide").GetComponentsInChildren<UILabel>(true)[0];
        m_leftVIPSweepCount = m_transform.FindChild("LeftBox/lblContainer/lblVIPSweepCount").GetComponentsInChildren<UILabel>(true)[0];
        m_closeAnchor = m_transform.FindChild("closeAnchor").GetComponentsInChildren<UIAnchor>(true)[0];
        m_buttonVIP = m_transform.FindChild("RightBox/btnTowerVIP").GetComponentsInChildren<MogoTwoStatusButton>(true)[0];
        m_buttonNormal = m_transform.FindChild("RightBox/btnTowerNormal").GetComponentsInChildren<MogoTwoStatusButton>(true)[0];
        AddButtonListener("onClicked", "RightBox/btnEnter", ClimbTowerUILogicManager.Instance.OnEnterMap);
        AddButtonListener("onClicked", "LeftBox/btnTowerCharge", ClimbTowerUILogicManager.Instance.Charge);
        AddButtonListener("onClicked", "RightBox/btnTowerNormal", ClimbTowerUILogicManager.Instance.NormalSweep);
        AddButtonListener("onClicked", "RightBox/btnTowerVIP", ClimbTowerUILogicManager.Instance.VIPSweep);
        AddButtonListener("onClicked", "closeAnchor/btnClose", Close);
        AddButtonListener("onClicked", "report/img/btnClose", closeReport);
        if (MogoUIManager.Instance.WaitingWidgetName == "btnEnter")
        {
            TimerHeap.AddTimer(100, 0, () => { EventDispatcher.TriggerEvent("WaitingWidgetFinished"); });
        }

        //m_towerList.GetComponent<MogoListImproved>().SetGridLayout<TowerUnit>(7, m_towerList.transform, TowerLoaded);
    }
예제 #2
0
    public void SetAnchorY(float offY)
    {
        UIAnchor uia = this.GetComponent <UIAnchor>();

        if (uia != null)
        {
            uia.relativeOffset = new Vector2(uia.relativeOffset.x, offY);
        }
    }
예제 #3
0
    public void SetAnchorX(float offX)
    {
        UIAnchor uia = this.GetComponent <UIAnchor>();

        if (uia != null)
        {
            uia.relativeOffset = new Vector2(offX, uia.relativeOffset.y);
        }
    }
예제 #4
0
    public void MoveControlOffset(float offX, float offY)
    {    //Moves a control by the specified distance on the gui
        UIAnchor uia = this.GetComponent <UIAnchor>();

        if (uia != null)
        {
            uia.relativeOffset = uia.relativeOffset + new Vector2(offX, offY);
        }
    }
예제 #5
0
    protected override void DoAwake()
    {
        Transform rootAnchorTransform = transform.FindChild("Anchor");

        if (rootAnchorTransform)
        {
            rootAnchor = rootAnchorTransform.GetComponent <UIAnchor>();
        }
    }
예제 #6
0
파일: UIMng.cs 프로젝트: atom-chen/tianyu
    /// <summary>
    /// 加载某个界面 by吴江
    /// </summary>
    /// <param name="_name"></param>
    /// <param name="_needOpen">加载以后是否需要打开</param>
    /// <returns></returns>
    public GUIBase GenGUI(string _name, bool _needOpen, SubGUIType _subType = SubGUIType.NONE, GUIType _baseOn = GUIType.NONE, System.Action <GUIBase> _callback = null)
    {
        if (uiDictionary.ContainsKey(_name) && uiDictionary[_name] != null)
        {
            if (_callback != null)
            {
                _callback(uiDictionary[_name]);
            }
            return(_needOpen ? uiDictionary[_name].OpenUI() : uiDictionary[_name].CloseUI());
        }
        Object obj = exResources.GetResource(ResourceType.GUI, _name);

        if (obj == null)
        {
            Debug.LogError("找不到名为:" + _name + "的UI预制");
            return(null);
        }
        GameObject gui = Instantiate(obj) as GameObject;

        gui.transform.parent        = uIRoot.transform;
        gui.transform.localScale    = Vector3.one;
        gui.transform.localPosition = Vector3.zero;
        gui.name = obj.name;
        obj      = null;
        UIAnchor anchor = gui.GetComponent <UIAnchor>();

        gui.SetActive(false);
        if (anchor != null)
        {
            anchor.uiCamera = GameCenter.cameraMng.uiCamera;
        }
        GUIBase guibase = gui.GetComponent <GUIBase>();

        if (guibase != null)
        {
            uiDictionary[_name] = guibase;
            if (_subType != SubGUIType.NONE)
            {
                guibase.InitSubGUIType = _subType;
            }
            if (_needOpen)
            {
                guibase.OpenUI(_baseOn);
            }
            if (_callback != null)
            {
                _callback(guibase);
            }
            return(guibase);
        }
        else
        {
            Debug.LogError("在" + _name + " UI预制上找不到 GUIBase 组件!");
        }
        return(null);
    }
예제 #7
0
        public static UIGenericValueWatcher Get(UIAnchor anchor, float timer, Func <string> del)
        {
            var valueWatcher = ItemPool.SpawnUIPrefab <UIGenericValueWatcher>(UnityDirs.UI + "UIGenericValueWatcher", anchor.Get().transform);

            valueWatcher._timer.StartNewTime(timer);
            valueWatcher._checkTimer = timer > 0;
            valueWatcher._updateDel  = del;
            anchor.SetAnchorPosition(valueWatcher._rectTr);
            return(valueWatcher);
        }
예제 #8
0
    void Start()
    {
        float    fRadio = (standard_width / standard_height) / ((float)Screen.width / (float)Screen.height);
        UIAnchor anchor = gameObject.GetComponent <UIAnchor>();

        if (anchor != null)
        {
            anchor.relativeOffset.y = anchor.relativeOffset.y / fRadio;
        }
    }
예제 #9
0
    public virtual GameObject AddContent(UIAnchor anchor, GameObject prefab)
    {
        var content = NGUITools.AddChild(anchor.gameObject, prefab);

        if (anchor == GetAnchor(anchor.side))
        {
            CorrectOffsets(anchor);
        }
        return(content);
    }
예제 #10
0
 public void AddContentText(
     GameObject prefab,
     UIPivot pivot,
     UIAnchor anchor,
     Vector2 offset,
     string text)
 {
     this.AddContentText(prefab, pivot, anchor, offset);
     this.SetContentText(text, this._contentText.Count - 1);
 }
예제 #11
0
 public virtual void Start()
 {
     anchor         = this.GetComponent <UIAnchor>();
     stretch        = this.GetComponent <UIStretch>();
     CursorPosition = new Rect(
         0.0f,
         0.0f,
         cursorSizeX,
         cursorSizeY);
 }
예제 #12
0
 public override void Init()
 {
     base.Init();
     this.PanelTransform = this.transform.Find("AnchorLeft/BuffPanel");
     this.BuffNode       = this.transform.Find("AnchorLeft/BuffPanel/Buff");
     this.PassiveNode    = this.transform.Find("AnchorRight/BuffPanel/Passive");
     this.tAlpha         = this.transform.GetComponent <TweenAlpha>();
     this.Anchor         = this.transform.FindChild("AnchorLeft").GetComponent <UIAnchor>();
     this.m_BuffItem     = ResourceManager.LoadPath <GameObject>("Prefab/UI/Skill/BuffItem", null, 0);
 }
예제 #13
0
    // 時間の表示
    void TimeUI()
    {
        Text               = timeLabel.GetComponent("UILabel") as UILabel;
        Text.pivot         = UIWidget.Pivot.Left;
        Offset             = timeLabel.GetComponent("UIAnchor") as UIAnchor;
        Offset.side        = UIAnchor.Side.Top;
        Offset.pixelOffset = new Vector2(-50, -40);

        Text.text = "Time : " + (int)Rule.GameTime;
    }
예제 #14
0
    public void Init(UIAnchor pos, Note.NoteColor newColor, float width, GameObject gameObj)
    {
        Start();

        color = newColor;
        anchor.relativeOffset.x = pos.relativeOffset.x;
        anchor.relativeOffset.y = pos.relativeOffset.y;

        SetColor();
        SetWidth(width);
    }
예제 #15
0
    UIAnchor CreatSpriteAndParentToNGUIPanel(string carName)
    {
        GameObject g = (GameObject.Instantiate(nameLabelPrefab) as GameObject);

        g.transform.parent     = GameObject.Find(uiRootName).transform;
        g.transform.localScale = Vector3.one;
        g.GetComponentInChildren <UILabel>().text = carName;
        UIAnchor anchor = g.GetComponentInChildren <UIAnchor>();

        return(anchor);
    }
예제 #16
0
    // スコアの表示
    void ScoreUI()
    {
        Text               = scoreLabel.GetComponent("UILabel") as UILabel;
        Text.pivot         = UIWidget.Pivot.Left;
        Offset             = scoreLabel.GetComponent("UIAnchor") as UIAnchor;
        Offset.side        = UIAnchor.Side.TopLeft;
        Offset.pixelOffset = new Vector2(10, -40);
        int score = Rule.GetScore();

        Text.text = string.Format("Score : {0:D4}", score);
    }
예제 #17
0
    void ClearUI()
    {
        var clearLabel = NGUITools.AddChild(Parent, labelPrefab);

        clearLabel.transform.localScale = new Vector2(60f, 60f);
        Text        = clearLabel.GetComponent("UILabel") as UILabel;
        Text.pivot  = UIWidget.Pivot.Center;
        Offset      = timeLabel.GetComponent("UIAnchor") as UIAnchor;
        Offset.side = UIAnchor.Side.Top;
        Text.text   = "Clear!!";
    }
예제 #18
0
        internal static void AnchorToScreen(UIAnchor anchor, int x, int y, out int out_x, out int out_y)
        {
            int sw = Screen.width;
            int sh = Screen.height - 35;

            switch (anchor)
            {
            // Upper
            case UIAnchor.UpperLeft:
                y = sh - y;
                goto default;

            case UIAnchor.UpperCenter:
                x = (sw / 2) + x;
                y = sh - y;
                goto default;

            case UIAnchor.UpperRight:
                x = sw - x;
                y = sh - y;
                goto default;

            // Middle
            case UIAnchor.MiddleLeft:
                y = (sh / 2) - y;
                goto default;

            case UIAnchor.MiddleCenter:
                x = (sw / 2) + x;
                y = (sh / 2) - y;
                goto default;

            case UIAnchor.MiddleRight:
                x = sw - x;
                y = (sh / 2) - y;
                goto default;

            // Lower
            case UIAnchor.LowerCenter:
                x = (sw / 2) + x;
                goto default;

            case UIAnchor.LowerRight:
                x = sw - x;
                goto default;

            // End
            case UIAnchor.LowerLeft:
            default:
                out_x = x;
                out_y = y;
                break;
            }
        }
예제 #19
0
    private UIWin getUI(WinID ID)
    {
        UIWin UI = null;

        try
        {
            if (ID == WinID.Max)
            {
                return(null);
            }
            UI = UIInstances[(int)ID];
            if (UI == null)
            {
                //there is none can use, then add a new one
                UnityEngine.Object prefab = Resources.Load(string.Format("UI/{0}", ID));
                if (prefab == null)
                {
                    Debug.LogWarning(string.Format("UI/{0} is not exist!", ID));
                    return(null);
                }
                else
                {
                    GameObject go = (GameObject)Instantiate(prefab);
                    go.name = prefab.name;
                    UI      = go.GetComponent <UIWin>();
                    if (!UI)
                    {
                        Debug.LogError(string.Format("UI:{0} has not UIWin component!", ID));
                        return(null);
                    }
                    Transform trans = go.transform;
                    trans.parent         = transform;
                    trans.localScale     = Vector3.one;
                    trans.localPosition  = new Vector3(0, 0, (float)UI.eLayer);
                    UIInstances[(int)ID] = UI;
                    UI.ID = ID;
                    //init anchor
                    UIAnchor anchor = UI.GetComponent <UIAnchor>();
                    if (anchor)
                    {
                        anchor.runOnlyOnce = true;
                        anchor.uiCamera    = UICamera.currentCamera;
                    }
                    go.SetActive(false);
                }
            }
            return(UI);
        }
        catch (System.Exception ex)
        {
            Debug.LogException(ex);
            return(null);
        }
    }
예제 #20
0
    static private bool SetAnchorCameraCallback(Transform tr, object args)
    {
        Camera   cam    = args as Camera;
        UIAnchor anchor = tr.GetComponent <UIAnchor> ();

        if (anchor != null)
        {
            anchor.uiCamera = cam;
        }
        return(false);
    }
예제 #21
0
 static public int get_container(IntPtr l)
 {
     try {
         UIAnchor self = (UIAnchor)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.container);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #22
0
 static public int get_pixelOffset(IntPtr l)
 {
     try {
         UIAnchor self = (UIAnchor)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.pixelOffset);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #23
0
        protected void Init(GameObject root, UIAnchor.Side side)
        {
            this.root = root;
            if (root.GetComponent <UIAnchor>() != null)
            {
                throw new Exception("UXAnchor must not have a UIAnchor added already");
            }
            UIAnchor uIAnchor = root.AddComponent <UIAnchor>();

            uIAnchor.side = side;
            this.uxCamera.AddNewAnchor(root);
        }
예제 #24
0
    protected override void Start()
    {
        if (map == null)
        {
            return;
        }

        mAnchor = GetComponent <UIAnchor>();

        base.Start();
        UpdateAlignment();
    }
예제 #25
0
 public override UILabel AddLabel(UIAnchor anchor, GameObject prefab)
 {
     if (anchor == head)
     {
         var label = anchor.GetComponentInChildren <UILabel>();
         if (label != null)
         {
             return(label);
         }
     }
     return(base.AddLabel(anchor, prefab));
 }
예제 #26
0
    public void Fill(Component com, MyJson.IJsonNode json)
    {
        UIAnchor t     = com as UIAnchor;
        var      jsono = json as MyJson.JsonNode_Object;

        t.uiCamera       = GameObjParser.IDToComponent <Camera>(jsono["uiCamera"] as MyJson.JsonNode_ValueNumber);
        t.container      = GameObjParser.IDToObj(jsono["container"] as MyJson.JsonNode_ValueNumber);
        t.side           = (UIAnchor.Side)Enum.Parse(typeof(UIAnchor.Side), jsono["side"] as MyJson.JsonNode_ValueString);
        t.runOnlyOnce    = jsono["runOnlyOnce"] as MyJson.JsonNode_ValueNumber;
        t.relativeOffset = ComponentTypeConvert.StringToVector2(jsono["relativeOffset"] as MyJson.JsonNode_ValueString);
        t.pixelOffset    = ComponentTypeConvert.StringToVector2(jsono["pixelOffset"] as MyJson.JsonNode_ValueString);
    }
예제 #27
0
 static public int get_side(IntPtr l)
 {
     try {
         UIAnchor self = (UIAnchor)checkSelf(l);
         pushValue(l, true);
         pushEnum(l, (int)self.side);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #28
0
 // Use this for initialization
 void Start()
 {
     MainGame.topLayerCamera = this;
     if (root == null)
     {
         UIAnchor myAnchor = GetComponentInChildren <UIAnchor>();
         if (myAnchor != null)
         {
             root = myAnchor.transform;
         }
     }
 }
 void Awake()
 {
     if (NGUI2DRootPanel.IsHHDScreen)
     {
         UIAnchor anchor = GetComponent <UIAnchor>();
         if (null != anchor)
         {
             anchor.pixelOffset = new Vector2(-200f, -300f);
             anchor.enabled     = true;
         }
     }
 }
예제 #30
0
 static public int get_runOnlyOnce(IntPtr l)
 {
     try {
         UIAnchor self = (UIAnchor)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.runOnlyOnce);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #31
0
        public static void TT()
        {
            if (((Mod_OnGUI_Player)GameState.s_playerCharacter).showGameObjectBrowser == false)
            {
                if (((Mod_OnGUI_Player)GameState.s_playerCharacter).inspecting == null)
                {
                    ((Mod_OnGUI_Player)GameState.s_playerCharacter).inspecting = UICustomizer.UiCamera.transform;
                }

                if (GameBrowserBackground == null)
                {
                    UIMultiSpriteImageButton portraitLast = null;

                    foreach (UIMultiSpriteImageButton btn in UnityEngine.Object.FindObjectsOfType <UIMultiSpriteImageButton>())
                    {
                        if (btn.ToString() == "PartyPortrait(Clone) (UIMultiSpriteImageButton)" && portraitLast == null)
                        {
                            portraitLast = btn;
                        }
                    }

                    GameBrowserBackground             = NGUITools.AddWidget <UITexture>(portraitLast.transform.parent.parent.gameObject);
                    GameBrowserBackground.mainTexture = new Texture2D(500, 500);

                    GameBrowserBackground.transform.localScale = new Vector3(1100f, 600f, 1f);                     // those values are for 1920*1080...
                    //GameBrowserBackground.transform.localScale = new Vector3 (1600f, 800f, 1f); // those values are for 1280*1024

                    // rescaler
                    if (Screen.width != 1920)
                    {
                        float addwidth  = (1920 - Screen.width) * 0.78f;
                        float addheight = (1080 - Screen.height) * 0.55f;
                        GameBrowserBackground.transform.localScale += new Vector3(addwidth, addheight, 0f);
                    }

                    BoxCollider boxColl = NGUITools.AddWidgetCollider(GameBrowserBackground.gameObject); // adding a box collider, it's required for the UINoClick component
                    boxColl.gameObject.AddComponent <UINoClick>();                                       // this prevents clicks from going through the U-frame
                    UIAnchor ank = GameBrowserBackground.gameObject.AddComponent <UIAnchor>();
                    ank.side = UIAnchor.Side.Center;
                }
                else
                {
                    GameBrowserBackground.gameObject.SetActive(true);
                }

                ((Mod_OnGUI_Player)GameState.s_playerCharacter).showGameObjectBrowser = true;                 // temporarily turned off
            }
            else
            {
                GameBrowserBackground.gameObject.SetActive(false);
                ((Mod_OnGUI_Player)GameState.s_playerCharacter).showGameObjectBrowser = false;
            }
        }
예제 #32
0
        /// <summary>
        /// 设置 UI 组件锚点
        /// </summary>
        /// <param name="rectTransform">UI 组件</param>
        /// <param name="x">X 轴锚点</param>
        /// <param name="y">Y 轴锚点</param>
        public static void SetUIAnchor(RectTransform rectTransform, UIAnchor x, UIAnchor y)
        {
            float x1 = 0.5f, x2 = 0.5f, y1 = 0.5f, y2 = 0.5f;

            switch (x)
            {
            case UIAnchor.Left:
                x1 = 0;
                x2 = 0;
                break;

            case UIAnchor.Center:
                x1 = 0.5f;
                x2 = 0.5f;
                break;

            case UIAnchor.Right:
                x1 = 1;
                x2 = 1;
                break;

            case UIAnchor.Stretch:
                x1 = 0;
                x2 = 1;
                break;
            }
            switch (y)
            {
            case UIAnchor.Top:
                y1 = 1;
                y2 = 1;
                break;

            case UIAnchor.Center:
                y1 = 0.5f;
                y2 = 0.5f;
                break;

            case UIAnchor.Bottom:
                y1 = 0;
                y2 = 0;
                break;

            case UIAnchor.Stretch:
                y1 = 0;
                y2 = 1;
                break;
            }

            rectTransform.anchorMin = new Vector2(x1, y1);
            rectTransform.anchorMax = new Vector2(x2, y2);
        }
예제 #33
0
	void Start () 
	{
		if(maxOffset <=0)
			maxOffset = 80;
		joyAnchor = joyStick.GetComponent<UIAnchor>();
		screenSize =new Vector2(Screen.width, Screen.height);
		originalOffset = joyAnchor.relativeOffset;
		
		if(hasDynamic)
			joyStick.SetActiveRecursively(false);
		else
		{
			joyStick.SetActiveRecursively(true);
			
			joyCenter = new Vector2(joyAnchor.relativeOffset.x * Screen.width, joyAnchor.relativeOffset.y * Screen.height);
		}

	}
예제 #34
0
        private GameObject CreateButton(GameObject prefab, string name, UIAnchor anchor, UIPivot pivot, Vector2 offset, out ButtonInfo buttonInfo) {
            buttonInfo = null;
            if(prefab == null) return null;
            
            GameObject instance = UITools.InstantiateGUIObject<ButtonInfo>(
                prefab,
                content.transform,
                name,
                pivot,
                anchor.min,
                anchor.max,
                offset
            );
            if(instance == null) return null;

            buttonInfo = instance.GetComponent<ButtonInfo>();
            Button button = instance.GetComponent<Button>();
            if(button == null) {
                Debug.Log("Button prefab is missing Button component!");
                return null;
            }
            if(buttonInfo == null) {
                Debug.Log("Button prefab is missing ButtonInfo component!");
                return null;
            }
            return instance;
        }
예제 #35
0
 private Target(string name, bool automatic, int manualSize, UIAnchor.Side side)
 {
     this.automatic = automatic;
     this.manualSize = manualSize;
     this.name = name;
     this.side = side;
     this._root = null;
     this._anchor = null;
 }
예제 #36
0
 public override void UpdateAlignment()
 {
     base.UpdateAlignment();
     if (this.mAnchor == null)
     {
         this.mAnchor = base.GetComponent<UIAnchor>();
     }
     if (this.mAnchor != null)
     {
         this.mAnchor.side = (UIAnchor.Side)this.pivot;
     }
     if (base.iconRoot != null)
     {
         base.iconRoot.localPosition = new Vector3(this.rendererTransform.localPosition.x, this.rendererTransform.localPosition.y, 1f);
     }
     if (this.overlay != null && NJGMap.instance.atlas != null)
     {
         UISpriteData sprite = NJGMap.instance.atlas.GetSprite(this.overlay.spriteName);
         if (sprite != null)
         {
             Vector4 border = this.overlay.border;
             this.overlay.width = (int)this.mapScale.x + (int)(border.x + border.z + (float)this.overlayBorderOffset);
             this.overlay.height = (int)this.mapScale.y + (int)(border.y + border.w + (float)this.overlayBorderOffset);
         }
     }
 }
예제 #37
0
 public static Vector3 WorldOrigin(Camera camera, UIAnchor.Side side, RectOffset offset, bool halfPixel)
 {
     Vector3 vector3 = new Vector3();
     UIAnchor.Flags flag;
     vector3.z = 0f;
     Rect rect = offset.Add(camera.pixelRect);
     float single = rect.xMin;
     float single1 = rect.xMax;
     float single2 = rect.yMin;
     float single3 = rect.yMax;
     UIAnchor.Side side1 = side;
     float single4 = single;
     float single5 = single1;
     float single6 = single2;
     float single7 = single3;
     if (camera.isOrthoGraphic)
     {
         flag = (!halfPixel ? UIAnchor.Flags.CameraIsOrthographic : UIAnchor.Flags.CameraIsOrthographic | UIAnchor.Flags.HalfPixelOffset);
     }
     else if (!halfPixel)
     {
         flag = (UIAnchor.Flags)0;
     }
     else
     {
         flag = UIAnchor.Flags.HalfPixelOffset;
     }
     UIAnchor.ScreenOrigin(side1, single4, single5, single6, single7, flag, out vector3.x, out vector3.y);
     return camera.ScreenToWorldPoint(vector3);
 }
예제 #38
0
 public static void ScreenOrigin(UIAnchor.Side side, float xMin, float xMax, float yMin, float yMax, float relativeOffsetX, float relativeOffsetY, out float x, out float y)
 {
     float single;
     float single1;
     UIAnchor.ScreenOrigin(side, xMin, xMax, yMin, yMax, out single, out single1);
     x = single + relativeOffsetX * (xMax - xMin);
     y = single1 + relativeOffsetY * (yMax - yMin);
 }
예제 #39
0
파일: UITools.cs 프로젝트: hjrhjr/Beats2
 /// <summary>
 /// Adds an anchor to an object and set it's initial local position
 /// </summary>
 public static UIAnchor AddAnchor(GameObject gameObj, UIAnchor.Side side)
 {
     UIAnchor anchor = gameObj.AddComponent<UIAnchor>();
     anchor.side = side;
     return anchor;
 }
예제 #40
0
 public void AddContentText(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset, string text) {
     AddContentText(prefab, pivot, anchor, offset);
     SetContentText(text, _contentText.Count - 1);
 }
예제 #41
0
 public void AddContentText(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset) {
     Text text = null;
     CreateText(prefab, ref text, "Content Text", pivot, anchor, offset);
     _contentText.Add(text);
 }
예제 #42
0
    protected override void AwakeImpl()
    {
        base.AwakeImpl();

        m_ViewSpriteTr = transform.FindChild("ListBaseSprite");
        m_ViewScale = m_ViewSpriteTr.localScale;
        m_TopLeft = transform.FindChild("ListBaseSprite/TopLeft");
        m_BottomRight = transform.FindChild("ListBaseSprite/BottomRight");
        //m_DragCamera = transform.FindChild("ListBaseSprite").GetComponent<UIDragCamera>();
        NvGameUIManager mgr = Singlton.getInstance("NvGameUIManager") as NvGameUIManager;
        m_UICamera = mgr.GameUICamera;

        m_ListPrefab = Resources.Load("UI Prefabs/Prefabs/Controls/UIListView") as GameObject;
        m_ListView = GameObject.Instantiate( m_ListPrefab ) as GameObject;
        //rename list view
        m_ListView.name = listName;
        Transform listviewCamera = m_ListView.transform.FindChild("UIListViewCamera");
        //Transform listviewCamera = m_ListView.transform.FindChild("UIListViewCamera" );
        //m_ListViewCamera = listviewCamera.GetComponent<UIDraggableCamera>();
        //rename list view draggable camera
        //m_ListViewCamera.name = listName + "Camera";
        //set draggable camera to drag camera
        //m_DragCamera.draggableCamera = m_ListViewCamera;
        m_ListViewViewport = listviewCamera.GetComponent<UIViewport>();
        //set viewport camera
        m_ListViewViewport.sourceCamera = m_UICamera;
        m_ListViewLink = m_ListView.transform.FindChild("Link");
        m_ListViewLink.localScale = Utility.GetScreenRatio();
        Transform listOffset = m_ListView.transform.FindChild("Link/Anchor/ListOffset");
        listOffset.transform.localPosition = new Vector3 ( dragCameraDistance, dragCameraDistance, listOffset.transform.localPosition.z );
        m_ListViewTable = listOffset.GetComponent<UITable>();
        m_listViewAnchor = m_ListView.transform.FindChild("Link/Anchor").GetComponent<UIAnchor>();
        //m_DragPanel = m_ListView.transform.FindChild("Link/Anchor/ListOffset").GetComponent<UIDraggablePanel>();
        //set ui layer camera to list view anchor
        m_listViewAnchor.uiCamera = m_UICamera;
        //set slider bar
        if ( horizontalScrollBar != null )
        {
            m_horizontalScrollBar = horizontalScrollBar.GetComponent<UIScrollBar>();
            //m_DragPanel.scale = new Vector3( 1.0f, 0.0f, 0.0f );
            //m_DragPanel.horizontalScrollBar = m_horizontalScrollBar;
        }
        if ( verticalScrollBar != null )
        {
            m_verticalScrollBar = verticalScrollBar.GetComponent<UIScrollBar>();
            //m_DragPanel.scale = new Vector3( 0.0f, 1.0f, 0.0f );
            //m_DragPanel.verticalScrollBar = m_verticalScrollBar;
        }
    }
예제 #43
0
 /// <summary>
 /// Find all needed components.
 /// </summary>
 void Awake()
 {
     mAnchor = GetComponent<UIAnchor>();
 }
예제 #44
0
 public Target(string name, UIAnchor.Side side)
     : this(name, true, 1000, side)
 {
 }
예제 #45
0
    private void CreateNotes()
    {
        if (noteIndex < notes.Count)
        {
            if (notes[noteIndex].startTotal < timeLapsed + timeOffset)
            {
                pos = spawnPositions[notes[noteIndex].pitchPosition];
                color = notes[noteIndex].color;
                noteWidth = notes[noteIndex].noteDuration * lengthRatio;

                switch(notes[noteIndex].color)
                {
                    case Note.NoteColor.Blue:
                    case Note.NoteColor.Yellow:
                    case Note.NoteColor.Green:
                    case Note.NoteColor.Red:
                    {
                        GameObject newNote = (GameObject)Instantiate(singlePrefab);
                        newNote.transform.parent = noteParent.transform;
                        newNote.transform.localScale = Vector3.one;
                        newNote.name = notesSpawned.ToString() + ": Note (" + notes[noteIndex].color.ToString() + ")";

                        rNote = newNote.GetComponent<RhythmNote>();
                        rNote.Init(pos, color, noteWidth, gameObject);
                        notesSpawned++;
                        break;
                    }
                    default:
                    {
                        GameObject newNote = (GameObject)Instantiate(doublePrefab);
                        newNote.transform.parent = noteParent.transform;
                        newNote.transform.localScale = Vector3.one;
                        newNote.name = notesSpawned.ToString() + ": Note (" + notes[noteIndex].color.ToString() + ")";

                        rNote = newNote.GetComponent<RhythmNote>();
                        rNote.Init(pos, color, noteWidth, gameObject);
                        notesSpawned++;
                        break;
                    }
                }

                noteIndex++;
            }
        }
    }
예제 #46
0
 public void AddContentImage(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset) {
     CreateImage(prefab, "Image", pivot, anchor, offset);
 }
예제 #47
0
    void Start()
    {
        if (!anchor)
        {
            anchor = gameObject.GetComponent<UIAnchor>();
        }

        if (bar1 && !barStretch1)
        {
            barStretch1 = bar1.gameObject.GetComponent<UIStretch>();
        }

        if (bar2 && !barStretch2)
        {
            barStretch2 = bar2.gameObject.GetComponent<UIStretch>();
        }
    }
예제 #48
0
 public void AddContentImage(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset, string text) {
     AddContentImage(prefab, pivot, anchor, offset);
 }
예제 #49
0
 void Start()
 {
     cursorPos = cursor.GetComponent<UIAnchor> ();
     keys = System.Enum.GetNames(typeof(KeyCode)).Length;
 }
예제 #50
0
        public void CreateButton(GameObject prefab, UIPivot pivot, UIAnchor anchor, Vector2 offset, string buttonText, UnityAction confirmCallback, UnityAction cancelCallback, bool setDefault) {
            if(prefab == null) return;
            ButtonInfo buttonInfo;
            GameObject instance = CreateButton(prefab, "Button", anchor, pivot, offset, out buttonInfo);
            if(instance == null) return;
            Button button = instance.GetComponent<Button>();
            if(confirmCallback != null) button.onClick.AddListener(confirmCallback);

            // Create a UI cancel event for this button
            CustomButton customButton = button as CustomButton;
            if(cancelCallback != null && customButton != null) customButton.CancelEvent += cancelCallback;

            if(buttonInfo.text != null) buttonInfo.text.text = buttonText;
            if(setDefault) _defaultUIElement = instance;
        }
예제 #51
0
 public static void ScreenOrigin(UIAnchor.Side side, float xMin, float xMax, float yMin, float yMax, UIAnchor.Flags flags, out float x, out float y)
 {
     float single;
     float single1;
     float single2;
     float single3;
     switch ((byte)(flags & (!UIAnchor.Info.isWindows ? UIAnchor.Flags.CameraIsOrthographic : UIAnchor.Flags.CameraIsOrthographic | UIAnchor.Flags.HalfPixelOffset)))
     {
         case 1:
         {
             UIAnchor.ScreenOrigin(side, xMin, xMax, yMin, yMax, out single, out single1);
             x = Mathf.Round(single);
             y = Mathf.Round(single1);
             break;
         }
         case 2:
         {
             UIAnchor.ScreenOrigin(side, xMin, xMax, yMin, yMax, out x, out y);
             break;
         }
         case 3:
         {
             UIAnchor.ScreenOrigin(side, xMin, xMax, yMin, yMax, out single2, out single3);
             x = Mathf.Round(single2) - 0.5f;
             y = Mathf.Round(single3) + 0.5f;
             break;
         }
         default:
         {
             goto case 2;
         }
     }
 }
예제 #52
0
        // Private Methods

        private void CreateText(GameObject prefab, ref Text textComponent, string name, UIPivot pivot, UIAnchor anchor, Vector2 offset) {
            if(prefab == null || content == null) return;
            if(textComponent != null) {
                Debug.LogError("Window already has " + name + "!");
                return;
            }

            GameObject instance = UITools.InstantiateGUIObject<Text>(
                prefab,
                content.transform,
                name,
                pivot,
                anchor.min,
                anchor.max,
                offset
            );
            if(instance == null) return;
            textComponent = instance.GetComponent<Text>();
        }
예제 #53
0
 public static void ScreenOrigin(UIAnchor.Side side, float xMin, float xMax, float yMin, float yMax, out float x, out float y)
 {
     switch (side)
     {
         case UIAnchor.Side.BottomLeft:
         {
             x = xMin;
             y = yMin;
             break;
         }
         case UIAnchor.Side.Left:
         {
             x = xMin;
             y = (yMin + yMax) / 2f;
             break;
         }
         case UIAnchor.Side.TopLeft:
         {
             x = xMin;
             y = yMax;
             break;
         }
         case UIAnchor.Side.Top:
         {
             x = (xMin + xMax) / 2f;
             y = yMax;
             break;
         }
         case UIAnchor.Side.TopRight:
         {
             x = xMax;
             y = yMax;
             break;
         }
         case UIAnchor.Side.Right:
         {
             x = xMax;
             y = (yMin + yMax) / 2f;
             break;
         }
         case UIAnchor.Side.BottomRight:
         {
             x = xMax;
             y = yMin;
             break;
         }
         case UIAnchor.Side.Bottom:
         {
             x = (xMin + xMax) / 2f;
             y = yMin;
             break;
         }
         case UIAnchor.Side.Center:
         {
             x = (xMin + xMax) / 2f;
             y = (yMin + yMax) / 2f;
             break;
         }
         default:
         {
             throw new ArgumentOutOfRangeException();
         }
     }
 }
예제 #54
0
        private void CreateImage(GameObject prefab, string name, UIPivot pivot, UIAnchor anchor, Vector2 offset) {
            if(prefab == null || content == null) return;

            UITools.InstantiateGUIObject<Image>(
                prefab,
                content.transform,
                name,
                pivot,
                anchor.min,
                anchor.max,
                offset
            );
        }
예제 #55
0
 protected override void Start()
 {
     if (this.map == null)
     {
         return;
     }
     this.mAnchor = base.GetComponent<UIAnchor>();
     base.Start();
     this.UpdateAlignment();
 }
예제 #56
0
 public Target(string name, int manualSize, UIAnchor.Side side)
     : this(name, false, manualSize, side)
 {
 }