Beispiel #1
0
        protected override void InitCanvas()
        {
            titleContent = new GUIContent("AI Designer");
            base.InitCanvas();
            GraphCanvas.LocalRect = new Rect(-50000, -50000, 100000, 100000);

            mWires = new BTWireGUI(this);
            GraphCanvas.AddElement(mWires);

            AIGraph           = new EditorGUICanvas();
            AIGraph.LocalRect = new Rect(-50000, -50000, 100000, 100000);
            GraphCanvas.AddElement(AIGraph);

            RootNode = new BTRootNodeGUI(this);
            AIGraph.AddElement(RootNode);

            BlackboardMonitor           = new BlackboardMonitorGUI(this);
            BlackboardMonitor.LocalRect = new Rect(0, 0, 200, 180);
            RootCanvas.AddElement(BlackboardMonitor);

            HelpBox           = new BehaviourHelpGUI();
            HelpBox.SortOrder = -10;
            RootCanvas.AddElement(HelpBox);

            mSelectionRect         = new EditorSelection();
            mSelectionRect.Visible = false;
            GraphCanvas.AddElement(mSelectionRect);

            Tip = new TipBox();
            RootCanvas.AddElement(Tip);

            RootCanvas.Resort(true);
        }
Beispiel #2
0
        private static ToastsUi InitToastsUi()
        {
            var targetCanvas   = RootCanvas.GetOrAddRootCanvas().gameObject;
            var toastContainer = targetCanvas.AddChild(ResourcesV2.LoadPrefab("Messages/ToastContainer1"));

            return(toastContainer.GetOrAddComponent <ToastsUi>());
        }
Beispiel #3
0
        public override IEnumerator RunTest()
        {
            // Show some empty view as a background for the toasts:
            ViewStackHelper.MainViewStack().ShowView(someUiScreenPrefabName);

            Toast.Show("Some toast 1", "Lorem ipsum 1");
            yield return(new WaitForSeconds(1));

            Toast.Show("Some toast 2");

            // In between show another screen on the main view stack, to ensure it does not interrupt showing the toasts:
            ViewStackHelper.MainViewStack().SwitchToView(someUiScreenPrefabName);

            yield return(new WaitForSeconds(1));

            var toast3 = Toast.Show("Some toast 3", "Lorem ipsum 3", 2500);

            AssertV2.IsFalse(toast3.IsDestroyed(), "Toast was already destroyed");
            yield return(new WaitForSeconds(3));

            AssertV2.IsTrue(toast3.IsDestroyed(), "Toast could not be destroyed");

            RootCanvas.GetAllRootCanvases().Single().gameObject.Destroy();
            Toast.Show("Some toast 4");
            yield return(new WaitForSeconds(3));
        }
Beispiel #4
0
        static void AddViewInViewStack()
        {
            RootCanvas.GetOrAddRootCanvas(); // Ensure there is a root canvas
            var view = AddViewToRootCanvas(ResourcesV2.LoadPrefab("Canvas/DefaultViewStackView"));

            view.name = "View " + (view.transform.GetSiblingIndex() + 1);
        }
Beispiel #5
0
        private static SnackbarsUi InitSnackbarsUi()
        {
            var targetCanvas      = RootCanvas.GetOrAddRootCanvasV2().gameObject;
            var snackbarContainer = targetCanvas.AddChild(ResourcesV2.LoadPrefab("Messages/SnackbarContainer1"));

            return(snackbarContainer.GetOrAddComponent <SnackbarsUi>());
        }
Beispiel #6
0
    /// <summary>
    /// 获取用户信息
    /// </summary>
    /// <param name="str"></param>
    void getUserMessege(string str)
    {
        JsonData jso = JsonMapper.ToObject(str);

        if ((string)jso["code"] == "0")
        {
            JsonData js = jso["data"];
            if (js.Keys.Contains("mobile"))//如果手机已经绑定了,传回手机信息,否则不传
            {
                mobilenumber = true;
                RootCanvas.canvas_group(GameObject.Find("number_Image").GetComponent <CanvasGroup>(), true, 1);
                RootCanvas.canvas_group(GameObject.Find("mobileUnBindleSure").GetComponent <CanvasGroup>(), true, 1);
                RootCanvas.canvas_group(GameObject.Find("mobile_InputField").GetComponent <CanvasGroup>(), false, 0);
                RootCanvas.canvas_group(GameObject.Find("mobileBindleSure").GetComponent <CanvasGroup>(), false, 0);
                GameObject.Find("mobile_number").GetComponent <Text>().text = js["mobile"].ToString();
            }
            else
            {
                mobilenumber = false;
                RootCanvas.canvas_group(GameObject.Find("number_Image").GetComponent <CanvasGroup>(), false, 0);
                RootCanvas.canvas_group(GameObject.Find("mobileUnBindleSure").GetComponent <CanvasGroup>(), false, 0);
                RootCanvas.canvas_group(GameObject.Find("mobile_InputField").GetComponent <CanvasGroup>(), true, 1);
                RootCanvas.canvas_group(GameObject.Find("mobileBindleSure").GetComponent <CanvasGroup>(), true, 1);
            }
            httpView.instant.getname(js["nickName"].ToString(), js["code"].ToString(), int.Parse(js["experience"].ToString()), int.Parse(js["gold"].ToString()), js["headImg"].ToString(), js["id"].ToString(), js["userType"].ToString(), js["isVip"].ToString(), js["isBind"].ToString(), int.Parse(js["vipLevel"].ToString()));
        }
    }
