Exemple #1
0
        void Awake()
        {
            // get asset scriptables
            uniqueScriptableUsers = gameObject.GetComponents <IScopedScriptableUser>().ToList();
            foreach (IScopedScriptableUser user in uniqueScriptableUsers)
            {
                foreach (ScopedScriptable original in user.GetScopedScriptables())
                {
                    assetsUnfiltered.Add(original);
                }
            }

            // filter assets
            assets = assetsUnfiltered.Distinct <ScopedScriptable>().ToList();

            // make instances
            foreach (ScopedScriptable asset in assets)
            {
                ScopedScriptable instance = Instantiate(asset);
                instance.isInstance = true;
                instances.Add(new ScopedScriptableInstance(instance, asset));
            }

            // set asset reference to instances on all IUniqueScriptableUsers
            foreach (IScopedScriptableUser user in uniqueScriptableUsers)
            {
                user.SetScopedScriptables(instances);
            }
        }
Exemple #2
0
 public ScopedScriptableInstance(ScopedScriptable instance, ScopedScriptable asset)
 {
     this.instance = instance;
     this.asset    = asset;
 }