Slate, UMG, Editor UMG¶
Slate widgets in the editor interface are prefixed with the letter "S" in the engine code, where "S" stands for Slate. Slate is designed for the engine itself, not for GamePlay (the UI system used by GamePlay is UMG, with widgets prefixed with "U").
By using ChameleonData, we can modify most of the common properties of widgets on the interface.
In the MiminalExample, we get and save the ChameleonData instance of the current tool in the constructor of the Python tool class, and save it to self.data:
class MinimalExample(metaclass=Singleton): def __init__(self, jsonPath:str): self.jsonPath = jsonPath self.data = unreal.PythonBPLib.get_chameleon_data(self.jsonPath)
Similarly, we can use JsonPath to get the ChameleonData instance that has been created in any Python code:
Or the full path of JsonPath:
Likewise, we can use JsonPath to get the ChameleonData of any created Chameleon tool.
We can use
unreal.PythonBPLib.get_all_chameleon_data_paths() to get the JsonPath of all created ChamaleonTools in the current editor. Then,
use unreal.PythonBPLib.get_chameleon_data to get the ChameleonData instance:
get_all_chameleon_data_paths(...) method of builtins.type instance X.get_all_chameleon_data_paths() -> Array[str] Get the chameleonData by JSON file path Returns: Array[str]: All path of current Chameleon Tools's JSON file paths.
3. Through tool instance¶
As mentioned before, the variable names in the "InitPyCmd" of the JSON interface file are in the global space. Therefore, we can use these tool variable names to get their ChameleonData instances and modify their interfaces.
In our tool or Python Console, we can use:
chameleon_gallery.data.set_text(aka_name="IsPythonReadyText", text="Some Changed text")
to modify the text in the Gallery interface.
- Although we can do this, it is not recommended, as it will make the interaction between tools confusing. It is recommended to use interface functions or Signals for tool-to-tool communication.
- More commonly, after obtaining the ChamelonData instance in the PythonConsole, we can use commands to perform some debugging tasks, such as testing whether the results of getting and setting are as expected, etc.