I have gameObject with animator attached to it, it has animation curves, I need to dynamically change keyframe values from code. How do I access them?
Already asked this in the Live Session. The Answer is you can't since the anim file is the core for running the Animation Controller.
The alternate way that they gave me is to use the legacy SpriteRenderer instead.
Animation Controller doesn't support Dynamic changing of the values. Instead they provided Animator for you to make Dynamic changes of path from anim files, so consider making different anim files and path to your Animator if you don't like to work with SpriteRenderer.
If "dynamically" still means editor-time, then you could use UnityEditor.AnimationUtility, which provides methods to get and set curves and key frames and more.
One can retrieve the bindings with AnimationUtility.GetCurveBindings() or AnimationUtility.GetObjectReferenceCurveBindings(). And with AnimationUtility.GetObjectReferenceCurve() one can get the key frames, make modifications and apply it with AnimationUtility.SetObjectReferenceCurve()
At runtime - probably only with workarounds.
For example via some animated relay value within a certain custom script that then applies the wanted value to the actual property on Update() - a kind of custom constraint if you will. And within that you could apply then again custom modifications via code on runtime. But on editor time and when animating, the preview would be broken because you would not directly animate the property, but only that relay value. Maybe one could use [ExecuteInEditMode] in that custom constraint behaviour and AnimationMode.InAnimationMode() to simulate a preview. But all of this would be experimental.
Related
I have a requirement where I need to highlight the buildings around my current location on a map. I am using Xamarin and was wondering if anyone can point me to a correct library or control that can fulfill my requirement.
I am currently using Mapsui for Xamarin but I don't think it has the feature I am looking for.
If you have access to the geometries of the buildings there are many ways you could implement highlighting.
One way that comes to mind. Create a layer on top of your background layer with the same geometries as data source. Use a ThemeStyle to show only the selected geometry. The ThemeStyle class is created with a callback method which determines the style. In that method you should return no style unless the feature id is the same as selected feature id.
You can take a look at the ThemeStyle sample for a more general use of themes (no highlighting).
Also you could look at Mapsui.Sample.Wpf.Editing. Here is a screenshot of that sample:
I am trying to understand how the WebAudio API would work. I have two objects; one representing the listener and one the source. And have used the below link as an example. I am able to move the source and the sound position changes.
https://mdn.github.io/webaudio-examples/panner-node/
The command to change the orientation has been provided: viz this.panner.setOrientation or this.listener.setOrientation. The question I have is: if I have a source or listener object (in canvas mode using ThreeJS viz. we know its position and rotation) how do I change the orientation of either the panner or listener (as the case may be) via JS.
An example would greatly help. Thanks
Any reason not to use THREE's PositionalAudio object? https://threejs.org/docs/index.html#api/audio/PositionalAudio. That lets you add a sound to mesh object, and THREE will take care of moving it. If you want to source a different sound than an AudioBuffer, just connect the audio source to the .gain of the PositionalAudio object.
I'm fiddling around with ti.barcode scanner module, but it seems it's always fullscreen.
Is there a way to make it use a part of the screen?
For iOS you can use SquareCamera: https://github.com/mikefogg/SquareCamera which allows you to have the camera inside a view and scan qr codes too.
But if you want to have it cross platform I would go with the overlay variant
Not sure if you can embed the ti.barcode to a smaller view, since you don't add it to a controller.
Have you tried to set the size of the module in the capture method?
The possible workaround is to create a view with your stuff and place it in the overlay property of the capture method
I have an Idle animation with arms holding a weapon which I have tweaked so It would work with a weapon I had created, I also have a running animation for the same arms which I need to tweak as well to work with my weapon, Is It possible to use the first keyframe from the Idle animation to offset the running animation's key to match it?
Ok so if anybody needs this in the future, I ended up using 3ds max's merge animation, it worked perfectly.
I've edited my previous answer to clearly state how this is done.
First, you want to export your idle animation. This can be done using the ATOM exporter in Maya or a third party plugin like PAIE or Studio Library. From here you can choose to only export the first frame or all frames. Make sure to select all the relevant controllers.
Secondly, you open up your running animation and select the same controllers as before, and then create a new animation layer with that selection. Animation layers are found in Channel Box / Layer Editor as a tab called Anim.
After setting up the layer, you can import your idle animation onto the layer. Again, this can be done using ATOM or a third party plug-in. Perhaps lock the BaseAnimation layer to prevent accidentally changing it. If you only wish to merge certain parts, like the arms, make sure to only export, import and add that animation to the animation layer.
I use MvxImageViewLoader for MvvmCross Xamarin applications.
This component is really great and simplifies the images loading pretty much, but it (at least, out-of-the-box) is pretty basic and most of modern applications require some reacher functionality, for instance, loading/progress images or images nice appearing/transitions (possibly with custom animation).
I see there is DefaultImagePath property, but that's static image, which I can probably use by default, but that's not animated view or something.
So, is there any way to customize/extend the loader behaviour (for default image appearing, images transition (from default to loaded)) etc?
And also I've noticed that the loader caches the image and even if I trigger bound property changing (leaving the image url the same) it does not refresh the image. I guess, "caching" really means caching and so on, but what if I need to change the user icon or something... how can I forse the cache refreshing with the image loader?
Thank you!
So, is there any way to customize/extend the loader behaviour (for default image appearing, images transition (from default to loaded)) etc?
No - advanced features like fade-in/fade-out/animated-placeholder display aren't supported within the standard MvvmCross image view, and no-one that I know of has provided any samples or tutorials about how this can be done.
For adding such functionality, you can use normal software techniques - inheritance, aggregation and cut, copy, paste. e.g. you could simply create your own AgatImageView which had the behaviour your app requires based on MvxImageView.cs.
Some examples of creating your own data-bound controls is given in N=18 and N-19 of http://mvvmcross.wordpress.com/
As you already mentioned in upper comments you may use default iOS' UIActivityIndicatorView for showing progress and you should hide the progress in afterImageChangeAction, you can check if UIImageView.Image field is not null, to make sure that the image is loaded.
Regarding the caching, it's not that easy here. By default MvxImageViewLoader relies on MvvmCross framework's implementation of IMvxFileDownloadCache interface. This interface has only one public method RequestLocalFilePath(), so even if you get an instance from IoC container (Mvx.Resolve()) you won't be able to clean-up the existing cache (to do that you need to reset private _entriesByHttpUrl field of MvxFileDownloadCache class).
If you really need this, you have to copy-paste existing MvxFileDownloadCache class and make your tweaks. But I am not sure about your use-cases where you need this. If you download images from the web, the URL of the image is a sort of a key in the cache, so if you need to reload just change the URL.
Maybe you could use some old-school approach like adding GET parameters to the URL: http://mydomain.com/images/myimage.jpg?timestamp=123456. Usually this helps everywhere :-). Although I didn't test it with MvxImageViewLoader, it's just my best guess.