Beispiel #7
0
    /// <summary>
    /// 推广员
    /// </summary>
    void tuiGuangYuan(GameObject g)
    {
        buttonBehind.transform.Find("tuiGuangyuan").localScale = Vector3.one;
        RootCanvas.canvas_group(GameObject.Find("Canvas_button").GetComponent <CanvasGroup>(), true, 1);
#if UNITY_IOS
        if (weiXinLoad.instance.AndroidFunction)
        {
            buttonBehind.transform.Find("tuiGuangyuan").GetChild(6).localScale = Vector3.one;
        }
        else
        {
            if (weiXinLoad.instance.ServerIdentifyStr.Equals("1"))
            {
                buttonBehind.transform.Find("tuiGuangyuan").GetChild(6).localScale = Vector3.zero;
            }
            else
            {
                buttonBehind.transform.Find("tuiGuangyuan").GetChild(6).localScale = Vector3.one;
            }
        }
#endif
        //string filename = "/huidao.png";
        //string destination = Application.persistentDataPath;
        //string path = destination + filename;
        //if (Directory.Exists(path))   //判断目录是否存在,不存在则会创建目录
        //{
        //    Directory.Delete(path);
        //}
        //else
        //{
        //    return;
        //}
    }
Beispiel #8
0
    /// <summary>
    /// 匿名方法
    /// </summary>
    /// <param name="name"></param>
    public void lamada(string name)
    {
        Transform transf = buttonBehind.transform.Find(name);

        if (name.Contains("customServe"))
        {
            transf.localPosition = new Vector3(transf.localPosition.x, transf.localPosition.y, 0);
        }
        else
        {
            transf.localScale = Vector3.one;
        }



#if UNITY_IOS
        if (transf.name.Contains("customServe"))
        {
            if (UnitySendMessageToiOS.Instante().checkInstallWeChat() != 0 && weiXinLoad.instance.AndroidFunction == false)
            {
                Transform transf2 = transf.GetChild(3).GetChild(1);
                for (int i = 2; i < 6; ++i)
                {
                    transf2.GetChild(i).GetChild(1).localScale = Vector3.zero;
                }
            }
        }
#endif
        RootCanvas.find("backGround").transform.localScale = Vector3.one;//显示阴影背景
    }
 void OnKeyDown()
 {
     if (RootCanvas.InteractKeyDown(Event.current.keyCode))
     {
         Event.current.Use();
     }
 }
Beispiel #10
0
 /// <summary>
 /// 绑定切换提现界面
 /// </summary>
 void close_()
 {
     if (WithDraw_Sp.instance.return_blind == true)
     {
         if (GameObject.Find("mobileBindle").transform.localScale == Vector3.one)
         {
             GameObject.Find("Withdraw").transform.localScale = Vector3.one;
         }
         else
         {
             GameObject.Find("Withdraw").transform.localScale   = Vector3.zero;
             RootCanvas.find("backGround").transform.localScale = Vector3.zero;//显示阴影背景
         }
         GameObject.Find("mobileBindle").transform.localScale = Vector3.zero;
         WithDraw_Sp.instance.return_blind = false;
         GameObject.Find("yanZhengMa_InputField").GetComponent <InputField>().text = null;
     }
     else
     {
         for (int i = 0; i < buttonBehind.transform.childCount; ++i)
         {
             buttonBehind.transform.GetChild(i).localScale = Vector3.zero;
         }
         RootCanvas.find("backGround").transform.localScale = Vector3.zero;//显示阴影背景
     }
 }
Beispiel #11
0
        private static LogConsoleUi InitLogConsoleUi()
        {
            var targetCanvas   = RootCanvas.GetOrAddRootCanvas().gameObject;
            var toastContainer = targetCanvas.AddChild(ResourcesV2.LoadPrefab("Messages/LogConsoleUi1"));

            return(toastContainer.GetComponentInChildren <LogConsoleUi>());
        }
Beispiel #12
0
        private static ProgressUi NewGlobalProgressUi(ProgressManager pm, string prefab = "Progress/GlobalProgressOverlay1")
        {
            ProgressUi progressUi;
            var        go = RootCanvas.GetOrAddRootCanvasV2().gameObject.AddChild(ResourcesV2.LoadPrefab(prefab));

            progressUi = go.GetComponentInChildren <ProgressUi>();
            progressUi.progressManager = pm;
            return(progressUi);
        }
Beispiel #13
0
        private async Task SimulateConfirmButtonClick()
        {
            if (simulateUserInput)
            {
                await TaskV2.Delay(waitDurationPerDialogInMS);

                Log.d("Now simulating the user clicking on the confirm button");
                RootCanvas.GetOrAddRootCanvas().gameObject.GetLinkMap().Get <Button>("ConfirmButton").onClick.Invoke();
            }
        }
Beispiel #14
0
        private static GameObject AddViewToRootCanvas(GameObject viewInViewStack)
        {
            Canvas rootCanvas = RootCanvas.GetOrAddRootCanvas();

            rootCanvas.gameObject.AddChild(viewInViewStack);
            viewInViewStack.name += " " + rootCanvas.gameObject.GetChildCount();
            viewInViewStack.GetOrAddComponent <RectTransform>().SetAnchorsStretchStretch();
            SelectInHirarchyUi(viewInViewStack);
            return(viewInViewStack);
        }
Beispiel #15
0
 bool OnGraphDrag(EMouseButton button, Vector2 mousePosition, Vector2 delta)
 {
     if (button == EMouseButton.left)
     {
         Rect rect = SelectionRect.LocalRect;
         rect.size = RootCanvas.CalculateLocalPosition(mousePosition) - rect.position;
         SelectionRect.LocalRect = rect;
         return(true);
     }
     return(false);
 }
 void OnKeyUp()
 {
     if (RootCanvas.InteractKeyUp(Event.current.keyCode))
     {
         return;
     }
     if (Event.current.control && Event.current.keyCode == KeyCode.F)
     {
         focusCenter = true;
     }
 }
Beispiel #17
0
        static void AddRootCanvas()
        {
            var foundCanvas = RootCanvas.GetAllRootCanvases().FirstOrDefault();

            if (foundCanvas != null)
            {
                Log.e("There is already a root canvas in the scene");
                SelectInHirarchyUi(foundCanvas);
                return;
            }
            AddViewInViewStack();
        }
        protected virtual void OnCanvasGUI()
        {
            GUI.BeginClip(clipRect);
            GlobalMousePosition = Event.current.mousePosition;
            Rect r = new Rect(Vector2.zero, clipRect.size);

            RootCanvas.LocalRect   = r;
            ScaledCanvas.LocalRect = r;
            RootCanvas.CalculateGlobalRect(true);
            OnResized();
            RootCanvas.OnGUI(r);
            GUI.EndClip();
        }
Beispiel #19
0
 //======================================================================
 /// <summary>
 /// 手机绑定
 /// </summary>
 /// <param name="g"></param>
 void phoneBindle()
 {
     if (netConnect.instance.m_state == login_state.wechat)
     {
         buttonBehind.transform.Find("mobileBindle").localScale  = Vector3.one;
         buttonBehind.transform.Find("accountBindle").localScale = Vector3.zero;
         RootCanvas.find("backGround").transform.localScale      = Vector3.one;//显示阴影背景
     }
     else
     {
         netConnect.Ani(15);
     }
 }
 void OnDrag()
 {
     if (RootCanvas.InteractDrag(mouseButton, GlobalMousePosition, mouseDeltaPos))
     {
         return;
     }
     if (mouseButton == EMouseButton.middle || mouseButton == EMouseButton.right)
     {
         Rect rect = GraphCanvas.LocalRect;
         rect.position        += mouseDeltaPos / (GraphCanvas.GlobalScale > 0 ? GraphCanvas.GlobalScale : 1);
         GraphCanvas.LocalRect = rect;
     }
 }
