Good evening,
Recently I was trying to create an app in Unity where with a button I could open an image or a pdf while the app remains open and running. I tried to do it with Unity, and I didn't see any problem. However, when I used the HoloLens emulator, every time I did it the app opens the file but then closes.
I thought that maybe if I defined several 2D Empty Objects (as Images, Raw Images...) the app would still run while doing this. To do this, I used the WWW class and the example of the Unity Scripting API.
https://docs.unity3d.com/ScriptReference/WWW.html
However, I don't know why when I run the app the Image doesn't change... I also tried the SetTexture() method it still doesn't work. So I was wondering if you have encountered the same problem, and if you could help me to solve it out.
Thanks a lot for your help!
Best Regards
I'd suggest looking up the following post: change texture
It comes down to defining a gameobject, making a prefab out of the Image and setting the material of the prefab. You can easily make new materials by importing an image or making one using projects tab>Create>Material. You could try making 2 Materials with different colors to test it.
It could also be code that needs to be run using UWP outside of the editor, if that's the case, you could use
#if !UNITY_EDITOR
//Put your code here.
#endif
Related
This is my first time to make a Unity project. Everything works well on the Game view in Unity Editor. However, after I built the project and played it on Google Chrome, I found that the position of some gameobjects had been changed.
Here is a more detailed explanation. The left is what I saw on the game view, which was perfect. The right side is what I saw after built the project. The position of the grey picture had been changed.
Does anyone know how to fix this?
ps.I am using Unity 2020.3.18 with WebGL platform
Try exporting again but with the same resolution as the game view. In this case you would want to export in a 400x600 resolution (You can also edit the "index.html" file to change and experiment with the resolution). The problem has to do with the fact that changing the resolution of the game can affect where certain objects are and how much you can see.
I was following a tutorial on how to make snake. https://www.youtube.com/watch?v=N0QbmNZlxhw&list=PL1bPKmY0c-wnka3TTQhX7mfn9UoVXNP3H&index=1 When Unity crashed and I had not saved it once, however I still have the scripts for it. I tried to make it again but the map won't show up. I looked at the alpha but it was just fine. I need help finding out how to make the game again with the scripts.
You are out of luck, save your scene frequently and before testing/building. If Unity crashes your scene/inspector changes will not recover. Your scripts, however, as they are separate files retain their changes.
For avoiding this in the future I recommend you to use a Version Control System
And within the options of VCS I recommend to you Git
I am creating a small custom 2D game engine and I am stuck setting up the orientation for my game.
I would like to use only LandscapeRight, therefore I set the PageOrientation and SupportedOrientation in my GamePage.xaml and in my graphics' PresentationParams to LandscapeRight, but after calling ApplyChanges, the orientation resets back to Portrait.
I even tried setting the BackBuffer width/height, setting the PreferredBackBuffer width/height, and tried calling/not calling ApplyChanges in my Game constructor, Initialize, LoadContent, etc methods, but no change in the orientation.
Can someone advise me how to set up orientation properly? I dont need complex solutions, some pseudo code would be more than enough as my game engine is separated into many small dlls.
Thanks in advance!
Finally I was able to solve the issue:
MonoGame 3.2.2. installer has corrupted template, so I deleted the old project that was created from the template and targeted Windows Phone 8.1, then created a new project, added MonoGame 3.2.2. libraries through NuGet, copied the MonoGame.dll into an 'Externals' folder and referenced it in the engine's class libraries. After rebuild all, orientation worked like a charm! :)
I shifted to unity few weeks ago. I am developing a 2D platformer. For creating the maps I am using Tiled map editor from www.mapeditor.org . I have created a basic map. Included the tileSheet png and the .tmx file (saved as XML) in the Assets of the project. I am able to read the XML , that is all the gid's. But I don't know how to access a particular portion(tile) from the tileSheet corresponding to a gid.
I think for this I need to load sprite in the memory and select a tile (by specifying Height and width and coords) from texture memory to display it on screen. As given here :http://gamedevelopment.tutsplus.com/tutorials/parsing-and-rendering-tiled-tmx-format-maps-in-your-own-game-engine--gamedev-3104
but its for flash , how I can achieve same thing in Unity using C#. Notice the copyPixel stuff in the flash code. I thought I could use ReadPixels but it is used for reading from screen only not the texture memory.
Thanks.
If you're working in Windows then the Tiled2Unity Utility sounds like it will fit your needs. It exports Object Layers and was made with Unity 4.3 features in mind.
(Full disclosure: I'm the author of Tiled2Unity)
EDIT: Tiled2Unity is available for Mac users as well now. There is a command-line version for Linux users. (all free)
If you can describe more carefully your problem and what you are trying to do, maybe myself or someone can help you better, for example what exactly do you mean by "load a sprite into memory"? Or "select a tile"? Copying pixel data is SLOWWW, and hopefully you don't mean to be doing this in real time.
Here is my real advice though:
Have you checked out UTiled? It does tiled maps in 2D in Unity so I think it already does what you want and it's free.
There is also UniTMX... free.
There is also 'Tiled Tilemaps'... which is like $2.
I also built a system that can also do what I think you are trying to do (your link is broken, so I can't be sure).
The system I built is called 'Tiled to Unity' (you can search it in youtube to see if it does what you want). It allows you to attach gameObjects to tiles and have tile variants, and can do 3D tiles.
Anyway, trying to roll your own pipeline from Tiled into Unity is a ton of work, and with these tools available, I think it is almost certainly unnecessary... That's just imo.
I have an intresting project assigned to me , and I would like if you can provide me with an idea of what I should look for and read and learn.
(Im not asking for solutions )
I have to make a windows application using C# that have an option to load a video file (avi or any) and then the application detect a specific color or an object such as a ball or a face or whatever.
I heard there is a library called opencv and Im learning a lot from it .
I would like to learn more and more , but I want to avoid wasting my time on somthing old or not applicable.
please advice
thank you
Have you tried Googling first? The 3rd result from searching opencv track is this fantastic post:
Tracking colored objects in OpenCV
If you’re new to image processing, you’ll enjoy this project. What we’ll attempt to achieve in this tutorial is tracking the location of a coloured object in an image. In our case, it’ll be a yellow colored ball.