Welcome, Guest

Author Topic: After upgrading the framework, copy latest coherent.js into uiresources?  (Read 634 times)

Lisk

  • Posts: 39
    • View Profile
    • Legion TD 2
It seems like every time I upgrade the framework, I will need to copy a copy of coherent.js from one of the samples in the latest package, into each of my uiresources folders to overwrite its copy of the coherent.js.

Just confirming - this is the way I'm supposed to do it?

Is there any way to have a single copy of coherent.js that is referenced by all the HTMLs? Rather than copy-pasting the new coherent.js into each one of them one at a time. (I suppose I can write a script for it...)

Mike

  • Administrator
  • *****
  • Posts: 144
    • View Profile
Hi Lisk,

You don't have to take the coherent.js file from the samples. There's an archive which contains it and it is located in <ProjectDir>/Assets/CoherentUIGT (the JavaScriptBinding.zip one).

A possible approach that you can take is to serve the resources, which are shared between multiple projects, via an http server. Another approach is to modify the CoherentUIGTResourceHandler.cs script so that you can load shared resources from a different directory. You can achieve that by doing the following:

- For the sake of the example, lets assume that every time that you want to use a shared resource, it's URL will have the following format - coui://shared/<rest_of_path>.
- Add a member variable to the resource handler component which holds the directory as a string (i.e. SharedResourcesDir).
- Then, in the OnResourceRead method of the handler, around line 106 after the string cleanUrl = GetFilepath(url); line add this code snippet:

Code: [Select]
if (url.StartsWith("coui://shared")) {
    cleanUrl = SharedResourcesDir + url.Substring(13);
}

Regards,
Mike
« Last Edit: August 19, 2016, 02:04:36 AM by Mike »

Lisk

  • Posts: 39
    • View Profile
    • Legion TD 2
Thanks for the great reply, Mike.

When I do a refactor/workflow pass, I'll plan to look into the CoherentUIGTResourceHandler.cs script with the coui:// paths. It looks like it is exactly what I need.

Tags: