How to create a script icon in Unity3D? - c#

I created a scipt and editor for it. Now I want to assosiate an icon with it like this:
How to do such thing? Cant find any documentation on this.

You can change the icon by selecting the Object in Project view. Then click the icon in the upper left corner in the Inspector. Then select Other.
[Picture Guide] So after you have selected the script, click on the icon marked in red in the picture below:
Look at the picture below for guidance.

If you want to assign an icon to a custom script, I believe you can create a gizmo icon for it and place the image at a project location that maps to the namespace of your script. My understanding is for each MonoBehaviour in your assembly, Unity looks for an associated icon with the name "<className> Icon" under the "Gizmos" folder, but the hierarchy must match the namespace.
So if your MonoBehavior is TestClass and its namespace is Company.Project.Foo, you would place the image in your project at "Assets/Gizmos/Company/Project/Foo/" and image name should be "TestClass Icon".
Your script will then have the icon associated with it when viewed in the Inspector, but I don't believe this will cause it to appear in the SceneView. You should use the DrawGizmo attribute on an editor script, if you want to make the icon appear in the SceneView or perform any other custom gizmo drawing.
In the following example screenshots, I have a script called SafeArea with the namespace Greyborn.Library. I placed the "SafeArea Icon.png" at "Assets/Gizmos/Greyborn/Library/", and the icon immediately appeared in the Inspector and Project windows.
I used a PNG. Other image types may be supported, however when I tested with a PSD image, the gizmo wouldn't show up. Be sure to set the Texture Type to "Editor GUI and Legacy GUI".

Related

How to scale objects with screen size in Unity

For canvas item no problem, buttons or any other UI elements can be scaled with screensize. On the other hand, I can not do this for objects. I need a box in my design and in every screensize it should fit all screen.
I need this design.
But when I change screensize design does not remain same.
other image:
For button or canvas elements there is no problem I can do it by "scale with screen size" but when it comes to objects I can not do like this. How can I do?
It seems like a vignette would be useful rather than scaling a gameobject.
Quick explanation:
With Unity's post-processing properly added and a volume created, add the effect/override of vignette and change vignette's mode to mask. And add an image as a mask.
If not experienced with post-processing:
For unity 3d HDRP or URP(may work with unity 2d but probably not):
Add a global volume through the hierarchy by first navigating to the plus sign drop-down then to volume then click on global volume. If unavailable, add an empty object with a volume component. Create a profile then add the override of the vignette. Under vignette change the mode to mask and select an image you want the mask to be.
That should be all for unity HDRP or URP.
Without HDRP or URP:
Add the postprocessing package if not installed via the package manager.
Create an empty object and add post-processing volume. Checkmark is-global. Create a new post-processing profile. Add effect vignette. Checkmark 'Mode' and switch it to masked.
Checkmark and change 'Mask' to the image you want.
This should allow the image to pop up over the camera.
Extra note: Make Sure The Image Has A Transparent Background On The Vignette Mask Where You Want The Player To See Through
Please search for how to use post-processing package if any issues occur.

How to put a picture exactly on the road?

I created Custom Pin in Xamarin.Forms.Maps and add my icon. How I can put my icon on the road and and move this icon along.My problem is not with getting accurate data, but with displaying the image itself exactly on the road. For example, if the road is horizontal, then the icon (car) should stand horizontally on the road
You could use Map Tracking. It would show the driver route and car position on the map. The car should move according to its current position in the route.
Install the Xamarin.Forms.GoogleMaps.
https://www.nuget.org/packages/Xamarin.Forms.GoogleMaps/
You could download the source file from the GitHub for reference.
https://github.com/WendyZang/MapTrackingSample

What is the correct method for showing a full screen photo within a mobile app using Unity?

I am creating a mobile app using Unity. I would like to place a photo which fills the screen and then place some 3D objects on top of this photo. The photo is created during runtime and is saved to the persistance data folder.
What is the best method to achieve this? The options I see are Raw Image/Image/Sprite. However, I have been unable to achieve the above mentioned goal using either of these component types.
What about making a panel on a canvas, setting the image as background and the canvas to fit screen size?
Then place the objects on front of it, manually or as children of said canvas but higher in the hierarchy.
I don't really understand what you intend to do, just trying to help.
editing my original answer: you need to use RawImage to be able to easily load images that are not marked as Sprite in the editor
You load images from file like this :
Texture2D texture = new Texture2D(1,1); // the following needs a non null starting poin
var path=System.IO.Path.Combine(Application.streamingAssetsPath,"your_file.jpg");
byte[] bytes=System.IO.File.ReadAllBytes(path);
texture.LoadImage(bytes);
rawImage.texture=texture;
As far as keeping it filling the screen the AspectRatioFiter component is likely to do the job
To get 3d objects rendering in front, set your canvas to 'Screen Space - Camera' and point it to your camera. This will behave similar to word space in regards to rendernig order (will get 3d sroted) but canvas size will match camera viewport, so AspectRatioFitter will be able to do its job

Imageview over imageview (png over jpg)

Many topics about his, but still haven't found my solution:
I'm working with Xamarin Studio: Within my launch screen I have one view with two ImageViews. The first image .jpg is being set to fill parent vertically and horizontally. The image that should go on top of the background image is a .png (transparent background with white lettering).
I have my BuildAction set to BundleResource and the image source of .png does not show the extension, just the image name. The problem is that the .png image is not showing up. Tried deleting the bin and obj folders and rebuilding, but without succes.
In your Info.plist make sure the value for Launch Screen is set to your LanchScreen.storyboard (might be different name for yours). Open that storyboard and place your UIImageViews in the desired order.
If you work with LaunchImages instead you need to compose your image beforehand in a picture editor.

C# Changing the cursor's clicking/pointing position?

So the default cursor is the "Arrow" cursor and the top-left of the arrow (where the point is) is the part that clicks or interacts with other controls. How can I change the pointing part to say the tail of the arrow?
What I have is a custom cursor (a bitmap image) which is a circle at 16x16 size and I want the very center of it to be the pointer. I have another custom arrow-like cursor that points downward-left also 16x16 and I want the bottom-left corner of the cursor to be the pointer. I think there's a property in the cursor class for this but I'm not sure what it's called.
This is actually specified in the CUR file format.
The CUR file format is an almost identical image file format for
non-animated cursors in Microsoft Windows. The only differences
between these two file formats are the bytes used to identify them and
the addition of a hotspot in the CUR format header; the hotspot is
defined as the pixel offset (in x,y coordinates) from the top-left
corner of the cursor image where the user is actually pointing the
mouse.
Programs that can edit CUR files generally allow you to specify the hot spot. More information can be found in this question.
What you want can't be done through code. I wanted do the same thing but it's not possible.
In fact, the Cursor class has a property called HotSpot, which is the point that you want change. However this property is readonly.
The only way to change this is at file loading (on a .cur file, I suggest you using Paint .net with Cursor and icons plugin (search over the web) to edit cursor). An important thing: the cursor must be a file and not a resource or things like that (must be a file on the file system) to load it. Remember it, I had bad times testing in other ways.
The idea that I have in mind is: edit cursor file just when you need to change the hotspot, however this require for you writing an api that allows you to change the hotspot on a cursor file. I obviusly don't know how this file is built so you must continue from here.
Hope this was useful

Categories

Resources