- Home /
How can we access panel' s children for take Tags ?
I have a panel called "dropzone" which has drag and drop script .When i drop the image in dropzone.Images become children of dropzone so I.Want to take and store Tags of image in String array
Answer by tormentoarmagedoom · Jul 13, 2018 at 12:05 PM
Good day.
When you say "Tags of image" you mean the nimage name? or the images have tags?
Best solution is to add them in a list ( is like an array, but you can move items, remove and add).
Go look for tutorials on how use them.
my images have tags but im getting this --->
NullReferenceException UnityEngine.Component.GetComponents[Image] () (at C:/buildslave/unity/build/Runtime/Export/Component.bindings.cs:169)
`here is my code --->
public static bool forward= false;
public static bool right = false;
public static bool left = false;
public static bool f = false;
public void Lolo()
{
D = new DropZone();
//dropzone is another script
Image[] imaj = D.GetComponents<Image>();
List<Image> listofcard = new List<Image>();
for (int i = 0; i < imaj.Length; ++i)
{
if (listofcard != null)
{
listofcard.Add(imaj[i]);
}
}
foreach (Image imge in listofcard)
{
if (imge.tag.Equals(ileri))
{
ileri = true;
}
if (imge.tag.Equals(sağ))
{
sağ = true;
}
if (imge.tag.Equals(sol))
{
sol = true;
}
if (imge.tag.Equals(f))
{
f = true;
}
}
Your answer
Follow this Question
Related Questions
How do I get the width and height of text then apply it to a UI panel? 0 Answers
[Solved]Why my Unity Button's Positions are different. 1 Answer
why is my image (script) broken? 1 Answer
How to align pixel art with UI system ? 0 Answers
[Optimization] - Is "Generate Physics shape", in Import settings, necessary for UI? 1 Answer