Beispiel #21
0
 /// <summary>
 /// 按钮方法
 /// </summary>
 /// <param name="g"></param>
 public void close(GameObject g)
 {
     if (g.name.Contains("cus_Close"))
     {
         g.transform.parent.transform.localPosition = new Vector3(g.transform.parent.transform.localPosition.x, g.transform.parent.transform.localPosition.y, -100000);
     }
     else
     {
         g.transform.parent.gameObject.transform.localScale = Vector3.zero;
     }
     RootCanvas.find("backGround").transform.localScale = Vector3.zero;//把阴影背景缩放为零
     RootCanvas.canvas_group(GameObject.Find("Canvas_button").GetComponent <CanvasGroup>(), false, 0);
 }
Beispiel #22
0
 /// <summary>
 /// 游戏通关界面按钮
 /// </summary>
 void GameAllSucessUIButton()
 {
     EventTriggerListener.GetName("AllSucessReturnButton").onClick = delegate(GameObject obj)
     {
         RootCanvas.setActive("BoderRedImage/AllSucess", false);
         SceneManager.LoadSceneAsync(3);
     };
     EventTriggerListener.GetName("AllSucessExitButton").onClick = delegate(GameObject obj)
     {
         RootCanvas.setActive("BoderRedImage/AllSucess", false);
         SceneManager.LoadSceneAsync(1);
     };
 }
Beispiel #23
0
    public void InitGameMainData(string level, string enemyCount)
    {
        RootCanvas.GetComponentForName <Text>("levelText").text = level;
        RootCanvas.GetComponentForName <Text>("EnemyText").text = enemyCount;

        EventTriggerListener.GetName("B").onClick = delegate(GameObject obj)
        {
            ARGun.Instance.Send(obj.name);
        };
        EventTriggerListener.GetName("A").onClick = delegate(GameObject obj)
        {
            ARGun.Instance.Send(obj.name);
        };
    }
Beispiel #24
0
 bool OnGraphDragBegin(EMouseButton button, Vector2 mousePosition)
 {
     if (button == EMouseButton.left)
     {
         Rect rect = SelectionRect.LocalRect;
         rect.size               = Vector2.zero;
         rect.position           = RootCanvas.CalculateLocalPosition(mousePosition);
         SelectionRect.LocalRect = rect;
         SelectionRect.Visible   = true;
         SelectComment(null, false);
         return(true);
     }
     return(false);
 }
Beispiel #25
0
        public GridIndexWindow()
        {
            InitializeComponent();

            RootCanvas.Width          = WIDTH;
            RootCanvas.Height         = HEIGHT;
            GridCanvas.Width          = WIDTH;
            GridCanvas.Height         = HEIGHT;
            ShapCanvas.Width          = WIDTH;
            ShapCanvas.Height         = HEIGHT;
            GridIndexesListBox.Height = HEIGHT + 120;
            RootCanvas.SetValue(MarginProperty, new Thickness(30d));
            CanvasGrid.Clip = new RectangleGeometry(new Rect(0, 0, WIDTH + 60d, HEIGHT + 60d));
            DrawGrid();
            GridIndexesListBox.DataContext = this;
        }
Beispiel #26
0
 /// <summary>
 /// 记录邮件
 /// </summary>
 void record_email()
 {
     for (int i = 0; i < transform.childCount; i++)
     {
         int a = i;
         transform.GetChild(a).GetComponent <Button>().onClick.AddListener(() =>
         {
             RootCanvas.canvas_group(GameObject.Find("email_view").GetComponent <CanvasGroup>(), false, 0);
             RootCanvas.canvas_group(GameObject.Find("email").GetComponent <CanvasGroup>(), true, 1);
             transform.GetChild(a).GetComponent <Image>().sprite = Resources.Load <Sprite>("Rank/read");
             GameObject.Find("email").transform.GetChild(0).GetComponent <Text>().text = transform.GetChild(a).GetChild(2).GetComponent <Text>().text;
             GameObject.Find("email").transform.GetChild(1).GetComponent <Text>().text = transform.GetChild(a).GetChild(0).GetComponent <Text>().text;
             ss(a);
         });
     }
 }
Beispiel #27
0
    /// <summary>
    /// 用来控制对象的隐藏或显示
    /// 可以完成某个对象缩放成0到1的隐藏和显示
    /// </summary>
    /// <param name="name"></param>
    /// <param name="f"></param>
    public static void setActive(string name, bool f)
    {
        GameObject obj = RootCanvas.find(name);

        if (obj != null)
        {
            if (obj.transform.localScale.x <= 0)
            {
                obj.transform.localScale = f ? Vector3.one : Vector3.zero;
            }
            else
            {
                obj.SetActive(f);
            }
        }
    }
