Replace Object while it grabbed in oculus SDK Unity - unity3d

When Grab one object, replace object after some process or task (or after sometime) complete, Grabbed object is disable and other object is come to that place but it can't be grabbed after enable.
I need disablling one object and enable second both are grab in hand or controller (I integrate Oculus SDK).

Related

I want to use MRTK(Mixed Reality Tool Kit) gesture with script in Unity

I want to control MRTK input actions(select, scroll, hold, etc.) with script.
I'm trying to make custom controller, using EMG sensor.
When I received data from sensor, I need to control MRTK input actions depending on the data.
I tried to use some profiles (DefaultMixedRealityInputActionsProfile, MixedRealityInputSystemProfile ...) but they only provided data, not writable.
I also tried to use ViGEm, virtual game controller, but it was only available in unity test, not available at hololens because I don't know how to connect ViGEm and Hololens with wireless.
It is recommended to create a custom input system data provider based on your EMG sensor. For a step-by-step guide to getting started please refer to this link: Create data provider. And then, you can raise HoloLens gesture events corresponding to controller state changes by invoking the RaiseGestureStarted method in your custom data provider class. For example, have a look at WindowsMixedRealityDeviceManager which implements raising gesture input events and wraps the Unity XR.WSA.Input.GestureRecognizer to consume Unity's gesture events from HoloLens devices.

Detect gameobject removal from user action

I'm working on a system that automatically generate and release scriptable object that represent uniqueness for gameobject with a given component attach.
The generation process seems to be working really fine, but I'm facing problem when I want to release the scriptable object.
The given script is tagged "ExecuteInEditMode" and is implementating OnDestroy method to advertise a manager that his scriptable object should be deleted.
The problem is that OnDestroy is called in 4 situation from what i can tell :
Click on play
Switching scene
Manual removal (the only one I want to work with)
On editor shutdown
I've been able to avoid the 2 first on with this :
if (Application.isPlaying == false && Math.Abs(Time.timeSinceLevelLoad) > 0.00001f)
But I don't find any good solution for "On editor shutdown" I've seen that EditorApplication.quitting can be use for that case, but documentation warn that this event is not called when unity crash or is forced to quit, and I don't want to lose all my scriptable object if the editor crash.
I'm looking for a robust solution to avoid this problem if someone can help me please.
Thanks, have a nice day
Just handle the application quitting event.
this event is not called when unity crash or is forced to quit, and I don't want to lose all my scriptable object if the editor crash.
When unity crashes, so will your program, so it won't work any ways. Just make sure that under normal operating procedure (so a normal shutdown) you save your modifications.
In Unity3D if you edit your scene and you don't save, if the editor crashes you lose all your changes. The same will happen for what you're building here. In order to mitigate this risk (since prevention is reasonably difficult if not impossible) you can opt to save every minute, always save each change to a temporary location, or save for example every play.
For example i added a script to my project that autosaves the scene(s) whenever i press play, so when editing the scene i press play now and then to test, and it all gets autosaved.

Unity and Google's Blockly library integration

