public new void Start()
    {
        base.Start();

        var trackObjects = Resources.LoadAll(ResourcesLoader.Track_Objects, typeof(GameObject)).Cast <GameObject>();

        buttons = new List <Button>();

        foreach (var obj in trackObjects)
        {
            var trackObj = obj.GetComponent <TrackObject>();

            var gameObj = new GameObject();
            gameObj.transform.SetParent(transform, false);
            gameObj.AddComponent <RectTransform>();
            gameObj.GetComponent <RectTransform>().sizeDelta = new Vector2(10, 10);

            var button = gameObj.AddComponent <Button>();
            var image  = gameObj.AddComponent <Image>();

            button.targetGraphic = image;
            image.sprite         = obj.GetComponent <TrackObject>().Icon;

            button.onClick.AddListener(() => {
                CursorEditor.CreateNewObject(ResourcesLoader.LoadTrackObject(trackObj.ID));
                buttonsRect.gameObject.SetActive(false);
                CursorEditorUI.Exit();
            });

            buttons.Add(button);
        }
    }
Exemple #2
0
    private GameObject DuplicateObject(GameObject obj)
    {
        string name = obj.GetComponent <TrackObject>().ID;

        var newObj = ResourcesLoader.LoadTrackObject(name);

        newObj.transform.rotation = obj.transform.rotation;

        return(InitializeObject(newObj, obj.transform));
    }
Exemple #3
0
    private void InstantiateMapObjects(TrackDTO mapDTO)
    {
        track.TrackObjectsParent.transform.DestroyChildren();

        foreach (var mapObjectDTO in mapDTO.MapObjects)
        {
            GameObject gameObj = ResourcesLoader.LoadTrackObject(mapObjectDTO.ID);
            gameObj.transform.SetParent(track.TrackObjectsParent.transform);

            Mapper.Map(mapObjectDTO, gameObj.GetComponent <TrackObject>());
        }
    }