DMagic
-
Posts
4,180 -
Joined
-
Last visited
Single Status Update
-
Really sorry but i need help on implementing a UI button (and slider but in the same prefab).
My issue is that I have some terrible problems trying to understand this...
I managed to make an Asset Boundle (not sure if correctly).
but it shows in game. (even if does not behave fully ok).
my problem with following your tutorial is, on the way you hook up Unity with the ksp part.
specially this call: window.SetInitState(...)
because it gives a script error for me (and it makes sense).
I cannot define that correctly because inside that function you are referencing things of the Unity directly.
now as I noticed that, I add that to the basic unity, but then, I do not undesrtand how to reference :
the part i do not understand where it goes is...
So now we can set the UI’s initial state by implementing our interface on an object in the KSP Assembly and calling the Setup method.
private IExample exampleInterface; public void setInitialState(IExample example) { if (example == null) return; exampleInterface = example; if (m_VersionText != null) m_VersionText.text = example.Version; if (m_OrbitToggle != null) m_OrbitToggle.isOn = example.ShowOrbit; if (m_AlphaSlider != null) m_AlphaSlider.value = example.Alpha; if (m_AlphaText != null) m_AlphaText.text = example.Alpha.ToString("P0"); loaded = true; } public void OrbitPanelToggle(bool isOn) { if (!loaded) return; if (m_OrbitToggle == null) return; if (exampleInterface != null) exampleInterface.ShowOrbit = isOn; //Turn on Orbit Panel } public void mySliderAlpha(float alpha) { if (!loaded) return; if (exampleInterface != null) exampleInterface.Alpha = alpha; if (m_AlphaText != null) m_AlphaText.text = alpha.ToString("P0"); //Set panel background transparency }
- Note that we store a reference to the interface for use by the listener methods
- Make sure to set the Loaded Flag to true if needed
- The code for actually turning on the separate panel, or changing the background image’s alpha channel can all be handled within the Unity Assembly
sorry but, this is truly important for me to finish today, or at worst tomorrow.
if this goes in the Unity.Unity, then i do not understand how can be hooked to the ksp part.
If this goes as it is in the ksp part, then does not compiles.
because m_alphaText for example is not defined.
and if it goes in the interface, then its also NOT defined there (same problem of ksp).
May be for you is obvious what the problem is but, this is my first time with UI and its like 10 times harder than I expected. (in fact even if it took time doing all the rest was easier and was not truly easy)
Please answer me