Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KSP 1.8.1 - FAR 0.15.11.3 Mach - no button texture shown #85

Open
Gordon-Dry opened this issue Nov 5, 2019 · 19 comments
Open

KSP 1.8.1 - FAR 0.15.11.3 Mach - no button texture shown #85

Gordon-Dry opened this issue Nov 5, 2019 · 19 comments

Comments

@Gordon-Dry
Copy link

See
Screen-2019-11-05_17-12-36
and
Screen-2019-11-05_17-13-02

Log:
https://www.dropbox.com/s/w8z9jco9xlljjv6/player.log%20and%20stuff%202019-11-05-02.zip?dl=1

@dkavolis
Copy link
Owner

dkavolis commented Nov 5, 2019

Sorry, I don't know why it's happening. FAR uses textures from the GameDatabase so the issue might be with KSP, and of course it's not reproducible on my machine. Can you try FAR from https://github.com/dkavolis/Ferram-Aerospace-Research/tree/logs and overwriting the icon path with

@FARConfig[default]:FINAL
{
  @CONFIG[textures]
  {
    %iconButtonStock = <relative to GameData path to icon image without extension>
  }
}

and see if a different icon works? Default FARConfig

If you use DLL from bin/Debug the entire FARConfig will be dumped to log in main menu.

@Gordon-Dry
Copy link
Author

I don't need the @ because the FARConfig.cfg already got the correct paths.
But the release got no FARConfig.cfg - that is the thing I guess ...

I will test the build from the "logs" repo next session - as is.

@Gordon-Dry
Copy link
Author

Gordon-Dry commented Nov 5, 2019

Hmm. Now I loaded the game and as I went to the R&D the UI became unresponsive, I cannot leave R&D and this is spammed to the log:

