CesiumGS / cesium-unity

Bringing the 3D geospatial ecosystem to Unity
https://cesium.com/platform/cesium-for-unity/
Apache License 2.0
351 stars 85 forks source link

Cesium Credits #333

Closed jonmartincom closed 1 year ago

jonmartincom commented 1 year ago

As the credit prefab and ui ref links are referenced in code and ui included in the package, you can't easily make changes to the text layout i.e. make it scale etc change font, as the package reverts or diallows changes (rightly) and puts the original ui back in place this means you can't easily make a new prefab or ui as far as I can see... might be being dumb here, but I couldn't figure this out.

Perhaps I take it you copy your own prefab into the heirarchy, and turn off show credits (who knows - maybe I'll try that) - (edit- Did that faced replication and other issues.)

The only way bar above is to clone package make your own git and reference that instead, awkward for updates.

Can I suggest adding a link to the credit prefab in the runtime settings scriptable object or preferably as a GameObject field in the Cesium3DTileset, so that user can specify and customise the UI easily without, going insane.

otherwise awesome product thank you cesium and google much appreciated!!

kring commented 1 year ago

It should be possible to change fonts and such without changing the plugin itself. The trick is to add your own CesiumCreditSystem rather than letting Cesium add one automatically, and then modify it as necessary. So:

  1. Find the CesiumCreditSystem prefab in Cesium for Unity/Runtime/Resources in the Project tab. Drag it into your Hierarchy to add it to your scene. Update: you must also rename the prefab to exactly CesiumCreditSystemDefault.
  2. Find CesiumCreditSystemUI in the same folder. Ctrl-C to copy it, and then Ctrl-V to paste it to a folder in your project. Rename it to MyCreditSystemUI or somesuch.
  3. Click the CesiumCreditSystem that you added to your scene, and in the "UI Document" component, change the "Source Asset" to point to "MyCreditSystemUI".
  4. Modify "MyCreditSystemUI" as you see fit.
jonmartincom commented 1 year ago

Much appreciated, I'll follow above! thanks!

kring commented 1 year ago

If it works for you, please close this issue.

ShawkiVA commented 1 year ago

Hopping in here. I attempted the steps listed above, but found that after Step 1 I also needed to rename the CesiumCreditSystem gameobject in my hierarchy to "CesiumCreditSystemDefault" (as CesiumCreditSystem.GetDefaultCreditSystem() is expecting this). Thank you for your help!

jonmartincom commented 1 year ago

That does, as system was still overriding! Cheers will close!

TobiasWehrum commented 7 months ago

@kring This doesn't work for me. At step 2, after copying CesiumCreditSystemUI, I'm getting lots of these errors in the Unity console:

Assets\Scripts\MyCreditSystemUI.cs(110,18): error CS0122: 'CesiumCredit' is inaccessible due to its protection level

Maybe this is because I'm using Cesium via the package manager, which probably creates a separate assembly, and CesiumCredit (and other elements CreditSystemUI uses) is marked ìnternal?

kring commented 7 months ago

Hmm yeah that looks like a problem @TobiasWehrum. CesiumCredit was changed from public to internal, but it was way back before Cesium for Unity v1.0.0. So I'm not sure why this worked before and it doesn't now (and doesn't look like it should). We'll have to investigate. I'll reopen this issue and change the title accordingly.

kring commented 7 months ago

I ended up writing a new issue instead: #437.

JakobAnarkyLabs commented 2 months ago

I think that the issue @TobiasWehrum is experiencing might be due to a misunderstanding related to step 2 in the guide @kring gave:

  1. Find CesiumCreditSystemUI in the same folder. Ctrl-C to copy it, and then Ctrl-V to paste it to a folder in your project. Rename it to MyCreditSystemUI or somesuch.

There are two assets called CesiumCreditSystemUI. One is the CesiumCreditSystemUI.uxml file in the .../Runtime/Resources folder, and the other is the CesiumCreditSystemUI.cs in the .../Runtime folder. I guess that it is the CesiumCreditSystemUI.uxml file in the .../Runtime/Resources that we are supposed to duplicate and move, and not the C# file.

kring commented 1 month ago

Thanks for the note @JakobAnarkyLabs, that's a really good point!