Beispiel #1
0
    Stuff addStuff(StuffTemplate stuffTemplate, Vector2 position)
    {
        var newStuff = obj.stuffManager.makeStuff(stuffTemplate);

        newStuff.transform.SetParent(obj.transform);
        newStuff.transform.position = position;
        return(newStuff);
    }
Beispiel #2
0
    public Stuff makeStuff(StuffTemplate stuffToMake)
    {
        var result = GameObject.Instantiate(stuffPrefab);

        result.GetComponent <SpriteRenderer>().sprite = stuffToMake.sprite;
        result.transform.localScale = result.transform.localScale * stuffToMake.sizeMultiplier;
        result.gameObject.AddComponent <PolygonCollider2D>();
        result.name = stuffToMake.name;

#if UNITY_EDITOR
        result.template = stuffToMake;
#endif

        return(result);
    }
Beispiel #3
0
    void regenerateList()
    {
        var assets = AssetDatabase.FindAssets("t:StuffTemplate", new[] { "Assets/Stuff" });

        var templates = new List <StuffTemplate>();

        foreach (var guid in assets)
        {
            var assetPath = AssetDatabase.GUIDToAssetPath(guid);

            StuffTemplate loadedAsset = AssetDatabase.LoadAssetAtPath <StuffTemplate>(assetPath);

            if (loadedAsset == null)
            {
                continue;
            }

            templates.Add(loadedAsset);
        }

        ((StuffManager)target).stuffList = templates.ToArray();
    }