Moonflow-Studio/Moonflow-Lensflare-System

Some issues

ZauronDark opened this issue · 7 comments

Hi, today I tried your solution on a test project, it's nearly the same as working with the built-in Lens flare asset, really great work keep up :) leaving you with 2 issues I got when practicing, I used this on Unity 2019.4.9f1 LTS.

  1. this debug line is getting spammed on console (when not in play mode)
    Not enough source UnityEngine.Debug:Log(Object) URPLensFlare:CreateMesh() (at Assets/Scripts/Unity_Utils/URPLensFlare/URPLensFlare.cs:215) URPLensFlare:Update() (at Assets/Scripts/Unity_Utils/URPLensFlare/URPLensFlare.cs:154)

  2. Editor namespace classes are in use outside Editor folder like [MenuItem] attribute, however, I tried enveloped #if UNITY_EDITOR around CreateFlareDataModel and LoopCreateFlareAssetModel functions of both classes in the URPFlareAsset.cs file, now I can build without issues, however, after build no flare rendered (on android device, OpenGL es 2)

My bad, I didn't thoroughly test 2nd issue, however, I made a slight change in URPFlareLauncher, since in my case, I am using multiple cameras (it's my habit of separating UI scene with the main camera and world/levels load into as sub-Scene to that Ui Scene and using different Camera).

[Tooltip("Attach Camera with URPLensFlare Component")]
    public Camera sceneCamera;
    
    private void OnEnable()
    {
        lightSource = GetComponent<Light>();
        // Add self to awake function: AddLight in URPLensFlare.cs on camera in render;
        sceneCamera.GetComponent<URPLensFlare>().AddLight(this);
    }

now, this should Render flares on built, but....

Editor namespace classes are in use outside the Editor folder like [MenuItem] attribute, however, I tried enveloped #if UNITY_EDITOR around CreateFlareDataModel and LoopCreateFlareAssetModel functions of both classes in the URPFlareAsset.cs file, now I can build without issues.

However, I have to revert this #if UNITY_EDITOR changes because I realized i cannot edit Model data asset anymore with that. I also cannot move URPFlareAsset.cs inside the Editor folder, as URPFlareLauncher class starts complaining about model asset class isn't exist. being outside the Editor folder and having Editor functions in use means we cannot build. you should try separating URPFlareAsset.cs into 2 files, one as data class and the other in the Editor folder with using UnityEditor namespace.

currently, I can run on Editor Play mode :D

yeah I think I got the issue this happening on the play, I tried to re-create the model asset 3 times already.

you moved those functions to the Editor folder this is breaking the Asset file on the build I guess

edit: not sure maybe I am wrong, but that file is appearing and disappearing its content time to time, have to test exactly when it does, however In build log Lens flare image is getting compiled with build

yeah I think I got the issue this happening on the play, I tried to re-create the model asset 3 times already.

you moved those functions to the Editor folder this is breaking the Asset file on the build I guess

edit: not sure maybe I am wrong, but that file is appearing and disappearing its content time to time, have to test exactly when it does, however In build log Lens flare image is getting compiled with build

Now I found that the asset must be loaded by Resources.load or using assetbundle, otherwise it can't be loaded, that cause the problem in the program after build. However the two ways to load it in above is not so convenience, I'm trying to find a better way to load it. Give me some time.

Give me some time.

take your time :), I don't have any project, I am just a curious guy testing your solution to lens flare that unity didn't care to support in URP.

Give me some time.

take your time :), I don't have any project, I am just a curious guy testing your solution to lens flare that unity didn't care to support in URP.

Hi, bro. I have already updated a new version, please have a try. Now it can be shown on Android device.
The mistake caused by a mismatch class name, I've already learned from it. And at the same time, I found that the texture should be saved in Resources folder, or it can't be found correctly. I'll soon updated this setting guider to readme.md.

However, I have not test it in multiple camera yet. I'm still trying. And maybe there should be a more convenient way to load flare texture.