Stumbling Toward 'Awesomeness'

A Technical Art Blog

Thursday, April 12, 2018

Creating a Volume Slider in UE4 with Python

Working in cinematics and Sequencer, I often would like a global audio slider to lower audio levels while I am working on a sequence. I thought this might be a good simple tool example. This is completely bare bones, just a single slider in a dialog, for something more complex, you can check out scriptWrangler.

import unreal
from PySide import QtCore, QtGui, QtUiTools
 
class VolumeSlider(QtGui.QDialog):
 
    def __init__(self, parent=None):
        super(VolumeSlider, self).__init__(parent)
        self.setWindowTitle("Volume Slider")
        self.slider = QtGui.QSlider()
        self.slider.sliderMoved.connect(self.slider_fn)
        self.slider.setRange(0,100)
        self.slider.setValue(100)
 
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.slider)
        self.setLayout(layout)
 
        #load the master SoundClass
        self.master_sound_class = unreal.load_asset(None, name='/Engine/EngineSounds/Master')
 
    def slider_fn(self):
        volume_float = self.slider.value()/100.00
        #set the volume to the desired value
        self.master_sound_class.properties.set_editor_property(name='volume', value=volume_float)
 
APP = None
if not QtGui.QApplication.instance():
    APP = QtGui.QApplication(sys.argv)
 
main_window = VolumeSlider()
main_window.show()
posted by Chris at 1:05 AM  

2 Comments »

  1. Hi,
    I try to run your script, but there is a warning appear said
    “This application failed to start because it could not find or load the Qt platform plugin “window” in “”. reinstalling the application may fix this problem.”
    Have you ever encountered this problem?

    Waiting for reply
    Thanks
    An Qi

    Comment by An Qi — 2018/11/13 @ 4:28 AM

  2. Hi Chris,

    Are there any tricks to getting PySide to work in Unreal? I am able to import from PySide 64-bit in Unreal, but the editor crashes when I try to run this script.

    Comment by Johnson Thomasson — 2018/11/23 @ 7:34 PM

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress