Search Unity

Probuilder throws NullReferenceException when Extruding object on Android

Discussion in 'World Building' started by SajevID, Aug 5, 2020.

  1. SajevID

    SajevID

    Joined:
    Nov 9, 2019
    Posts:
    8
    Hey, I'm trying to Extrude a ProBuilder object during Runtime and it works on Editor but when testing on Android it gives me a NullReferenceException... Unity version 2019.4.5f1. Probuilder version 2.9.8f3.

    Android Logcat Message:
    Error Unity NullReferenceException: Object reference not set to an instance of an object


    Code that gives the Error (Lines 5, 6, 7):
    Code (CSharp):
    1. CurrentLevel = Shop.GetComponent<PlayerSeeds>().CurrentLevel;
    2.  
    3. ProBuilderMesh PB = gameObject.GetComponent<ProBuilderMesh>();
    4.  
    5. PB.Extrude (new Face[] {PB.faces[0]}, ExtrudeMethod.FaceNormal, CurrentLevel*50f);
    6. PB.ToMesh();
    7. PB.Refresh();
     
  2. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    Make sure the in the Preferences/ProBuilder section that "Strip ProBuilder Scripts" is disabled if you want to access that data in the runtime.
     
  3. SajevID

    SajevID

    Joined:
    Nov 9, 2019
    Posts:
    8
    Sadly that didn't work, in addition to NullReferenceException, it also threw me an
    ArgumentNullException: Value Cannot be null. Parameter name: indexes.
     
  4. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    Does the ProBuilderMesh that you're trying to extrude have any geometry?
     
  5. SajevID

    SajevID

    Joined:
    Nov 9, 2019
    Posts:
    8
    So the ProBuilder face that I'm trying to extrude is the top face of a cylinder that I made by hand from the editor. I haven't added any other geometry, only merged the top side faces to a single face.
     
  6. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    Hm, I don't know off-hand what the problem might be. Can you please file a bug report?
     
  7. SajevID

    SajevID

    Joined:
    Nov 9, 2019
    Posts:
    8
    Alright, I will thank you for trying to help. Honestly, if there is an alternative to this I wouldn't mind changing my code, I just don't know ProBuilder that extremely well and the documentation kinda went above my head.