Jump to content

Search the Community

Showing results for tags 'callback'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements
    • Welcome Aboard
  • Kerbal Space Program 2
    • KSP2 Dev Updates
    • KSP2 Discussion
    • KSP2 Suggestions and Development Discussion
    • Challenges & Mission Ideas
    • The KSP2 Spacecraft Exchange
    • Mission Reports
    • KSP2 Prelaunch Archive
  • Kerbal Space Program 2 Gameplay & Technical Support
    • KSP2 Gameplay Questions and Tutorials
    • KSP2 Technical Support (PC, unmodded installs)
    • KSP2 Technical Support (PC, modded installs)
  • Kerbal Space Program 2 Mods
    • KSP2 Mod Discussions
    • KSP2 Mod Releases
    • KSP2 Mod Development
  • Kerbal Space Program 1
    • KSP1 The Daily Kerbal
    • KSP1 Discussion
    • KSP1 Suggestions & Development Discussion
    • KSP1 Challenges & Mission ideas
    • KSP1 The Spacecraft Exchange
    • KSP1 Mission Reports
    • KSP1 Gameplay and Technical Support
    • KSP1 Mods
    • KSP1 Expansions
  • Community
    • Science & Spaceflight
    • Kerbal Network
    • The Lounge
    • KSP Fan Works
  • International
    • International
  • KerbalEDU
    • KerbalEDU
    • KerbalEDU Website

Categories

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Skype


Twitter


About me


Location


Interests

Found 1 result

  1. Hello, I am trying to create a new GUI window in KSP but when I call my delegate callback(onDraw()), VS errors on me. I've looked at the API pages, Unity tutorials and C# pages for help but have been unable to fix the issues. I'd greatly appreciate any help. Below is my code along with the VS errors. namespace KSP_Wind_Display { // public delegate CallBack(int que, int onDraw); public class Wind_GUI_Display : PartModule { delegate void CallBack(); CallBack callback; private Rect window_pos = new Rect(); // New blank window private GUIStyle window_style, label_style; private bool has_init_styles = false; public override void OnStart(PartModule.StartState state) { base.OnStart(state); if (!has_init_styles) init_styles(); callback += onDraw; if (state != StartState.Editor) RenderingManager.AddToPostDrawQueue(0, callback()); <-------- Error 11 The best overloaded method match for 'RenderingManager.AddToPostDrawQueue(int, Callback)' has some invalid arguments <-------- Error 12 Argument 2: cannot convert from 'void' to 'Callback' } private void onDraw() // Start up the window { if (this.vessel == FlightGlobals.ActiveVessel) window_pos = GUILayout.Window(10, window_pos, onWindow, "Wind Direction", window_style); } private void onWindow(int window_id) { GUILayout.BeginHorizontal(); GUILayout.EndHorizontal(); GUI.DragWindow(); // Makes the window draggable } private void init_styles() { window_style = new GUIStyle(HighLogic.Skin.window); window_style.fixedWidth = 250.0f; label_style = new GUIStyle(HighLogic.Skin.label); label_style.stretchWidth = true; // stretches the label width to that of the window has_init_styles = true; } } } For Error 11, shouldn't that result in onDraw() being called. AddToPostDrawQueue needs an int and Callback as it's arguments and that's what I am passing it. For Error 12, I suspect the problem is where I first declare Callback to be void type of delegate. However, I don't want Callback to return anything so it has to be a void. I've worked at this problem for about 2 hours now and online forums, tutorials and man pages haven't help. Can someone here spot the issue and at least give me a hint on how to resolve it? Thanks in advance.
×
×
  • Create New...