Search Unity

Loaded scripts from UPM not usable in project

Discussion in 'Package Manager' started by JPFerreiraVB, Feb 6, 2019.

  1. JPFerreiraVB

    JPFerreiraVB

    Joined:
    Sep 18, 2017
    Posts:
    39
    Hi folks.

    Having a problem with the new UPM. When i import scripts from a repository, i can't add them to newly created objects.



    If you look on the left, the scripts derives from monobehaviour.

    Also i have a sample scene in the package, and when i open it, all the scripts components are in error



    Is this normal?
     
  2. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    Hi @JPFerreiraVB ,

    Is this an *embedded* package? I'm not familiar with the *Avatar Core* package.

    Regards,

    Pascal
     
  3. JPFerreiraVB

    JPFerreiraVB

    Joined:
    Sep 18, 2017
    Posts:
    39
    Hey @okcompute_unity
    It's a costum package... it's a set of assets that other projects will use.
    Best example, the way we do it now, is with .unitypackage files, but this does not update/uninstall.
    The goal is: if i change the Avatar Core (again my costum package) i want to allow other members to update their projects and use new functionality and assets that are cross projet.
     
  4. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    I see. How do you reference the package in your project when you edit the content. Embedded or local package (file:)?
     
  5. JPFerreiraVB

    JPFerreiraVB

    Joined:
    Sep 18, 2017
    Posts:
    39
    Since i'm working on a corporate gitlab repo here is the manifest for the project that depend on the "AvatarCore"

    Code (JavaScript):
    1.  
    2.  "registry": "https://git.intra.company.com",
    3.   "always-auth": true,
    4.   "email": "email@company.com",
    5.   "_auth": "authtoken",
    6.   "dependencies": {
    7.     "com.company.avatarcore": "https://git.intra.company.com/AvatarCore.git"
    8.  
     
  6. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    Ok. When a package is referenced the way you did in your project, it becomes *read-only•. Unity will prevent you from modifying the content (it may misses cue from the UI?!). You need to *embed* the package in your project. This is physically copying the content of the package in your project.

    So what you can do is open a terminal and do the following commands:

    Code (CSharp):
    1.  
    2. $ cd <your project>/Packages
    3. $ git clone https://git.intra.company.com/AvatarCore.git
    4.  
    Switch back to Unity. A package dependencies resolution will be triggered. Once completed, Unity will treat your package as mutable (writable) and will allow most of the normal operation you have too within your project.

    Pascal
     
  7. JPFerreiraVB

    JPFerreiraVB

    Joined:
    Sep 18, 2017
    Posts:
    39
    Hi @okcompute_unity

    Didn't work. when cloning, it creates a different folder that have all the files but they are still read-only.



    When you say:
    How should it be referenced in order to be *embed* ? Do i need to change the manifest?

    Best regards
     
  8. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    The package manifest (package.json) must be at the root of your package folder. This is the file the package manager is looking for. If it is there, it will register that package in your project. You don't need to have the package dependency defined in the `dependencies` of the project manifest. But if it is, this is fine, the *embedded* package supersede the explicit dependency.
     
  9. JPFerreiraVB

    JPFerreiraVB

    Joined:
    Sep 18, 2017
    Posts:
    39
    It worked.

    After doing you suggestion, i realize a warning was raised in the editor, related to all scripts not having a Assembly definition. I looked in the documentation and added one to the AvatarCore package, and bam!! Everything worked.

    The package is imported using the manifest file structure i showed. Also the package is now living in the folder: <ProjectPath>/Library/PackageCache/com.company.AvatarCore.

    I can use all assets in the package now.

    What i can't do is having this error



    I looked to this thread: https://forum.unity.com/threads/network-configuration.590470/
    And i was told by company IT that HTTP/HTTPS ports are open and we do NOT have a proxy server.


    And even without this error (using a public github repo for in another test) i'm unable to have the functionailty like unity packages have.



    Best regards
     
  10. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    You have configured a *scoped registry* to host this custom package? If yes, the server you're trying to download from may be badly configured. It may not be including all the public certificates in the chain needed for the Package Manager to validate the request.

    There are two things you can do.

    1) Configure your scope registry URL to not used SSL (i.e. use htpp instead of https)
    2) Debug your server. (I referred this Stack Overflow response to help you out: https://stackoverflow.com/a/40359504/449712)

    Pascal
     
  11. JPFerreiraVB

    JPFerreiraVB

    Joined:
    Sep 18, 2017
    Posts:
    39
    And i'm back...

    I try to build first i get this error by opening the Build settings:

    Operation UnityEditor.PackageManager.Requests.SearchRequest failed with Error: UnityEditor.PackageManager.Error

    After ignoring it, if i try to build i get this error:

    error CS0246: The type or namespace name 'UnityEditorInternal' could not be found (are you missing a using directive or an assembly reference?)

    In several scripts.
    Any idea on why this happens and how to fix it?

    Best regards
     
  12. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
  13. JPFerreiraVB

    JPFerreiraVB

    Joined:
    Sep 18, 2017
    Posts:
    39
    Shure

    Here:
    https://we.tl/t-fH6dnAeH9Y

    Anothe update. I realize that all the errors thrown are relative to Scripts that are in different editor folder.
    Example:

    Core
    - ThirdPartyPlugin
    - PluginA
    - Editor
    ScriptA
    - PluginB
    - Editor
    ScriptB


    ScriptA and ScriptB with error: The type or namespace name 'UnityEditorInternal' could not be found (are you missing a using directive or an assembly reference?)
     
  14. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    @JPFerreiraVB ,

    This error
    Operation UnityEditor.PackageManager.Requests.SearchRequest failed with Error: UnityEditor.PackageManager.Error

    looks to be a proxy issue. This is probably because you are inside a closed network. Can we do a test? Can you try to change the registry URL to *http://packages.unity.com*? This will override the default SSL encrypted route to use the non-SSL one. I'm not 100% sure it will work.

    In your project manifest (/Packages/manifest.json), add this line

    "registry": "http://packages.unity.com",


    For you other errors.I looked at your log files. And indeed you have these UnityEditorInternall errors:

    Library\PackageCache\com.visionbox.avatarcore@8cb93efcb8306661da1a7b324dc4df4b5cf7af13\ThirdPartyAssets\PostProcessing\Editor\Monitors\HistogramMonitor.cs(1,7): error CS0246: The type or namespace name 'UnityEditorInternal' could not be found (are you missing a using directive or an assembly reference?)


    I've searched on the net for this error and I found this:

    https://answers.unity.com/questions/710400/using-unityeditorinternal-name-space-on-mobile.html

    It is not clear to me from the log but you may have misconfigured platform in one of your package assembly definition files. Make sure that all *editor* code is not also built with your *runtime*.

    Let me know if it helps!

    Pascal
     
  15. JPFerreiraVB

    JPFerreiraVB

    Joined:
    Sep 18, 2017
    Posts:
    39
    Hi @okcompute_unity , it's almost 100% working

    Here are the steps that might help another user:
    1- Changed the manifest.json
    Replace this:
    "registry": "https://git.intra.companyname.com",
    To this:
    "registry": "http://packages.unity.com",

    I thought the registry was needed to fetch the package from company gitlab.
    Changing this got me rid of two errors
    - Operation UnityEditor.PackageManager.Requests.SearchRequest failed with Error: UnityEditor.PackageManager.Error
    - This error is gone


    2- All editor scripts available in my package are now organized in one editor folder, that folder contains a assembly file that have "include platform: Editor", and reference the CoreAssembly file.

    After that i was able to build the project.

    What's left for work 100%
    Having the ability to choose which the version of the package to install (i have to dig deeper in scope registry)
    When building i'm having errors in some PostProcessing Shaders (this does not affect my project directly but might to some other user, and despite the error, unity is still able to build)



    This package thing it has been a road to hell, but we are moving. Hope the final official version be according to Unity standards.
     
  16. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    The main issue here is lack of documentations. We are working on it! If we had documentation, I'm pretty sure you would never made this (obvious when you know) mistake:

    Which generated a lot of noise in our discussion.

    Regards,

    Pascal