edited January 2020 in ORK Support
I'm planning on having the same GUI Boxes (ex: bottom dialogue) appear in multiple scenes (as a normal game). However, in some scenes, I'd like to dynamically override the GUI Skin->Base Skin.

For example, if it's winter, I'll use the same default/base Bottom Dialogue GUI Box, but change the GUI Skin to use the 'winter' colors. In summer, then I'll use the 'summer' skin, etc. I'm trying to avoid having multiple GUI Boxes that are essentially the same thing (with a different skin), because when I need to tweak 1 thing, I have to make that same change in every clone - which is just a hassle but not too big of a pain.

Here's what I have so far, but I'm having a hard time understanding the API for the AssetSource class.

public GUISkin BottomDialogueGUISkin;

void Start()
{

GUIBoxesSettings guiBoxes = ORKFramework.ORK.GUIBoxes;

for(int i=0;i < guiBoxes.Count;i++)
{
string name = guiBoxes.GetName(i);
if(string.Equals( name , "Bottom Dialogue"))
{
Debug.Log("found it " + name); // works
// GUIBoxSetting settings = guiBoxes.Get(i); // returns null?
// settings.ownSkins = true;
// AssetSource ownSkin = new AssetSource<GUISkin>();
// how to load this.BottomDialogueGUISkin into 'ownSkin' var?
// settings.skins.skin = ownSkin;
}
}
}
thanks
Post edited by Shurijo on
  • Since you should know the ID/index of the GUI box, there's no need to go through all of them:
    GUIBoxSetting box = ORK.GUIBoxes.Get(id);
    if(box != null)
    {
    box.ownSkins = true;
    box.skins = new GUIBoxSkins();
    box.skins.skin.settings.EditorAsset = yourSkin;
    }


    Needs
    using ORKFramework;
    using ORKFramework.UI;
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • This isn't working for me. I still see my default skin. Do I need to call an update or something for the new skin to be applied?


    [SerializeField]
    public GUISkin BottomDialogueGUISkin;

    public class SceneOverrides : MonoBehaviour
    {
    void Start()
    {
    GUIBoxSetting box1 = ORK.GUIBoxes.Get(1);
    if (box1 != null)
    {
    box1.ownSkins = true;
    box1.skins = new GUIBoxSkins();
    box1.skins.skin.settings.EditorAsset = BottomDialogueGUISkin;
    }
    }
    }


    Thanks
  • You're using the legacy GUI system, right? Because GUISkins are only used there :)

    The change would also only affect GUI boxes that are opened after it was made, i.e. if the GUI box is already opened, it (probably) wouldn't affect it.

    Also, the GUIBoxSkins class has other GUISkin settings for other parts as well, e.g. the selectSkin for the selected choice button.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Yes. Legacy UI.

    I'm only using the BaseSkin of the GUIBoxes, so that's the only one I need to override. None of the boxes that appear after the scene loads use the new skin.

  • Hm, I'll give it a try - I've never actually done it, as the system wasn't meant to be used that way :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Could it be done using the new UI? If so, maybe I'll just move to there after I get through the rest of the tutorial.
  • Here, this is working - I've improved your stuff a bit with additional options:
    using ORKFramework;
    using ORKFramework.UI;
    using UnityEngine;

    public class SceneOverrides : MonoBehaviour
    {
    public bool reset = false;

    public int boxID = 0;

    public GUISkin guiSkin;

    void Start()
    {
    GUIBoxSetting box = ORK.GUIBoxes.Get(this.boxID);
    if(box != null)
    {
    if(this.reset)
    {
    box.ownSkins = false;
    box.skins = null;
    }
    else
    {
    box.ownSkins = true;
    box.skins = new GUIBoxSkins();
    box.skins.skin.settings.EditorAsset = this.guiSkin;
    }
    }
    }
    }


    Enabling Reset will reset the GUI box to now override skins.
    The Box ID sets the ID/index of the GUI box that will be used.
    The Gui Skin is the GUI skin that will be used (when not resetting).

    Tested it and it works.
    Have it set the skin in the scenes you want and use the Reset option in connected scenes where this should be reset :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thanks.

    My code is near verbatim of your code (which core is same as your initial post), but it didn't work. Then I realized something... I had dragged the wrong GUISkin into my component. My skins have the same name, but in different folders and I accidentally set the override skin to the default skin. Once I set the correct skin in the component, then everything worked just like your original post.

    Once I get farther into the tutorial (just starting battles now), I might switch to use the new UI system (if there's a tutorial on that) so I can future proof my prototype, in case ORK 3.0 is released before I get too far deep into it.

  • It'll work the same when using the new UI, just that you'd set the different prefab settings (e.g. contentBoxPrefab) instead of the skins (and use GameObject assets instead of GUISkin).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.