Exemple #1
0
    public void TryToAddElement(Element element)
    {
        // check that element could be added

        if (mCompoundDescription.IsEmptyElement(element.ElementName.text))
        {
            // find target position of an element on the podium
            Vector3 pos;
            if (mCompoundDescription.GetElementPosition(element.ElementName.text, out pos))
            {
                pos   += podium.transform.position;
                pos.y += 1.5f;

                // Create element
                GameObject elementObject = (GameObject)Instantiate(elementTemplate, sceneContent.transform);
                elementObject.transform.position = element.transform.position;
                elementObject.name = elementObject.name + objectIndex.ToString();
                objectIndex++;
                elementsObjects.Add(elementObject);
                Color col = GetColorByElement(element.ElementName.text);

                GameObject sph  = GameObject.Find(elementObject.name + "/Sphere");
                Renderer   rend = sph.GetComponent <Renderer>();
                if (rend != null)
                {
                    rend.material.SetColor("_Color", col);
                    rend.material.SetColor("_SpecColor", col);
                }

                // start animation
                StartCoroutine(SmoothMovement(elementObject, pos));
            }
        }
    }