Search Unity

Unable to create new labels?

Discussion in 'Addressables' started by unity_YgLwdbTFIaq_CQ, Dec 5, 2018.

  1. unity_YgLwdbTFIaq_CQ

    unity_YgLwdbTFIaq_CQ

    Joined:
    Nov 26, 2018
    Posts:
    7
    I was watching this video
    and when I went to create a new label in my own project, the option simply isn't there.
    Is there something I'm missing? Has the place where this is done changed? I tried clicking in both the bar and the arrow to the right of it.
     
  2. rachelgarza

    rachelgarza

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    28
    Hi!

    Yes, the way to create labels has changed. Now you should see the option to create a new label in your AddressableAssetsSettings file (should be in the AddressableAssetsData directory).

    Screen Shot 2018-12-05 at 9.28.06 AM.png
     
  3. unity_YgLwdbTFIaq_CQ

    unity_YgLwdbTFIaq_CQ

    Joined:
    Nov 26, 2018
    Posts:
    7
    Okay thanks for the help! This new way seems kinda tucked away... is there a reason it was made less intuitive?
     
    ModLunar, Favo-Yang and DinostabOMG like this.
  4. unity_YgLwdbTFIaq_CQ

    unity_YgLwdbTFIaq_CQ

    Joined:
    Nov 26, 2018
    Posts:
    7
    Also I'm not quite understanding what the Type parameter for LoadAssets<T> is for.

    Code (CSharp):
    1.     void Start()
    2.     {
    3.         //AsyncOperation async =
    4.         Addressables.LoadAssets<PartStatistics>("Arms", op =>
    5.         {
    6.             print(op.Result);
    7.             PartStatistics stat = op.Result;
    8.             statsList.Add(stat);
    9.         });
    10.        
    11.        
    12.     }
    This is grabbing everything labeled as "Arms" regardless of type, is this intended? Also another question about asynchronous operations: how would I execute some function after all of the labelled assets have been loaded? Sorry, I have not worked with coroutines much and I don't fully understand how they work.
     
  5. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    913
    For one, I'd recommend doing `LoadAsset().Completed +-= SomeFunctionName` for your async work. Many IDE's will let you generate that method with the proper signature, so you don't have to know exactly what to make.

    As to the type, it should only be returning things that cast to that type. Is that type a component class? If so, you'll actually get nothing returned if you are running in the real player. So you probably want the type to be GameObject. At least that'd be my guess.
     
  6. unity_YgLwdbTFIaq_CQ

    unity_YgLwdbTFIaq_CQ

    Joined:
    Nov 26, 2018
    Posts:
    7
    When browsing the docs and videos I was just copying the code because I didn't yet understand what delegates and events were or what the += SomeMethod() even meant. Some introduction to that in the AsyncOperation page may help other new users. And thanks, PartStatistics is a ScriptableObject so thanks for the clarification. I'm guessing I could also use this to load only Sprites, Textures, Meshes, etc.
     
  7. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    232
    += SomeMethod() just say to the Completed event to add your method (+) without erased others methods that could be plugged on it (=). In this way each time Completed is triggered by the AsyncOperation it will call every methods attached to it.
     
  8. unity_YgLwdbTFIaq_CQ

    unity_YgLwdbTFIaq_CQ

    Joined:
    Nov 26, 2018
    Posts:
    7


    I'm not sure if this is a bug or if I'm doing something wrong here. Essentially what I want to do is load all ScriptableObjects with a certain label and add them to a list.
     
  9. unity_YgLwdbTFIaq_CQ

    unity_YgLwdbTFIaq_CQ

    Joined:
    Nov 26, 2018
    Posts:
    7
    Okay I decided to use my specific ScriptableObject type again and it works and the Result returns null when it hits anything that has the same label but a different type, so that is manageable. I'm still not really sure how to replace the => and instead refer to some other function instead of defining one right there. I understand using += to subscribe a method to an event but callbacks are sort of going over my head.
     
  10. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    269
    Less convenience indeed. Maybe we can still leave a button in the labels dropdown, and navigate to the inspector of AdressableAssetSettings?