Example #1
0
    void RefreshVisual()
    {
        if (visual != null)
        {
            Destroy(visual.gameObject);
            visual = null;
        }

        buildingType = buildingSystem.GetSelectedBuildingType();

        if (buildingType != null)
        {
            visual                  = Instantiate(buildingType.preview, Vector3.zero, Quaternion.identity);
            visual.parent           = transform;
            visual.localPosition    = Vector3.zero;
            visual.localEulerAngles = Vector3.zero;
        }
        else
        {
            if (visual != null)
            {
                Destroy(visual.gameObject);
            }
        }
    }