NullReferenceException: Object reference not set to an instance of an object
  at FerramAerospaceResearch.FARConfig.get_Item (System.String key) [0x00005] in <1800ba8bb55344948185fec5b0ff0f00>:0 
  at FerramAerospaceResearch.FARConfigParser`1[T].get_Instance () [0x0000a] in <1800ba8bb55344948185fec5b0ff0f00>:0 
  at FerramAerospaceResearch.FARDebugAndSettings.OnScenarioChanged () [0x00000] in <1800ba8bb55344948185fec5b0ff0f00>:0 
  at FerramAerospaceResearch.FARDebugAndSettings.Update () [0x00008] in <1800ba8bb55344948185fec5b0ff0f00>:0 
 
(Filename: <1800ba8bb55344948185fec5b0ff0f00> Line: 0)

Do I really HAVE to replace the binaries from those of the bin/debug folder?

Or is it something else?

@Gordon-Dry
Copy link
Author

Well, this time I used the debug binaries and the log spamming already started as KSP reached the main menu...
I guess it already did it like that the last session but I only recognized it after checking the log as I was stuck in R&D.

After loading the save there is no FAR button at all.
Before it was a blank button. Now it's none.

@Gordon-Dry
Copy link
Author

@dkavolis
Copy link
Owner

dkavolis commented Nov 5, 2019

Ok, the latest commit should solve the issue. Some mod was modifying AssemblyLoader.loadedAssemblies while FAR was iterating over it.

@Gordon-Dry
Copy link
Author

Button is there again, no log spamming - but still no icon on the button. ;)

@dkavolis
Copy link
Owner

dkavolis commented Nov 6, 2019

Can you check if the button texture works on a clean KSP install only with FAR and dependencies? Might be a mod interaction

@Gordon-Dry
Copy link
Author

With just

FerramAerospaceResearch (dev/logs)
ModularFlightIntegrator
Squad
ModuleManager.4.1.1.dll

and starting a new career test save - no icon on the button:
Screen-2019-11-06_13-30-30

Log:
https://www.dropbox.com/s/3kqyq6p7m39frxn/player.log%20and%20stuff%202019-11-06-01.zip?dl=1

@dkavolis
Copy link
Owner

dkavolis commented Nov 6, 2019

Ok, I think I know what's happening, try now
e0248cf

@Gordon-Dry
Copy link
Author

With all my mods - no icon:
Screen-2019-11-06_14-26-52
Log:
https://www.dropbox.com/s/cz3n326bqwdy0kw/player.log%20and%20stuff%202019-11-06-02.zip?dl=1

With the minimum install environment and a new career - no icon as well (see pic above).
Log:
https://www.dropbox.com/s/x40qouesh38q3uu/player.log%20and%20stuff%202019-11-06-03.zip?dl=1

@Gordon-Dry
Copy link
Author

@dkavolis
Copy link
Owner

dkavolis commented Nov 6, 2019

Well, the texture is loaded and exists in the GameDatabase so I'm not sure what is happening. My only other guess is somehow corrupt image file.

@dkavolis
Copy link
Owner

dkavolis commented Nov 6, 2019

Can you check if the icon shows up once in main menu with DLL from https://drive.google.com/file/d/1bBlSc4IeXqYr4VgYcpS7tLH-kB01se7d/view?usp=sharing?
test

The only difference is I added this segment of code immediately after call to ApplicationLauncher.Instance.AddModApplication

var go = new GameObject("Image");
go.AddComponent<CanvasRenderer>();
var rectTransform = go.AddComponent<RectTransform>();
var image = go.AddComponent<Image>();
rectTransform.SetParent(MainCanvasUtil.MainCanvas.transform);
rectTransform.position = Vector3.zero;
image.sprite = Sprite.Create(icon, new Rect(0, 0, icon.width, icon.height), new Vector2(0.5f, 0.5f), 500f);

If there's still no icon, I'll look into loading the image myself.

@Gordon-Dry
Copy link
Author

With minimum environment:
Screen-2019-11-06_17-47-20

I would say this is a "nope".

Log:
https://www.dropbox.com/s/h1yb2dionrz64rb/player.log%20and%20stuff%202019-11-06-06.zip?dl=1

btw this .dll did not create an additional CustomFARConfig.cfg directly in GameData

@dkavolis
Copy link
Owner

dkavolis commented Nov 6, 2019

This time I'm loading the texture myself but you don't have to wait till main menu
https://drive.google.com/open?id=1bBlSc4IeXqYr4VgYcpS7tLH-kB01se7d

using System.Collections;
using FerramAerospaceResearch.FARUtils;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;

namespace FerramAerospaceResearch
{
    [KSPAddon(KSPAddon.Startup.Instantly, true)]
    public class ImageLoader : MonoBehaviour
    {
        private void Awake()
        {
            StartCoroutine(Test());
        }

        private IEnumerator Test()
        {
            using UnityWebRequest request =
                UnityWebRequestTexture
                    .GetTexture($@"file:///{FARConfig.CombineGameData("FerramAerospaceResearch/Textures/icon_button_stock.png")}");
            yield return request.SendWebRequest();

            Texture2D tex = DownloadHandlerTexture.GetContent(request);
            FARLogger.Info($"Testing image loading from {request.url}");
            var go = new GameObject("Image");
            go.AddComponent<CanvasRenderer>();
            var rectTransform = go.AddComponent<RectTransform>();
            var image = go.AddComponent<Image>();
            rectTransform.SetParent(MainCanvasUtil.MainCanvas.transform);
            rectTransform.position = Vector3.zero;
            image.sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f), 500f);
        }
    }
}

test

@Gordon-Dry
Copy link
Author

Better late than never (I wanted to do something else than just troubleshooting this issue):
screenshot0

@dkavolis
Copy link
Owner

dkavolis commented Mar 4, 2020

Try dev branch and FARConfig.cfg for options, works with MM. Add the .png extension to texture url and change its loader to default if you have issues with textures not loading.

Note that there's an additional DLL now for adding and testing new features directly in Unity editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants