How can I split a List ?
I want to create a List and insert each some counted items something that will mark for me that after for example 10 items it's a box then after a 6 items it's box1 then box2 then box3.
void DrawBox()
{
SpawnLineGenerator(v3FrontTopLeft, v3FrontTopRight, color);
SpawnLineGenerator(v3FrontTopRight, v3FrontBottomRight, color);
SpawnLineGenerator(v3FrontBottomRight, v3FrontBottomLeft, color);
SpawnLineGenerator(v3FrontBottomLeft, v3FrontTopLeft, color);
SpawnLineGenerator(v3BackTopLeft, v3BackTopRight, color);
SpawnLineGenerator(v3BackTopRight, v3BackBottomRight, color);
SpawnLineGenerator(v3BackBottomRight, v3BackBottomLeft, color);
SpawnLineGenerator(v3BackBottomLeft, v3BackTopLeft, color);
SpawnLineGenerator(v3FrontTopLeft, v3BackTopLeft, color);
SpawnLineGenerator(v3FrontTopRight, v3BackTopRight, color);
SpawnLineGenerator(v3FrontBottomRight, v3BackBottomRight, color);
SpawnLineGenerator(v3FrontBottomLeft, v3BackBottomLeft, color);
itsbox = true;
}
void SpawnLineGenerator(Vector3 start, Vector3 end, Color color)
{
GameObject myLine = new GameObject();
myLine.transform.parent = transform;
myLine.tag = "FrameLine";
myLine.name = "FrameLine";
myLine.AddComponent<LineRenderer>();
myLine.AddComponent<EndHolder>();
myLine.GetComponent<EndHolder>().EndVector = end;
LineRenderer lr = myLine.GetComponent<LineRenderer>();
lr.material = new Material(Shader.Find("Particles/Alpha Blended Premultiply"));
lr.startColor = color;
lr.useWorldSpace = false;
lr.endColor = color;
lr.startWidth = 0.1f;//0.03f;
lr.endWidth = 0.1f;//0.03f;
lr.SetPosition(0, start);
lr.SetPosition(1, start);
allLines.Add(myLine);
}
For example the List allLines should be format for example something like:
myLine myLine myLine Box myLine myLine Box1 myLine myLine myLine myLine myLine Box2
And then when reading back the List items I want to be able to get the first box and all it's myLine items then box1 and it's items and so on.
Then how can I create this format of List and then how to read it back by boxes ?
The type of List should no be change but I need to make something and somehow that will mark and tell me after each what number of items it's a box.
Now when doing:
allLines.Add(myLine);
I will have just a long List of myLine items I don't know when box started and ended and when box1 started and ended and so on.
I added a box variable flag:
itsbox = true;
Maybe it can help to know when a box ended and a new started.
Your answer
Follow this Question
Related Questions
I create material with script but it does not render right 0 Answers
Creating Splines from empties in script 0 Answers
How can i rotate all the child objects together at the same time ? 1 Answer
How can i give another name/number to the created Plane object name ? 0 Answers
How can i create List of maps from each Map class ? 0 Answers