I am "new" in blender and I am using it to create game assets for Unity, where I'm developing something for HTC Vive.

I created a model in Blender using the image below. Now i was wondering if I can control what it displays someway (for example through code).

reference image

Is this possible in Blender, or should I create the model in blender and the logic in Unity?

If possible with blender can you tell me some link/info page about it? I have looked for it without effort..


closed as off-topic by Monster, batFINGER, aliasguru, David Aug 21 '17 at 12:31

  • This question does not appear to be about Blender within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Could you clarify what the question is? Is this a question about how to go straight from Blender to HTC Vive to explore a model, how to use blender game logic instead of the Unity logic, or how to model the particular asset? $\endgroup$ – Carlo Aug 11 '17 at 16:51
  • $\begingroup$ Edited my question.....Question is if I can someway (for example programmatically) control what the display displays in Blender. I already created the model, now I was wondering HOW to control the behaviour... $\endgroup$ – R. Gomez Aug 11 '17 at 16:57
  • 2
    $\begingroup$ Could you better describe how you intend to drive the change of the number? Time? User input? We can (maybe) traduce the logic in instruction, but you should at least describe what exactly you have in mind for your application. $\endgroup$ – Carlo Aug 11 '17 at 17:06
  • $\begingroup$ You can assign materials to different faces, I would use a script in unity to change the material used to "light up" each segment based on the number you want to display. That would lead you to the unity forums or unity answers for help. $\endgroup$ – sambler Aug 12 '17 at 8:17
  • 3
    $\begingroup$ This question belongs to Unity which is not the dealt by stackexchange (at least not at the Blender part of it). $\endgroup$ – Monster Aug 21 '17 at 4:42

I would create two materials, one for "on" segments and one for "off" segments. Then I would swap out the materials on each segment to display the correct number.

Here's a small script I made to do the job:

# Assumes segment objects are named
# SegmentA, SegmentB, ... as follows:
#   A
# B   C
#   D
# E   F
#   G

import bpy

segments = {
    "0": "ABCEFG",
    "1": "CF",
    "2": "ACDEG",
    "3": "ACDFG",
    "4": "BCDF",
    "5": "ABDFG",
    "6": "ABDEFG",
    "7": "ACF",
    "8": "ABCDEFG",
    "9": "ABCDFG"

def setdisplay (s):
    for x in list("ABCDEFG"):
        bpy.data.objects["Segment"+x].material_slots[0].material = bpy.data.materials["Off"]
    for x in list(segments[s]):
        bpy.data.objects["Segment"+x].material_slots[0].material = bpy.data.materials["On"]

setdisplay("4"); # or whatever
  • $\begingroup$ This is python in Blender? Would be possible to add logic in Unity or need to do it in blender? Just because I know a lot more c# than python. $\endgroup$ – R. Gomez Aug 12 '17 at 15:54
  • $\begingroup$ @Gomez: Yes, this is Python in Blender—it includes its own scripting engine. To use it, open a Text Editor pane, put in the script, and name the text datablock something.py. There should be a "Run Script" button in the toolbar at the bottom of the pane, or you can press Alt+P to run it. $\endgroup$ – SilverWolf Aug 12 '17 at 16:17
  • $\begingroup$ You can find documentation about Blender scripting here and here. The same system is used for addons, too—they're just Python scripts in zip files with some extra metadata. $\endgroup$ – SilverWolf Aug 12 '17 at 16:22
  • $\begingroup$ Probably the best way to discover Blender's Python API for yourself is to open a Python Console pane and type bpy.<ctrl+space>—this will autocomplete with what is available. You can then look into the results with <ctrl+space> on them. $\endgroup$ – SilverWolf Aug 12 '17 at 16:26
  • $\begingroup$ Thanks @seaturtle for the responses. I will give it a try. Just 4 info, would be possible to do the same with unity using C#? Is there any difference doing it in blender or in unity about performance or sth like that? $\endgroup$ – R. Gomez Aug 12 '17 at 19:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.