Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
m_Image = GetComponent<Image>();i am trying to put a list of images and whenever clicked i want to replace clicked image to a plain . as i am a beginner in unity please share your thoughts,,
As shown here the pen image should be replaced in the floor
I believe you should use
GetComponent<Image>().sprite
and set a sprite instead of an Image.
You should use Sprite instead of an image(sprite is a part of images components in unity)
GetComponent<Image>().sprite;
Read more about Sprites
Unity Manual
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
So the problem is the following:
I have been trying to make this flying simulator little phone game, the problem is i cant make the shadow change with a smooth transition...
That White squared is a cloud, and the objective is to have the shadow change size while in the cloud...
I don´t really know were to start, i tried shaders, but i´m not that good with that...
Thx :))
If you are not into shaders, I would look into Masks. Masks basically limit a sprite to only draw within it's boundaries.
In this example, you could have a mask on the cloud. To make it work, have the "nearer" shadow be always drawn, but only in the mask's boundaries (In this case - the cloud) Relevant Youtube Tutorial
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Currently I am working on face detection app. I have implemented face detection part using Apple's Vision.
And app has custom white circle drawn over the screen (you can see in below image).
Now, how can I detect if face is within that custom white circle or not?
I have also done similar project for fun. Link here: https://github.com/sawin0/FaceDetection
For those who don't want to dive into repo.
I have quick suggestion for you, if you have path of circle and face as CGPath then you can compare circle's and face's bounding box using contains(_:using:transform:) .
Here is a code snippet
let circleBox = circleCGPath.boundingBox
let faceBox = faceRectanglePath.boundingBox
if(circleBox.contains(faceBox)){
print("face is inside the circle")
}else{
print("face is outside the circle")
}
I hope this helps you and others too.
P.S. If there is any better way to do this then please feel free to share.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I made a wall in Home sweet 3d with some pictures on it and I imported it as a .obj and opened in unity 3d. I want to put a button next (point of interest) to every image So that on click to the button, a popup should appear with some text.
GameObject -> UI -> Button
create a button and move it in your scene
change the sprite to whatever you want it to look like
attach a script to an object in the scene with a method to show your popup
add the method to your button's onclick
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Inside this pattern there is an image of a kettle. You can see it if you really focus. I'd like to know if I can use Matlab to decode this pattern? Give me some tips or code samples.
Warning
This answer will not attempt to solve this programatically ... Instead it focuses on letting Matlab do the eye crossing* for you however you still need to decide how far* to cross them...
* this terminology sounds wrong but I'm just going to go with it
Method
Simply shifting the image and subtracting it from the original should give reasonable results, choosing the shift however is the tricky part, but once you know it something as simple as imData-circshift(imData,[shiftY,shiftX,0]) should give a good image...
Here is a crude but simple GUI wrapper for the line of code above... (just run the function with an image file name as an argument)
It doesn't give great results for the given image but it works better on some of these
Example
Initial Image
After a little playing
I think "you can see it if you really focus" is not correct. In my oppinion you rather have to defocus to see the hidden image. You have to focus on a thought object that lies behind the image plan.
To extract it with matlab, I would suggest to try some stereo algorithms. Correlate each line of the image with itself and find repetitions. This is the same way our brain sees the hidden image.
This problem is a stereo vision problem: if you cross your eyes correctly you will see the object in 3D. i suggest you have a look at disparity maps: for instance the disparity matlab function (http://www.mathworks.co.uk/help/vision/ref/disparity.html)
computes a 3D image from a pair of 2D image.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have an app idea so mocked it up in C# because that's my most fluent language. I now want to port this over to Swift if possible, how hard will it be to generate a grid of 6x6 blocks, each block needs to be separate from each other as I need to change they're properties and detect touches on them. This is the grid I've currently got running on Windows.
Thanks for any help.
There are a lot of different ways to approach this problem, so you need to provide more details. You could do it with a single custom UIView, drawing the current representation of your model in the drawRect method and it would also be able to handle all of the touch events since you can just calculate where the user did the touch in the same way that you calculated drawing the grid and coloring the squares.
But if you want to use SpriteKit, then this tutorial will show you all the details of doing a 2D array, using sprites, tiles, etc.
http://www.raywenderlich.com/75270/make-game-like-candy-crush-with-swift-tutorial-part-1