how to load external images for sphere texture unity - unity3d

i'm trying to create a unity script that will generate a 360° visit and it must be managed by a web platform (where you upload your 360° images ) so my sphere in the unity script must load external images for the sphere texture. I found only how to load external images for texture2D. Help please
I tried this script script to load image
and this is how it look how it looks

it's solved now i can load external images from url to set in my sphere texture . this is the script new script
and now this is how it looks

The first step is correct with loading the image in to a Texture2D however you now need to assign that texture to the spheres material. There are someways to do that and one of them is this
//Assuming sphere is a reference to a GameObject with a renderer attached
//After loading image
sphere.GetComponent<Renderer>().material.mainTexture = img;
This should replace the materials main texture with the image you loaded.

Related

Upload an image to Unity, but it change color, how do i fix it?

enter image description here
The left one is the image I upload to Unity, I open it in Sprite Editor.
The right one is the image I draw in Aseprite.
To use an image in unity it needs to be a sprite.
To create a sprite in Unity, we must supply the engine with a texture.
Get a standard image file such as a PNG or JPG that you want to use, save it, and then drag the image into the Assets region of Unity.
Next, drag the image from the Assets into the Scene Hierarchy. You will notice that as soon as you let go of the mouse button, a new GameObject with your texture’s name shows up in the list.
For a more concise explanation visit this site and follow the steps!

How to set Camera View a Specific Area in UI

My all project works in UI. One of my scene has videoPlayer and I would like to set my MainCamera to that specific Area. This scene is my Recording scene but for recording I have to use canvas Render Mode and has to be "Screen Space - Camera". How I can set my camera view to that specific area.
I tried 2nd camera with culling mask but didn't work because videoplayer is already my UI's child when camera Renders UI showing all children objects.
Is it possible show to camera whereever I want in UI?
enter image description here
Yessir it sure is. I literally had to do this a couple of days ago. Here is a tutorial/video I followed to figure out how to do it for my application. From the sounds of it, all you need to do is follow the video up to ~3 minutes. Then utilize the end product of getting a camera to showcase something in a UI window for your application.
For reference if the video gets deleted the process is as follows:
Create a new GameObject within the Canvas
Add a Raw Image as a child to to the new GameObject
We want a raw image because Raw Images in particular support the addition of a 2d Texture and this is what we need in order to display the Camera view.
Add a new Camera as a child to the GameObject
Create a new Render Texture in you Project Folder
Add the Render Texture to your Camera's Camera Component in the Target Texture field
Add the Render Texture to you Images Raw Image Component in the Texture field
Move the Camera to what you want to view and it should project to your UI GameObject.
If it doesn't do this correctly or the image has weird aspect ratios, check the dimensions in the Render Texture and your Image. It took me a while to get everything to look normal but it really just takes dimension adjustments.
Hope this helps!

Unity3D - How to change object's texture at runtime, when texture file is on server

I am recently started working with Unity3D, I am working with Unity3D version 5.3.0;
I have sprite object in my application, currently I am importing image and converting its texture type from texture to sprite. and the manually liking it with sprite renderer of my sprite object.
I want to change sprite (2D texture) in sprite renderer at the runtime. and the texture file (png image) is stored on my server.
using www class I can download it in a texture file but the question is, How i can convert the texture type from texture to sprite before assigning it to sprite?
When you say that you can download the texture, do you manage to get a unity object (such as a Texture2D), or just the image file downloaded on your computer?
If you managed to get a unity texture object, you can have a look at the Sprite.Create function
If you just get the file, I think this isn't enough to convert it to a correct Unity object. You should prepare an Unity asset bundle containing your sprite (have a look on google, there is plenty of info about asset bundles) and store the asset bundle on your server. This way you can download usable unity objects (for instance, a Sprite)

Sphere not rendering in Unity for Google Cardboard

I was following this blog post on how to implement 360 degree video in Unity. At the end, I used ffmpeg to split the video into individual frames as recommended. I also set the first frame as the texture for each material on each sphere. The end result looks like this
bad sphere
The big problem though is that once I build and run it on my phone or just play the scene itself, the sphere simply fails to render. Could this be caused by the texture being the first frame? Or am I making some other sort of error? Many thanks.
Movies in Unity are usually rendered as textures on objects. On mobile the issue becomes that the device only wants to display video in a video player, so the Unity class MovieTexture is not supported.
I am having success circumventing this, and successfully rendering 360-video on the inside of a sphere using a Unity plug-in from the Unity Asset Store called, Easy Movie Texture.
For working on a Mac, here's what I did:
Download the Easy Movie Texture plug-in from the Unity Asset Store
Open the Demo Sphere demo scene from Assets/EasyMovieTexture/Scene
Create a new (empty) Prefab to your project, and drag the Sphere GameObject from the Demo Sphere scene onto the Prefab.
Reopen your Cardboard scene and drag the new videosphere prefab into your hierarchy.
Open your source 360-video in Quicktime
File -> Export -> 720p
Change file extension from '.mov' to '.mp4'
Drag your new mp4 file into your projects Assets/Streaming Assets directory. Note: don't import through the menu system, as this will force Unity to convert to OGG.
On the "Media Player Ctrl" script component of your videosphere GameObject, locate the "Str_File_Name" field and provide the FULL filename of your newly exported video file. Make sure to include the extension as part of the string, "mymovie.mp4".
Pretty sure that's everything. Hope it helps other folks stuck on this problem.
Final note, the video will only render on the device. In the editor you will only see a white texture on the sphere. You have to publish to the device in order to see your awesome 360-video.

Error loading textures using Spritekit and Texture Packer

I am using SpriteKit and Texture Packer. I have a small sequence of animation. I was able to load certain images such as background and logos. But when I try to load the texture, which has an animation sequence using -
SKSpriteNode *char1 = [SKSpriteNode spriteNodeWithTexture:TEST_TEX_CHARACTER01];
It says SKTexture:Error loading image resource: "character01".
Please help me out!
Texture Packer creates a header file when you tell it you are using SpriteKit. I came across the same issue recently, although it worked just fine in a previous game. Everything appears to be correct in the plist, header and atlas.
I will edit my answer with a solution when I find one.
EDIT:
This turned out to be pretty simple. If you have any images with #2x in the name, change the name to a plain file name (e.g. ship#2x.png needs to be ship.png).
With that change to any files that need it and re-publishing your atlas from Texture Packer you should be able to use the convenience macro name from the header, e.g.
SKSpriteNode *ship = [SKSpriteNode spriteNodeWithTexture:ARTWORK_TEX_SHIP];