Ejemplo n.º 1
0
        public void CanWriteCustomData()
        {
            string usdFile = System.IO.Path.Combine(UnityEngine.Application.dataPath, "sceneFile.usda");

            filesToDelete.Add(usdFile);
            // Populate Values.
            var value = new MyCustomData();

            value.aString       = "IT'S ALIIIIIIIIIIIIIVE!";
            value.anArrayOfInts = new int[] { 1, 2, 3, 4 };
            value.aBoundingBox  = new UnityEngine.Bounds();

            // Writing the value.
            var scene = Scene.Create(usdFile);

            scene.Time = 1.0;
            scene.Write("/someValue", value);
            Debug.Log(scene.Stage.GetRootLayer().ExportToString());
            scene.Save();
            scene.Close();

            Assert.IsTrue(File.Exists(usdFile));

            // Reading the value.
            Debug.Log(usdFile);
            var newValue = new MyCustomData();

            scene      = Scene.Open(usdFile);
            scene.Time = 1.0;
            scene.Read("/someValue", newValue);

            Assert.AreEqual(value.aString, newValue.aString);

            scene.Close();
        }
        public void CreatedSubscriptionDoesNotRoundDownForPeriodLessData()
        {
            var data = new MyCustomData
            {
                Time   = new DateTime(2020, 5, 21, 8, 9, 0),
                Symbol = Symbols.SPY
            };

            var config = new SubscriptionDataConfig(
                typeof(TradeBar),
                Symbols.SPY,
                Resolution.Hour,
                TimeZones.Utc,
                TimeZones.Utc,
                false,
                false,
                false
                );

            var exchangeHours  = SecurityExchangeHours.AlwaysOpen(TimeZones.Utc);
            var offsetProvider = new TimeZoneOffsetProvider(TimeZones.Utc, new DateTime(2020, 5, 21), new DateTime(2020, 5, 22));

            var subscription = SubscriptionData.Create(config, exchangeHours, offsetProvider, data);

            Assert.AreEqual(new DateTime(2020, 5, 21, 8, 9, 0), subscription.Data.Time);
            Assert.AreEqual(new DateTime(2020, 5, 21, 8, 9, 0), subscription.Data.EndTime);
        }
Ejemplo n.º 3
0
        static void TaskDemo2()
        {
            // Create the task object by using an Action(Of Object) to pass in custom data
            // in the Task constructor. This is useful when you need to capture outer variables
            // from within a loop. As an experiment, try modifying this code to
            // capture i directly in the lambda, and compare results.
            Task[] taskArray = new Task[10];

            for (int i = 0; i < taskArray.Length; i++)
            {
                taskArray[i] = new Task((obj) =>
                {
                    MyCustomData mydata = (MyCustomData)obj;
                    mydata.ThreadNum    = Thread.CurrentThread.ManagedThreadId;
                    Console.WriteLine("Hello from Task #{0} created at {1} running on thread #{2}.",
                                      mydata.Name, mydata.CreationTime, mydata.ThreadNum);
                },
                                        new MyCustomData()
                {
                    Name = i, CreationTime = DateTime.Now.Ticks
                }
                                        );
                taskArray[i].Start();
            }
        }
Ejemplo n.º 4
0
        public void CanWriteCustomData()
        {
            // Populate Values.
            var value = new MyCustomData();

            value.aString       = "IT'S ALIIIIIIIIIIIIIVE!";
            value.anArrayOfInts = new int[] { 1, 2, 3, 4 };
            value.aBoundingBox  = new UnityEngine.Bounds();

            // Writing the value.
            string usdFile = CreateTmpUsdFile("sceneFile.usda");
            var    scene   = ImportHelpers.InitForOpen(usdFile);

            scene.Time = 1.0;
            scene.Write("/someValue", value);
            Debug.Log(scene.Stage.GetRootLayer().ExportToString());
            scene.Save();
            scene.Close();

            Assert.IsTrue(File.Exists(usdFile), "File not found.");

            // Reading the value.
            Debug.Log(usdFile);
            var newValue = new MyCustomData();

            scene      = Scene.Open(usdFile);
            scene.Time = 1.0;
            scene.Read("/someValue", newValue);

            Assert.AreEqual(value.aString, newValue.aString, "Serialized data don't match the original data.");

            scene.Close();
        }
 public MyCustomData(int c, string n, string cod, int i, int l, MyCustomData p)
 {
     childCount = c;
     name       = n;
     code       = cod;
     id         = i;
     level      = l;
     parent     = p;
 }
