How do I access and change this value via script - c#

I'm not sure about how to word this but basically I'm trying to create a sort of animated glow effect for text in unity2D. To do that I need to be able to change the value of "Glow Power" through a script(shown below).
here's the value (underlined in red)
Any advice that would steer me in the right direction would be greatly Appreciated
I've been search around for a while & I can't seem to find any information on how to do it. Also, the value I'm trying to edit is attached to the component (shown below) if that makes thing's any clearer.
here's the component (underlined in red)
I tried editing it using "Get.Component" but that doesn't seem to work. Any Idea's?

That's not a component.. it is a Material and what you underlined is the Shader it uses.
You will need to select the shader in the Assets in order to see which properties it exposes.
Then once you know it's name you can use e.g. SetFloat on the according material.
Without having Unity open a wild guess would be something like _GlowPower but you will need to check.
so basically
yourObject.GetComponent<TMP_Text>().fontMaterial.SetFloat("_GlowPower", xy);

Related

How do I change the button mapping of jumping in unity to the X instead of Square on my PlayStation controller?

so when using the unity GetButtonDown("Jump") it automatically keeps space bar as the jump button, however, when using unity with a controller the button is mapped to square instead of x if there is anyway to change this please let me know!
I tried doing an action map and maybe relaying it there but to be honest I'm really new to Unity and coding in general so following youtube tutorials did end up getting me more confused.
Not familiar with Action Mapping, but if you're using the standard Input Manager, then go to Project Settings -> Input Manager -> Axes, find the second entry for "Jump" (the first one is for keyboard), and change its default (for me, I see "joystick button 3") to the button you want it to be.
Here's the docs for the Input Manager, for future reference: https://docs.unity3d.com/Manual/class-InputManager.html

Is there a universal way to get the name of a component field?

when I work with different plugins, I often want to change a specific value in a component from that plugin. And it is always a lengthy trial and error phase until I find out, how to address the value.
Example
Currently, I'm working with the Dreamteck Splines plugin.
One of the components is the Spline Positioner which has under the headline Tracing a expandable section called Motion in which is the headline Position which has the sub headline Offset and in it is the field "X" which I want to change.
So, I tried it with ...
GetComponent<SplinePositioner>().offset.x
GetComponent<SplinePositioner>().offsetX
GetComponent<SplinePositioner>().position.offset.x
and so on ... but everything is wrong.
In a perfect world, I could hover over any field in the inspector and a tooltip is shown with the way, I can address this specific field. But this isn't the perfect world ;)
So, how you deal with that, when you you don't find it in the documentation of the plugin?
Thank you!
I found it through the suggestion list of Visual Studio code after typing in GetComponent<SplinePositioner>(). First, this list felt a little generic, but after looking through it, entry for entry, I found my way. It was GetComponent<SplinePositioner>().motion.offset.x in the end.
Thank you #derHugo for getting me in the right direction :)

Tangram puzzle application

I am trying to create a WPF application using C# to run on Pixelsense that is basic version of the tangram puzzle. I am able to draw my 7 shapes and translate and rotate them all around the screen.
Could anyone give me advise regarding how I should go about saving the pattern (with shapes in specific positions and orientations) so that when a user creates the pattern next time, the application can match it to the saved one and tell the user if it's correct.
It's a pattern matching and recognition problem that I am trying to solve.
I have been stuck on this for a while now :(
Define the solution as a collection of objects with shapeType, position, and orientation properties. Have the solution include one shape at position 0, 0 and an orientation of 0. Now loop over all the shapes the user has actually placed to find the ones with a shapeType that matches the shape your solution has at 0,0,0. Calculate the position and orientation of every other shape relative to where the user put this one. Compare those values to the rest of your solution. You'll need to experiment with how much tolerance to allow because this stuff is not precise - to make the game fun, err on the side of having high tolerances. If needed, you can follow this up with some performance optimizations to only re-evaluate pieces that moved.
Hopefully you are using physical shape prices with tags on them instead of this purely a virtual game. I always wanted to build this when I was on the Surface team but it never happened. One challenge you will run into is defining how the tag's position/orientation relates to the actual shape. If you'll be putting tag stickers on multiple tangram sets, you almost certainly won't get the on precisely the same each time so you may need to add a "calibration" mode to your app (have the user place each piece in a specific spot and then push a button so you can record where the tag is relative to those spots). The TagVisualizer WPF control should help a lot for building your UI - definitely look into using it (this scenario was top of mind when we designed that API). The default behavior of that control (if you tell it the ID of a tag to look for but not how to visualize it) is a "crosshair" that can help you find tune your offset values.
Good luck! If you wouldn't mind recording a YouTube video when you are done and posting a comment here linking to it, I'd really appreciate that
You can use ObservableCollection or List of a custom class. That class can consist of various values such as position, orientation etc as properties.
When a new pattern is drawn or when the pattern change its position you can update that particular object stored in the collection. As you have all the details of the pattern(positions and orientation) you can iterate the for loop and check the position of the new pattern when added.

AutoCAD: Access group pivot in C#

I am writing a plugin for AutoCAD in C#.
I would like to change the position of the pivot point of a group.
It is possible to do that by mouse clicking but after deselecting and reselecting the group, it automatically moves back to it's default position (which looks like it is the center point of the bounding box).
If I use something like...
private void SetBasePoint(Group group)
{
group.AnyAvailableMethod();
//or...
group.AnyAvailableAttribute;
}
...none of the offered attributes or methods give me any solution or hint how to get there.
Does anyone have a clue how to access the pivot?
-Mike
So after working through several APIs and websites I contacted Kean Walmsley from Autodesk Developer Network and even he told me there was no direct way to get access to the pivot of a group.
So now I'm saving a user defined basepoint inside AutoCAD and whenever I need a function with a predefined pivot position I simply call my own loadBasepoint() -method which fits perfectly for my specific case.
Just in case someone runs into the same issue I thought I'd mention it :)

how can I lock shapes in PowerPoint?

I'm working on a Add-in for PowerPoint 2010 (C#) and I want to prevent the end-user to move or edit all the shapes that I have programmatically created.
I have already sought in the framework but I think it's not allowed programmaticaly. Has anyone already encountered this kind of limitations and could help me to find a solution?
I know that some people create their add-in thanks to C++ because there are a lot of limitations in office.
I have found two solutions :
The first is to catch all events from the "commandBars.OnUpdate" like this great sample code : http://code.msdn.microsoft.com/CSExcelNewEventForShapes-0e26b1f2#content
Then you can impose the position/the color or everything you want to your shape.
The second one is more "brutal" > unselect immediately the shape. When you catch all the events from the "CommandBars.OnUpdate" do this :
To see which shape is selected :
var selectedShape = this.Application.ActiveWindow.Selection.ShapeRange[1]
In all my shapes, I have set a tag with an ID. I have just to check that there are an ID in the tags of the selectedShape and if this is the case :
this.Application.ActiveWindow.Selection.Unselect();
Then I show a messageBox to warn the user to do not select this kind of shape.
I don't like this solution but it's the only one that I have found and it works.
I believe this is not possible. A way of achieving this to a certain extent (people can work around it if they figure out how to select the shapes below) is by making a transparent rectangle the size of the canvas and binding a custom event to that (like you described in your comment). The transparent rectangle is overlaying the shapes you created so people can no longer access the shapes that way. Of course if they are capable of figuring out how to select the shapes they can move them anyway...
Alternatively, to make people not do stuff like that (you only stop the inexperienced) you can also set them up as master slides.
Only 'real' solution for people not doing that? Images .. but then they can move the image too!

Categories

Resources