I'm creating a game in Unity, and I just added an inventory with multiple tabs (Inventory, Flora, and Bestiary). I put buttons on the tabs to switch between them and it was working smoothly until I tried creating a WebGL build. All of a sudden none of the buttons work. I didn't change anything, I have an event system and everything. I even tried deleting it all and remaking it and it still doesn't work. I'm an amateur at programming, so there's probably a better way to do it, but this is the code I have:
public void InventoryOpen()
{
inventory.SetActive(true);
flora.SetActive(false);
bestiary.SetActive(false);
}
public void FloraOpen()
{
inventory.SetActive(false);
flora.SetActive(true);
bestiary.SetActive(false);
}
public void BestiaryOpen()
{
inventory.SetActive(false);
flora.SetActive(false);
bestiary.SetActive(true);
}
My buttons are properly routed to the functions on OnClick(), so I don't know what the problem is.
Related
Hey im having issues with a website in the jxbrowser. it seems like it is running into a timeout or whatever and then in the jxbrowser there is a dialog showing up "website not responding" and i can click on "reload" or "leave".
Can I in any way access this dialog and overwrite it? For instance everytime i would get this dont ask but go to the homepage instead?
I'm having trouble finding this if it is even possible.
I found a solution. JXBrowser has a RenderAdapter where a function exists onRenderUnresponsive wich can be overridden. Look at this: https://jxbrowser.support.teamdev.com/support/solutions/articles/9000091687-detecting-unresponsive-web-page
In my case I simply want to reload the website:
Browser browser = new Browser();
browser.addRenderListener(new RenderAdapter() {
#Override
public void onRenderUnresponsive(RenderEvent event) {
browser.reloadIgnoringCache(false);
}
});
Very basic loader question.
My WIMMOne watch uses Android 2.1 (version 7).
There are no orientation changes, etc. with a watch. The small screen does not have room for any layout changes. So no need to deal with any kind of layout change.
The app I am working on now simply reads from a cursor, and displays an open ended scrolling list. My first app had a fragment and that was a pain. So I decided since I don't need fragments I will do away with the complexities of fragments.
I START WITH:
public class PhoneListActivity extends Activity
implements LoaderManager.LoaderCallbacks <Cursor>;
THEN:
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.phone_list_activity);
FINALLY:
getLoaderManager().initLoader(0, null, this);
BUT:
Because it is 2.1 I need to use:
getSupportLoaderManager().initLoader(0, null, this);
BUT: -
That generates compile errors, so I need to use:
public class PhoneListActivity extends FragmentActivity . . . (not just Activity)
BUT: -
It immediately crashes on load in the ContentProvider.
Postings in various sites refer to "Activities and ActivityFragments".
SO: QUESTION 1: Can my main class use "extends FragmentActivity" without setting up a separate fragment (ie: leave it just as an Activity).
QUESTION 2: If not, does that mean that to use a loader I must set up a separate fragment and deal with the issues of fragments?
Many thanks,
Clark
The answer is YES.
I redid part of the program and it now works without using fragments. It has the open ended scrolling being loaded from a cursor and basically the same structure above
I think something in handling my cursor was causing it to crash.
Clark
I'm using OpenSceneGraph and Qt to develop a simulation software. Simulations can involve multiple bots in the same virtual world. My requirements for views are as follows:
Ability to show static world cameras
Ability to show bot cameras
Ability to move these views around and/or stack them
To accomplish these tasks, I have made an 'OSGWidget' that uses an Osg Viewer to render the scene inside a QGLWidget. This OSGWidget is in turn put inside a QDockWidget that can be moved around and/or stacked, fulfilling that requirement.
The problem is that when using multiple singular viewers to render the same scene in different widgets, I get strange render behavior. Namely, textures do not display properly or sometimes even at all.
I have looked around SO and the OSG forums and while people have had similar problems, the only responses I have seen have suggested switching to an Osg CompositeViewer. For my purposes, I would like to avoid using that as it breaks my desired requirement of movable and stackable widgets rendering the same scene.
Is this an intractable situation that just isn't easily handled by Osg? I have seen several posts that say this is not how OSG is 'supposed to work' but they haven't really provided facts to support that claim. Has anyone done something similar or have any ideas/insight? I can provide code snippets if needed, but as this might just be a contradiction to Osg's ideology I will wait to get some responses.
Thanks to some help from the comments and from a couple other sites, I was able to successfully get the behavior I wanted from CompositeViewer.
Basically, all OSG Views go through my "WidgetDriver" which contains a CompositeViewer.
class OsgWidgetDriver {
public:
void init() {
compositeViewer = new osgViewer::CompositeViewer;
compositeViewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
compositeViewer->setReleaseContextAtEndOfFrameHint(false);
}
void start() {
initialized = true;
}
void stop() {
compositeViewer->stopThreading();
compositeViewer->setDone(true);
}
void updateFrame() {
if (initialized)
compositeViewer->frame();
}
void addView(osgViewer::View *view) { compositeViewer->addView(view); }
bool isInitialized() { return initialized; }
protected:
bool initialized;
osgViewer::CompositeViewer *compositeViewer;
};
Then, whenever I make a new Qt OSG Widget, I hand the osg::View off to the driver. I let the driver update the render window, while Qt can still update the QWidget accordingly. It even allows me to place the widget in a QDockWidget so I can move them around and stack them as needed.
Some final notes on the process if anyone else wants to do this:
You will very likely run into weird texture display problems when multiple OSG Viewers are looking at one scene. If that happens, use the osgUtil::Optimizer::TextureVisitor to set all textures to "UnrefImageAfterApply = false". This will allow proper texture displays across multiple osg::View instances.
The CompositeViewer options I set above, threading model to SingleThreaded and releaseContextAtEndOfFrame to false, are necessary if you want a single thread acting upon multiple views. If you use a widget driver like I did, you will want to do this.
I recreated the example of a webkit that displays the content of a textEdit containing HTML: http://qt-project.org/doc/qt-4.8/webkit-previewer.html
I changed it so rather than the webkit HTML being changed upon clicking the button, it's changed upon the text in the textEdit being changed:
// changed when button is click. Works fine.
void Previewer::on_previewButton_clicked()
{
// Update the contents in web viewer
QString text = htmlTextEdit->toPlainText();
webView->setHtml(text);
}
// change when text is changed. Crashes.
void Previewer::on_htmlTextEdit_textChanged()
{
// Update the contents in web viewer
QString text = "<html><body><h1>No crash!</h1></body></html>";
webView->setHtml(text);
}
This causes the program to crash as soon as it starts. I altered the program to run the function only a bit later (I thought maybe something needed to be initialized) but it still crashed once it reached the textChanged function. Why is it crashing? How can I fix this?
Your program is entering an infinite loop because, in the example, there's a connection between the webView's loadFinished(bool) signal and the text/html editor's updateTextEdit() slot.
Basically, editing the HTML causes the page to load again, which causes an update to the editor, which causes the page to load again, so on and so forth.
A quick way I solved this was to add a static bool flag to the updateTextEdit SLOT/function that only allows it to run once.
void MainWindow::updateTextEdit()
{
static bool once = false;
if (once) {
return;
}
once = true;
QWebFrame *mainFrame = centralWidget->webView->page()->mainFrame();
QString frameText = mainFrame->toHtml();
centralWidget->plainTextEdit->setPlainText(frameText);
}
Doing this worked for me, but your version might work differently than mine. I followed the example closely, but added an htmlchanged() slot to the previewer class, and made the connection like so:
connect(centralWidget->plainTextEdit, SIGNAL(textChanged()), centralWidget, SLOT(html_changed()));
Also, I'm no expert, but I'm pretty sure this is not the best way to get around this, and I assume that updateTextEdit() needs to run more than once. It'll work for the time being, though.
I have a timer in my application. For every 30 min, it will hit the web services and fetch the data and updates the UI. The application was working fine till yesterday. Suddenly, because of some issue, the web services were not available for some time. During that period, Application displayed the RPC Error multiple times(More than 100 alert boxes) in alert window. Because of this alert boxes, my application was hanged and i was not able to do anything.
I have tried several approaches, but nothing worked.Finally, I have tried to use a flag. In all the approaches, this looked promising. so i have implemented it.Basically, in this approach whenever we open an alert we will set a flag.While opening and closing alert we will reset this flag. But it didn't work as expected. Is there any approach, which can help us in avoiding multiple alert windows.
Please help me, to fix this issue.
I would write wrapper for opening alerts, and use only this wrapper, not Alert.show in the code:
public class AlertWrapper {
private static var lastAlert:Alert;
public static function showAlert(text:String, title:String):void {
if (lastAlert) {
PopUpManager.removePopUp(lastAlert);
//or
//return; //ignore last alert
}
lastAlert = Alert.show(text, title, null, 4, onAlertClose);
}
private static function onAlertClose(event:CloseEvent):void {
lastAlert = null;
}
}
Imports are missing, but I hope the idea is clear.