Ejemplo n.º 6
0
    protected override void OnDuplicate(Rhino.DocObjects.Custom.UserData source)
    {
        MyCustomData src = source as MyCustomData;

        if (src != null)
        {
            IntegerData = src.IntegerData;
            StringData  = src.StringData;
        }
    }
        //  Methods  --------------------------------------
        private async void SetupBeamable()
        {
            var beamableAPI = await Beamable.API.Instance;

            Debug.Log($"beamableAPI.User.id = {beamableAPI.User.id}");

            _myCustomContentMicroserviceClient = new MyCustomContentMicroserviceClient();

            // #1 - Call Microservice
            MyCustomData myCustomData =
                await _myCustomContentMicroserviceClient.LoadCustomData();

            // Hardcoded guess. Feel free to update via Content Manager
            bool isSuccess = myCustomData.Attack == 22;

            // #2 - Result
            Debug.Log($"LoadCustomData() myCustomData.Attack = {myCustomData.Attack}, Success={isSuccess}");
        }
    private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        MyCustomData newItem = (MyCustomData)e.NewItem;

        if (newItem == null)
        {
            return;
        }
        if (newItem.level == 3)
        {
            controlHub.menuController.classroomToConnectTo = newItem.name;
            controlHub.menuController.roomToConnectTo      = newItem.serverroom;
            controlHub.menuController.enableConnectButton();
        }
        else
        {
            controlHub.menuController.disableConenctButton();
        }
    }
Ejemplo n.º 9
0
        public async Task <MyCustomData> LoadCustomData()
        {
            MyCustomData myCustomData = null;

            // Check All Content
            var clientManifest = await Services.Content.GetManifest();

            foreach (var entry in clientManifest.entries)
            {
                // Find Matching Type
                if (entry.contentId.Contains("my_custom_content"))
                {
                    // Load MyCustomContent
                    MyCustomContent myCustomContent =
                        await Services.Content.GetContent <MyCustomContent>(entry.ToContentRef());

                    myCustomData = myCustomContent.MyCustomData;
                }
            }

            // Return data
            return(myCustomData);
        }
Ejemplo n.º 10
0
        void Test()
        {
            string usdFile = System.IO.Path.Combine(UnityEngine.Application.dataPath, "sceneFile.usda");

            // Populate Values.
            var value = new MyCustomData();

            value.aString       = "IT'S ALIIIIIIIIIIIIIVE!";
            value.anArrayOfInts = new int[] { 1, 2, 3, 4 };
            value.aBoundingBox  = new UnityEngine.Bounds();

            // Writing the value.
            var scene = Scene.Create(usdFile);

            scene.Time = 1.0;
            scene.Write("/someValue", value);
            Debug.Log(scene.Stage.GetRootLayer().ExportToString());
            scene.Save();
            scene.Close();

            // Reading the value.
            Debug.Log(usdFile);
            value      = new MyCustomData();
            scene      = Scene.Open(usdFile);
            scene.Time = 1.0;
            scene.Read("/someValue", value);

            Debug.LogFormat("Value: string={0}, ints={1}, bbox={2}",
                            value.aString, value.anArrayOfInts, value.aBoundingBox);

            var prim    = scene.Stage.GetPrimAtPath(new pxr.SdfPath("/someValue"));
            var vtValue = prim.GetAttribute(new pxr.TfToken("aString")).Get(1);

            Debug.Log((string)vtValue);

            scene.Close();
        }