Beispiel #28
0
        public BehaviourTreeDesignerWindow() : base()
        {
            mMaxScale            = 2;
            GraphCanvas.GridSize = 200;
            SelectionRect        = new SelectionGUI();
            RootCanvas.AddElement(SelectionRect);
            ScaledCanvas.Pivot = new Vector2(0.5f, 0.25f);
            GraphCanvas.Pivot  = new Vector2(0.5f, 0.1f);
            Rect r = GraphCanvas.LocalRect;

            r.position            = new Vector2(-0.5f * r.width, -0.1f * r.height);
            GraphCanvas.LocalRect = r;

            TreeGraph = new Graph <PaintElement>(1);

            Rect grect = new Rect(-GraphCanvas.LocalRect.size * 0.5f, GraphCanvas.LocalRect.size);
            BehaviourTreeWireGUI wires = new BehaviourTreeWireGUI(this);

            wires.LocalRect = grect;
            GraphCanvas.AddElement(wires);

            TreeCanvas           = new EditorGUICanvas();
            TreeCanvas.LocalRect = grect;
            GraphCanvas.AddElement(TreeCanvas);

            CommentCanvas           = new EditorGUICanvas();
            CommentCanvas.SortOrder = -2;
            CommentCanvas.LocalRect = grect;
            GraphCanvas.AddElement(CommentCanvas);

            ContextMenu = new BehaviourTreeContextMenuGUI(this);
            GraphCanvas.AddElement(ContextMenu);

            BlackboardMonitorGUI blackboard = new BlackboardMonitorGUI(this);

            blackboard.LocalRect = new Rect(0, 0, 200, 180);
            RootCanvas.AddElement(blackboard);

            RootCanvas.Resort(true);

            GraphCanvas.OnDragBegin  = OnGraphDragBegin;
            GraphCanvas.OnDrag       = OnGraphDrag;
            GraphCanvas.OnDragEnd    = OnGraphDragEnd;
            GraphCanvas.OnMouseClick = OnGraphClick;
            GraphCanvas.OnKeyUp      = OnGraphKeyUp;
        }
Beispiel #29
0
        /// <summary> This example shows how to use the DialogLoader manually to have full control over the UI presenter </summary>
        private async Task UseDialogLoaderManually()
        {
            var loader = new DialogLoader <ConfirmCancelDialog>(new ConfirmCancelDialog(caption: "I am a dialog",
                                                                                        message: "I can be awaited in the code, the async or coroutine can wait for the user " +
                                                                                        "to make a decision (select cancel or confirm) before the code continues!"));
            GameObject dialogUi = loader.LoadDialogPrefab(new ConfirmCancelDialog.DefaultPresenter(),
                                                          dialogPrefabName: "Dialogs/DefaultDialog1");

            RootCanvas.GetOrAddRootCanvas().gameObject.AddChild(dialogUi); // Add dialog UI in a canvas
            var waitForUserInputInDialogTask = loader.ShowDialogAsync();

            AssertV2.IsFalse(loader.data.dialogWasConfirmed, "Dialog was already confirmed!");
            await SimulateConfirmButtonClick();

            ConfirmCancelDialog dialog = await waitForUserInputInDialogTask; // Wait until user clicks cancel or confirm

            AssertV2.IsTrue(dialog.dialogWasConfirmed, "Dialog was not confirmed!");
        }
Beispiel #30
0
        /// <summary> The first example here demonstrates how a progress manager can be
        /// created and then shown in a global progress UI (that is eg shown on top of all
        /// screens). This manager can be set as a global singlton to use it from anywhere
        /// in your logic and show overall progress indication of background tasks to the
        /// user to give them a sense of the amount of work that is currently happening
        /// and when it will approximatly be done. </summary>
        private void SetupGlobalProgressUi()
        {
            var pm1             = new ProgressManager();
            var uisInRootCanvas = RootCanvas.GetOrAddRootCanvasV2().gameObject.GetChildren();
            // Find the single one that has a progress UI attached to it and assume its the global process UI screen to be used:
            var globalProgressUi = uisInRootCanvas.Single(x => x.GetComponentV2 <ProgressUi>() != null).GetComponentV2 <ProgressUi>();

            globalProgressUi.progressManager = pm1;

            int id  = 0;
            var map = gameObject.GetLinkMap();

            map.Get <Button>("NewProgress").SetOnClickAction(delegate {
                id++;
                pm1.GetOrAddProgress("Progress:" + id, totalCount, true);
            });
            map.Get <Button>("IncrementCurrentProgress").SetOnClickAction(delegate {
                pm1.GetProgress("Progress:" + id).IncrementCount();
            });
        }