For my undergrad final project I want to develop an educational game for teaching basic programming so I want to provide them some easy drag'n'drop visual programming editor like in this code it but i have no idea how to do this i'm new in unity and i did a lot of search in google but i didn't get it ( i'm quite loste ) .so please can any one help me in these and give me a clue so i can build on it. thank you for your help
this is a example for my game design expl ( i want to move the player by drag and drop move right , move up ,move forward ......). I home my idea and question are clear
A few months ago I developed a project very similar to yours. I recently extrapolated a library from this project and published it on github. the library is called blockly-gamepad 🎮 and allows you to create the structure of a game with blockly and to interact with it using methods such as play() or pause().
I believe this will greatly simplify the interaction between blockly and unity, if you are interested in the documentation you can find the live demo of a game.
blockly-gamepad 🎮
live demo
Here is a gif of the demo.
How it works
This is a different and simplified approach compared to the normal use of blockly.
At first you have to define the blocks (see how to define them in the documentation). You don't have to define any code generator, all that concerns the generation of code is carried out by the library.
Each block generate a request.
// the request
{ method: 'TURN', args: ['RIGHT'] }
When a block is executed the corresponding request is passed to your game.
class Game{
manageRequests(request){
// requests are passed here
if(request.method == 'TURN')
// animate your sprite
turn(request.args)
}
}
You can use promises to manage asynchronous animations.
class Game{
async manageRequests(request){
if(request.method == 'TURN')
await turn(request.args)
}
}
The link between the blocks and your game is managed by the gamepad.
let gamepad = new Blockly.Gamepad(),
game = new Game()
// requests will be passed here
gamepad.setGame(game, game.manageRequest)
The gamepad provides some methods to manage the blocks execution and consequently the requests generation.
// load the code from the blocks in the workspace
gamepad.load()
// reset the code loaded previously
gamepad.reset()
// the blocks are executed one after the other
gamepad.play()
// play in reverse
gamepad.play(true)
// the blocks execution is paused
gamepad.pause()
// toggle play
gamepad.togglePlay()
// load the next request
gamepad.forward()
// load the prior request
gamepad.backward()
// use a block as a breakpoint and play until it is reached
gamepad.debug(id)
You can read the full documentation here.
I hope I was helpful and good luck with the project!.
EDIT: I updated the name of the library, now it is called blockly-gamepad.
Your game looks cool!
For code-it, we are using Blockly as the code editor. The code is then executed by a Lua interpreter inside the game. You could do something simpler: make one block type for each action, like MoveForward etc. and have them generate function calls like SendMessage('gameInterfaceObject','MoveForward'). In the game you need an Object that listens for such messages from the website.
Here's how your game talks to the website:
https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html

Identifying unity gameObjects (pre-runtime) to save/load their data

I pretty much already made a little quest game for Android, and it only just occurred to me that I have to save player's progress.
I have a lot of interactive game objects (they share a script InteractiveObject that I made), which has an integer "CurrentPosition" parameter, that tracks how the player interacted with it. I need to save that parameter for all of those game objects.
What I figured I will do is pass this data to some "manager" singleton class after every interaction, and compile it into the list.. only I have nothing to identify those game objects by. GetInstanceID is unique, but not persistent, so its useless for this purpose.
Of course, I could just add "ID" parameter ty my script, and fill it by-hand in editor.. but that seems to be a suboptimal solution. There are a lot of those objects.
Any suggestions?
You need to somehow "register" your buttons
This is basically the same idea as "give them all an ID manually" except replace manually with "using code."
The first problem you have is that all of your buttons are hand-placed in your scene and all of their interactions are done by hand and all of this was done manually with no regard to "I'm going to need to be able to identify these later" which is how you've ended up here.
Option 1:
Have your code create, place, and name your buttons. As your code is yours it will just automatically generate the required ID and retrieve the state from the save file because you built it to handle this requirement from the get-go.
As you haven't already set your project up this way, this will be a lot of work spent refactoring your project to do it this way.
Option 2:
Do it manually as you stated you don't want to do. You may have to decide that this is the least work-intensive solution that is also reliable.
Option 3:
Create a class that all it does is have a registerButton function that shoves the buttons into an array so that they have an index ID value. When your buttons run their Start() method (if they do not have a Monobehavior script yet, give them one for this purpose) calls this registerButton method, which returns an ID (its literally just the button's index in the all_the_buttons array). Use this as your serialization ID.
Note that while this is deterministic (in that the buttons will register themselves in the same order every time) it occurs in an unknown order. If you delete, clone, create, or move the button around in the scene hierarchy, you will affect what IDs your buttons have, possibly invalidating any existing save files.
you can use playerprefs to save the game data , take a look at this link https://docs.unity3d.com/ScriptReference/PlayerPrefs.html

Receiving Dynamic Links In Unity

I am using the Firebase Dynamic Links SDK in a Unity project and am receiving dynamic link data in my app in a single scene. But, if you navigate to another scene, the subscription to DynamicLinkReceived does not seem to work.
Both scenes are using the same controller and script and subscribing with
DynamicLinks.DynamicLinkReceived += OnDynamicLink;
The method OnDynamicLink is called in Scene 1 when I click a test link but not in Scene 2.