0
$\begingroup$

I wish to make a black/white UI theme in my current project , but setting object colour to all the UI lags the game a bit and takes forever for me to do it.

enter image description here enter image description here

To achieve this I had to connect every single object in the scene to one object controls the theme type, which is hard specially when an object's colour changes to some colour not white or black, also I added 4 languages to this project so there are a lot of words on the screen.

enter image description here

Then I thought what if I just multiplied the display colour by -1 (change the pixels colour value) which will invert white to black, red to blue and so on.

I'm using UPBGE 0.2.5b.

$\endgroup$
1
  • $\begingroup$ Hello and welcome. Please don't post the same question more than once. If your previous question was put on hold, address raised the issues by editing it so it can be reopened rather than post a new one, otherwise see What should I do if no one answers my question? $\endgroup$ Commented Jul 10, 2022 at 14:15

1 Answer 1

0
$\begingroup$

TL;TR

There's two ways to restrict your texture color only to black or white colors.

W/ Material Nodes

  • Use the Hue Saturation Value material node to restrict a texture or material's color to only black or white by forcing the Value setting to have a number of either be 0.0 or 1.0.

enter image description here

W/O Material Nodes

  • In the bottom of your Properties Editor - Texture Tab:
    • Enable the RGB to Intensity setting.
    • Set the RGB to Intensity Color input to solid black (R:0.0, G:0.0, B:0.0).
    • Lastly, toggle the Negative setting depending on whether you want your material / texture color to be black or white.

enter image description here

Replace Material - Script

  • If you want to replace certain UIs with one color, but different for others, here's a script that will automatically assign a material for an object depending on if that object has a certain game-property.
    • Feel free to tweak the names of the game-properties and object with the replacement materials that the script will be looking for in the active scene.
    • UI_White & UI_Black are material names, while Textured_Object is the name of the object that already has have the material names assigned to it for easy reference and material tweaking.
import bge

def main(self):

    for o in self.owner.scene.objects:
        for p in o.getPropertyNames():
            if p == "UI_White":
                o.meshes[0].replaceMaterial(0, self.owner.scene.objects["Textured_Object"].meshes[0].materials[0])
            elif p == "UI_Black":
                o.meshes[0].replaceMaterial(0, self.owner.scene.objects["Textured_Object"].meshes[0].materials[1])
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .