public void SetSize(Vector3 v) { Size_ = v; if (IsLoaded) { //Get collider and set correct size BoxCollider bc = LoadedObject.GetComponent <BoxCollider>(); bc.size = Size_; bc.center = Size_ / 2; } }
private static void CheckAndPrepareObject <T>(string name, Action <Object> callback) where T : Object { if (_loadedObjects.TryGetValue(name, out var value)) { callback(value?.GetInstantiatedObject()); } else { if (_loadingQueue.TryGetValue(name, out var queue)) { queue?.Add(callback); } else { var newQueue = new List <Action <Object> > { callback }; _loadingQueue.Add(name, newQueue); Addressables.LoadAssetAsync <T>(name).Completed += result => { if (result.Status == AsyncOperationStatus.Succeeded) { var loadedObject = LoadedObject.Instantiate(result.Result); _loadedObjects.Add(name, loadedObject); foreach (var action in newQueue) { var instantiatedObject = loadedObject?.GetInstantiatedObject(); action(instantiatedObject); } _loadingQueue.Remove(name); } else { Debug.LogError("Couldn't load asset by name " + name); foreach (var action in newQueue) { action(null); } } }; } } }
/// <summary> /// Tato metoda je volana pri vsech load akcich, kdy upozorni uzivatele ze puvodni objekt nebyl pred nactenim noveho ulozen /// </summary> public void TryToLoad() { if (EditFlag == true) { Editor.Log("Puvodni objekt nebyl pred nactenim noveho ulozen: " + this.GetType().Name + "->" + LoadedObject.GetType().ToString()); } }