Gui.Window won't show in Unity - unity3d

I have some code like follwing:
if( GUI.Button(
new Rect(Screen.width/4f,50f,Screen.width/2f,Screen.height/9f),"RessetLevel")) {
showingWinsows = true;
if(showingWinsows)
{
rectWindow = GUI.Window(
0,
rectWindow,
DoMyWindow,
"Are you sure you want to reset All level ?"
);
}
I've insert the userGuiLayout = false; in my Awake() function. But the window still doesn't show. How do I fix this?

The problem is that the window is only drawn when the button is pressed.
You need to move the code that checks the flag out of the if( GUI.Button ), something like this:
if( GUI.Button(new Rect(Screen.width/4f,50f,Screen.width/2f,Screen.height/9f),"Resset Level"))
{
showingWinsows = true;
}
if(showingWinsows)
{
rectWindow = GUI.Window(0,rectWindow,DoMyWindow,"Are you sure you want to reset All level ?");
}

Related

How to easily detect if map is empty or not in dart?

Hi so I have some variable that take care of whether my button and other widget should be shown or not, I already create a if statement for it and the issue is with detecting whether the map is currently empty or not.
Here's the code:
/// Initialize the data
Map data = {};
///If statement
if (povStatus == 'pic' && data.isEmpty) {
showReportEditButton = false;
showReportWriteButton = true;
showReportNotif = true;
showHeaderReport = false;
} else {
showReportEditButton = true;
showReportWriteButton = false;
showReportNotif = false;
showHeaderReport = true;
}
Based on the code above, when the data is empty it work just fine and enter the first if. But when I fill the "data" and the map becomes not empty it still enter the first if rather than the else part. What's the reason of this ?
You can read the entries:
Map<String,String> map={};
if(map.entries.isEmpty){
//Do something
}

Jodit -> Hide Toolbar after initialization

i use Jodit as wysiwyg editor and have a beginner question.
At initialization of the editor, i want to hide the toolbar.
This works perfect:
var editor = new Jodit('#freitext_oben', {
fullsize: false,
toolbar: false,
editorCssClass: 'editor_freitext'
});
Now i want a custom button which calls a function that toggles the toolbar but i don't know how to set this option.
i need something like
function toggle_toolbar() {
editor.toggleToolbar();
}
But i don't know the exact syntax...
Please help ;-(
So here's a way that I've found to do this:
public ToggleToolbarVisibility()
{
if(!editor.editor.toolbar.container.style.display != "none")
{
editor.toolbar.container.style.display = "none";
}
else
{
editor.toolbar.container.style.display = "";
}
}

Extension event loop in Gnome 3.10 vs 3.14

I wrote this accessibility extension:
https://extensions.gnome.org/extension/975/keyboard-modifiers-status/
https://github.com/sneetsher/Keyboard-Modifiers-Status
Which works as supposed in Gnome Shell v3.14 & v3.16 but not in v3.10. It shows the only the initial keyboard modifiers state after i
restarted it and never update it after that.
Here the full code:
const St = imports.gi.St;
const Mainloop = imports.mainloop;
const Main = imports.ui.main;
const Gdk = imports.gi.Gdk
let button, label, keymap;
function _update() {
let symbols = "⇧⇬⋀⌥①◆⌘⎇";
let state = keymap.get_modifier_state();
label.text = " ";
for (var i=0; i<=8; i++ ) {
if (state & 1<<i) {
label.text += symbols[i];
} else {
//label.text += "";
}
}
label.text += " ";
}
function init() {
button = new St.Bin({ style_class: 'panel-button',
reactive: false,
can_focus: false,
x_fill: true,
y_fill: false,
track_hover: false });
label = new St.Label({ style_class: "state-label", text: "" });
button.set_child(label);
keymap = Gdk.Keymap.get_default();
keymap.connect('state_changed', _update );
Mainloop.timeout_add(1000, _update );
}
function enable() {
Main.panel._rightBox.insert_child_at_index(button, 0);
}
function disable() {
Main.panel._rightBox.remove_child(button);
}
Trying to debug, I modified the code to show (state label + a counter)
let c,button, label, keymap;
c=0;
function _update() {
Gtk.main_iteration_do(false);
c++;
let symbols = "⇧⇬⋀⌥①◆⌘⎇";
//let keymap = Gdk.Keymap.get_default()
let state = keymap.get_modifier_state();
label.text = " ";
for (var i=0; i<=8; i++ ) {
if (state & 1<<i) {
label.text += symbols[i];
} else {
//label.text += "";
}
}
label.text += " "+c+" ";
return true;
}
I can confirm these:
keymap.connect('state_changed', _update ); this signal is never raised
timeout callback works well
label is updated and show the initial state & the incrementing counter
So I think there is something with event loop as it does not pull
state update or does not process its events.
Could you please point me to way to fix this and what's the difference
between v3.10 & v3.14?
Assuming that commenting out the definition of keymap was intentional, check that it is still assigned elsewhere in your code. Have you tried using a -(minus) rather than a _(underscore)? Most events use the former in JS space, rather than the latter and this has been the problem for me when in several cases where I was attaching events to changing the active workspace, where the back-end for Meta.Display fires workspace_switched, the GJS space connects through workspace-switched and there are a lot more examples there.
For official documentation, including the correct event, property and function names for within GJS space, refer to GNOME DevDocs I don't know when it became official, but they state that it is here

How to activate a script from another object?

I'm trying to activate a script from another object on a button press. Heres what I tried:
function Update () {
if(Input.touchCount == 1) {
GameObject.Find("theobject").GetComponent(thescript).enabled = true
}
else {
GameObject.Find("theobject").GetComponent(thescript).enabled = false
}
}
When I press play, It has no errors but when I press the button, nothing happens. Are there anything wrong with the script. I'm new to Unity and Javascript. Any help would be appreciated. Thanks in advanced!
This is what you can do:
if(GUI.Button(new Rect(10,10,100,90),"Button to activate object"))
{
gameObject.active = true;
}

Update OpenLayers popup

I am trying to update some popups in my map but I am not able to do that.
Firstly I create some markers, and with the next code, I create a popup associated to them. One popup for each marker:
popFeature = new OpenLayers.Feature(markers, location);
popFeature.closeBox = true;
popFeature.popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
'autoSize': true
});
popFeature.data.popupContentHTML = "hello";
popFeature.data.overflow = (false) ? "auto" : "hidden";
var markerClick = function (evt) {
if (this.popup == null) {
this.popup = this.createPopup(this.closeBox);
map.addPopup(this.popup);
this.popup.show();
} else {
this.popup.toggle();
}
currentPopup = this.popup;
OpenLayers.Event.stop(evt);
};
mark.events.register("mousedown", popFeature, markerClick);
After that, I add the new marker to my marker layer.
Everything is fine until here, but, I want to update the popupcontentHTML some time later and I don't know how I can access to that value.
I read OL API but I don't understand how to get it. I am lost about features, events, extensions...
I want to know if I can access to that property and write other word.
I answer myself, maybe it helps other people in future:
for(i = 0; i < map.popups.length; i++){
if(map.popups[i].lonlat.lon == marker.lonlat.lon){
map.popups[i].setContentHTML("new content");
}
}
Content will be refreshed at the moment.