Jump to content

ui creation problem


Recommended Posts

I'm trying to go through the unity ui creation tutorial. And after some problems, I could install the asset compiler. But I've some questions:

1) after creating a new panel with all those elements on it, I had the possibility to select or create the asset bundle into which I want to add this panel (directly in the little window that shows the raw sprite used for the panel in the right lower corner of the editor) ... but, that's gone now. I cannot change it or set it for other elements. Why? ... I guess it's called "Asset Labels" ...

2) ... (and that's probably the main question): The tutorial says, that after compiling I will get a ".ksp" file (at least that's how I understand it) ... but, I don't have a .ksp file. Only xml files. And when I try to load it, I get some sort of "format error" ...

3) the function "Awake" (private) is called on my KSPAddon object... why?

Rudolf

 

Link to comment
Share on other sites

*hmm* ... ok, I have to drag my "thing" (in my case I dragged the "panel") from the "Hierarchy" into the "Assets"-Part of the "Project"-window... and then I selected it could set the bundle name... but, it did not export. Because of an error ("unity cannot mark assets and scenes in one assetbundle") ... then I clicked around... "remove unused names" things like that, removed the "scene" from my "Assets" ... but I don't know what exactly solved the problem... and suddedly the compilation was successful... no idea why.

... I don't get it. Even after watching 10 tutorials on the web I don't understand it. And every version of unity seems to be completely different. Most of the times I don't find the buttons and menus they're showing. :-)

Link to comment
Share on other sites

The KSPedia tutorial goes over some of this stuff more explicitly. For selecting the prefabs that you actually want to export you just drag the object from the hierarchy into a folder in your projects tab.

08ZD6eA.png

Here the "Template.Panel" object has been dragged into the KSPedia Tutorial folder, it's basically just an image. You do the same for each prefab in your project. But you don't drag the Canvas object down (KSP has its own Canvases), and you don't drag anything else down, like the EventSystem, or anything within a prefab.

You don't have to wait until you're finished with the project to do this. You can drag the prefab down into the folder at any time. When you want to make changes, you select the object from the "Hierarchy" tab, make whatever changes, then, from the "Inspector" tab on the right, click the "Apply" button, this will update the prefab (which is a separate file saved on disk). This button (and the "Select" and "Revert" buttons are only available if you have already dragged the object into the assets folder.

 

To make an asset bundle for export you have to select all of the prefabs you want and assign them to an asset bundle or create a new one from the little button in the very bottom right:

O49yk98.png

Be sure to only select what you want to export, not things like the Unity Scene file (you can also export asset bundles with other things like sprites, or audio files, but that's another story).

 

For question 3, about the Awake method, any class that you start using KSPAddon has to be a Unity MonoBehaviour, which has several methods that are called by name (Awake, Start, Update, etc...).

Link to comment
Share on other sites

thanks for the explanations...

ok... that's working now... (or, it's showing a window that does nothing, but that was the goal) ... my question about the Awake method was more of the kind "it's private and... not new, override or somehting, nobody can see it, so how can it get called?" ... but, seems that there is some kind of 'magic' going on (function pointers inside il code or maybe cpp code, whatever...)

... now, I'll try to create a more useful window :-)

 

Link to comment
Share on other sites

1 hour ago, Rudolf Meier said:

there is some kind of 'magic' going on

You ll have read up a bit on Unity's MonoBehaviour. The short version is that everything in the "Message" section of that doc page can be called by 'magic' (as you say) by the Unity engine.

https://docs.unity3d.com/ScriptReference/MonoBehaviour.html

Edited by sarbian
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...