Instantiate Objects in Pattern using UI Slider
Hi, I'm designing a mobile AR app for my school project that allows users to design gardens in their neighborhood. They place different types of trees in different types of patterns on an AR plane. For design control, sliders increase the scale of that pattern. For example, if they were to place one tree on the plane, one slider might distribute that tree in a linear fashion (min value = 1, max value = 10) for a total of 10 trees in a line. Another slider might distribute that tree in a radial fashion (as seen in the image below). This sounds easy in my head, but I've been mad struggling with the code. Any help would be greatly appreciated. Right now I'm just creating animations and using sliders to control their playback but it's causing my app to crash, as I feared.
Also, if a user were to do multiple operations of these in the same plane, and say it gets to be like 100 trees or something, would this be a situation where object pooling should be used? Or is there some procedural script/plugin I should use instead? Granted, the different pattern instantiations should only happen when the user inputs with the slider. Not sure if this is relevant, but I'm using AR Foundation for this app.
Thanks a bunch!
For slider UI script made by Unity You only need to drag a class $$anonymous$$onoBehavior with this function into it
public void SliderValueChange(float value){
// Your code here. Change all the tree transform based on 'value'
}
For Object pooling, yeah.
Answer by jiescobe · Dec 08, 2018 at 06:56 PM
Hi @NoDumbQuestion, I'm having trouble with creating the code that would go in the slider UI script. Can you help me with that?
Please google your question first before asking for help
That is number one rule of developer
Your answer
Follow this Question
Related Questions
Setting Hierarchical slider parameters via script 0 Answers
Generating Triangle Problem 1 Answer
Object Pooling causing a gap between last and first reused tile in array 0 Answers
problems with nav mesh agent 0 Answers
How to make it so I can't use the jetpack/jump while slider value is 0? 0 Answers