Ejemplo n.º 11
0
    public static Rhino.Commands.Result Userdata(RhinoDoc doc)
    {
        Rhino.DocObjects.ObjRef objref;
        var rc = Rhino.Input.RhinoGet.GetOneObject("Select Face", false, Rhino.DocObjects.ObjectType.Surface, out objref);

        if (rc != Rhino.Commands.Result.Success)
        {
            return(rc);
        }

        var face = objref.Face();

        // See if user data of my custom type is attached to the geomtry
        // We need to use the underlying surface in order to get the user data
        // to serialize with the file.
        var ud = face.UnderlyingSurface().UserData.Find(typeof(MyCustomData)) as MyCustomData;

        if (ud == null)
        {
            // No user data found; create one and add it
            int i = 0;
            rc = Rhino.Input.RhinoGet.GetInteger("Integer Value", false, ref i);
            if (rc != Rhino.Commands.Result.Success)
            {
                return(rc);
            }

            ud = new MyCustomData(i, "This is some text");
            face.UnderlyingSurface().UserData.Add(ud);
        }
        else
        {
            RhinoApp.WriteLine("{0} = {1}", ud.Description, ud);
        }
        return(Rhino.Commands.Result.Success);
    }
    private void OnItemDataBinding(object sender, TreeViewItemDataBindingArgs e)
    {
        MyCustomData dataItem = e.Item as MyCustomData;

        if (dataItem != null)
        {
            //We display dataItem.name using UI.Text
            Text text = e.ItemPresenter.GetComponentInChildren <Text>(true);
            text.text          = dataItem.name;
            text.color         = colorByLevel [dataItem.level];
            text.fontSize      = 60;
            text.raycastTarget = false;

            //Load icon from resources
            //Image icon = e.ItemPresenter.GetComponentsInChildren<Image>()[4];
            //icon.sprite = Resources.Load<Sprite>("cube");

            //And specify whether data item has children (to display expander arrow if needed)
            if (dataItem.name != "TreeView")
            {
                e.HasChildren = dataItem.level < 3;
            }
        }
    }
    private void OnItemExpanding(object sender, ItemExpandingArgs e)
    {
        //get parent data item (game object in our case)
        MyCustomData data = (MyCustomData)e.Item;

        if (data.level < 3)
        {
            if (data.level == 0)
            {
                wwwForm = new WWWForm();
                wwwForm.AddField("c", data.code);
                www = new WWW(controlHub.networkAgent.bootstrapData.extraServer + ":" + controlHub.networkAgent.bootstrapData.extraServerPort + Utils.getLocalitiesListScript, wwwForm);
                while (!www.isDone)
                {
                }                 // O.o this is no bueno....
                string[]            locs        = www.text.Split(';');
                List <MyCustomData> level1Items = new List <MyCustomData> ();
                for (int i = 0; i < locs.Length - 1; ++i)
                {
                    string[] components = locs [i].Split(':');
                    level1Items.Add(new MyCustomData(1, components[0], components[1], i, 1, data));
                }
                e.Children    = level1Items;
                expandCountry = data.name;
                //state = 10; // retrieve localities
            }

            if (data.level == 1)
            {
                wwwForm = new WWWForm();
                wwwForm.AddField("l", data.code);
                wwwForm.AddField("c", data.parent.code);
                www = new WWW(controlHub.networkAgent.bootstrapData.extraServer + ":" + controlHub.networkAgent.bootstrapData.extraServerPort + Utils.getOrganizationsListScript, wwwForm);
                while (!www.isDone)
                {
                }                 // O.o
                string[]            locs        = www.text.Split(';');
                List <MyCustomData> level2Items = new List <MyCustomData> ();
                for (int i = 0; i < locs.Length - 1; ++i)
                {
                    //string[] components = locs [i].Split (':');
                    level2Items.Add(new MyCustomData(1, locs[i], locs[i], i, 2, data));
                }
                e.Children = level2Items;
            }

            if (data.level == 2)
            {
                wwwForm = new WWWForm();
                wwwForm.AddField("o", data.code);
                wwwForm.AddField("l", data.parent.code);
                wwwForm.AddField("c", data.parent.parent.code);
                www = new WWW(controlHub.networkAgent.bootstrapData.extraServer + ":" + controlHub.networkAgent.bootstrapData.extraServerPort + Utils.getClassroomsListScript, wwwForm);
                while (!www.isDone)
                {
                }                 // O.o
                string[]            locs        = www.text.Split(';');
                List <MyCustomData> level3Items = new List <MyCustomData> ();
                for (int i = 0; i < locs.Length - 1; ++i)
                {
                    string[]     components = locs [i].Split(':');
                    MyCustomData newData    = new MyCustomData(1, components [0], components[1], i, 3, data);
                    newData.serverroom = components [1];
                    level3Items.Add(newData);
                }
                e.Children = level3Items;
            }
        }
        //currentItemExpandingArgs = e;
    }
Ejemplo n.º 14
0
    public static Rhino.Commands.Result Userdata(RhinoDoc doc)
    {
        Rhino.DocObjects.ObjRef objref;
        var rc = Rhino.Input.RhinoGet.GetOneObject("Select Face", false, Rhino.DocObjects.ObjectType.Surface, out objref);
        if (rc != Rhino.Commands.Result.Success)
          return rc;

        var face = objref.Face();

        // See if user data of my custom type is attached to the geomtry
        // We need to use the underlying surface in order to get the user data
        // to serialize with the file.
        var ud = face.UnderlyingSurface().UserData.Find(typeof(MyCustomData)) as MyCustomData;
        if (ud == null)
        {
          // No user data found; create one and add it
          int i = 0;
          rc = Rhino.Input.RhinoGet.GetInteger("Integer Value", false, ref i);
          if (rc != Rhino.Commands.Result.Success)
        return rc;

          ud = new MyCustomData(i, "This is some text");
          face.UnderlyingSurface().UserData.Add(ud);
        }
        else
        {
          RhinoApp.WriteLine("{0} = {1}", ud.Description, ud);
        }
        return Rhino.Commands.Result.Success;
    }