Coder Social home page Coder Social logo

clickthroughblocker's Introduction

Having clicked one too many times on one window, only to have it click on the parts underneath (in the Editor), or click on an unwanted item in flight, I decided to solve the problem with yet another mod

Mods which use the Click Through Blocker would need to be modified, and this would become a hard dependency for that mod.

The changes are very simple:

Replace all calls to GUILayout.Window with ClickThruBlocker.GUILayoutWindow, the parameters are identical Replace all calls to GUI.Window with ClickThruBlocker.GUIWindow, the parameters are identical

How it works

Each call first calls the original method (ie: ClickThruBlocker.GUILayoutWindow will call GUILayout.Window). After the call, the position of the mouse is checked to see if it was on top of the window Rect, if it is, it then locks the controls so that clicks don't pass through to any other window.

Usage

Add the following to the top of the source:
	using ClickThroughFix;
Replace calls to GUILayout.Window with ClickThruBlocker.GUILayoutWindow
Replace calls to GUI.Window with ClickThruBlocker.GUIWindow

Functions - Identical to the GUI and GUILayout versions Rect GUILayoutWindow(int id, Rect screenRect, GUI.WindowFunction func, GUIContent content, GUIStyle style, params GUILayoutOption[] options); Rect GUILayoutWindow(int id, Rect screenRect, GUI.WindowFunction func, Texture image, GUIStyle style, params GUILayoutOption[] options); Rect GUILayoutWindow(int id, Rect screenRect, GUI.WindowFunction func, string text, GUIStyle style, params GUILayoutOption[] options); Rect GUILayoutWindow(int id, Rect screenRect, GUI.WindowFunction func, GUIContent content, params GUILayoutOption[] options); Rect GUILayoutWindow(int id, Rect screenRect, GUI.WindowFunction func, Texture image, params GUILayoutOption[] options); Rect GUILayoutWindow(int id, Rect screenRect, GUI.WindowFunction func, string text, params GUILayoutOption[] options);

Rect GUIWindow(int id, Rect clientRect, WindowFunction func, Texture image, GUIStyle style);
Rect GUIWindow(int id, Rect clientRect, WindowFunction func, string text, GUIStyle style);
Rect GUIWindow(int id, Rect clientRect, WindowFunction func, GUIContent content);
Rect GUIWindow(int id, Rect clientRect, WindowFunction func, Texture image);
Rect GUIWindow(int id, Rect clientRect, WindowFunction func, string text);
Rect GUIWindow(int id, Rect clientRect, WindowFunction func, GUIContent title, GUIStyle style);

Additional functions

bool MouseIsOverWindow(Rect rect) Returns true if the mouse is over the specified rectangle

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.