public void ChannelSelectLight(LightFixture lightFixture)
    {
        selectedLightLabel.text = lightFixture.captureData.id.ToString();
        selectedLightChannelDropdown.gameObject.SetActive(true);
        selectedLightChannelDropdown.ClearOptions();

        selectedLightChannelDropdown.onValueChanged.RemoveAllListeners();

        int dropdownIndex = 0;
        int i             = 0;

        foreach (KeyValuePair <int, Channel> entry in gameManager.captureImport.channels)
        {
            if (entry.Key == lightFixture.captureData.channel)
            {
                dropdownIndex = i;
            }
            selectedLightChannelDropdown.options.Add(new Dropdown.OptionData()
            {
                text = string.Format("Channel {0}", entry.Key)
            });
            i++;
        }
        selectedLightChannelDropdown.value = dropdownIndex;

        int TempInt = selectedLightChannelDropdown.value;

        selectedLightChannelDropdown.value = selectedLightChannelDropdown.value + 1;
        selectedLightChannelDropdown.value = TempInt;

        selectedLightChannelDropdown.onValueChanged.AddListener(delegate { MoveSelectedLightToChannel(); });
    }
    void LightOnClick()
    {
        LightFixture lightFixture = gameManager.lightManager.lightIds[lightId].GetComponent <LightFixture>();

        gameManager.SelectLight(lightFixture);
        gameManager.lightManager.HighlightChannel(lightFixture.captureData.channel);
    }
Esempio n. 3
0
    public void IntensityChangeCheck()
    {
        lightIntensityInput.text         = lightIntensity.value.ToString();
        lightFixture.spotlight.intensity = Globals.AdjustLight(lightIntensity.value);

        colorPreview.color           = new Color(lightColorR.value / 255.0f, lightColorG.value / 255.0f, lightColorB.value / 255.0f);
        lightFixture.spotlight.color = colorPreview.color;
        lightFixture.SetEmissionColor(lightFixture.spotlight.intensity, colorPreview.color);
        lightFixture.GetComponentInChildren <VLB.BeamGeometry>().gameObject.GetComponent <Renderer>().material.SetColor("_Color", colorPreview.color);

        foreach (int id in gameManager.captureImport.channels[lightFixture.captureData.channel].lightIds)
        {
            LightFixture channelFixture = gameManager.lightManager.lightIds[id].GetComponent <LightFixture>();
            channelFixture.spotlight.intensity = Globals.AdjustLight(lightIntensity.value);
            channelFixture.SetEmissionColor(Globals.AdjustLight(lightIntensity.value), gameManager.lightManager.lightIds[id].GetComponent <LightFixture>().spotlight.color);
            if (lightFixture.spotlight.intensity > 0.05f)
            {
                if (Globals.ShowingHaze)
                {
                    VLB.VolumetricLightBeam beamComponent = gameManager.lightManager.lightIds[id].GetComponentInChildren <VLB.VolumetricLightBeam>();
                    beamComponent.enabled = true;
                    Material beamRenderer = channelFixture.GetComponentInChildren <VLB.BeamGeometry>().gameObject.GetComponent <Renderer>().material;
                    beamRenderer.SetFloat("_AlphaInside", Globals.AdjustBeamValue(Globals.LightBeamInside, lightIntensity.value));
                    beamRenderer.SetFloat("_AlphaOutside", Globals.AdjustBeamValue(Globals.LightBeamOutside, lightIntensity.value));
                }
            }
            else
            {
                gameManager.lightManager.lightIds[id].GetComponentInChildren <VLB.VolumetricLightBeam>().enabled = false;
            }
        }
    }
Esempio n. 4
0
    public void ResetLightPanel()
    {
        Deselect();

        lightFixture = null;

        lightIntensity.value     = 50;
        lightIntensityInput.text = "50";
        lightColorRInput.text    = lightColorGInput.text = lightColorBInput.text = "127";

        lightPosX.text    = lightPosY.text = lightPosZ.text = "0";
        lightColorR.value = lightColorG.value = lightColorB.value = 127;

        lightPan.value      = -180;
        lightTilt.value     = 0;
        lightPanInput.text  = "-180";
        lightTiltInput.text = "0";

        channelNumber.text = "0";

        lightGoboDropdown.value = 0;
        lightGoboIndex          = 0;      // No gobo selected

        gelColorDropdown.options.Clear();
        colorPreview.color = Color.white;
    }
    public void SelectLight(LightFixture lightFixture)
    {
        DeselectAll();
        selectedObject = lightFixture;
        lightFixture.Highlight(true);
        channelsManager.ChannelSelectLight(lightFixture);
        CreateLightPanel(lightFixture);


    }
Esempio n. 6
0
            public void Should_Set_Working_Directory()
            {
                // Given
                var fixture = new LightFixture();

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/Working", result.Process.WorkingDirectory.FullPath);
            }
    public void CreateLightPanel(LightFixture lightFixture) { 

        OpenLightMenu();

		PanelSelectedLight panelLight = lightMenuOpen.GetComponent<PanelSelectedLight>();

        panelLight.lightFixture = lightFixture;
		panelLight.gameManager = this;
		panelLight.Setup();

	}
Esempio n. 8
0
            public void Should_Find_Light_Runner_If_Tool_Path_Not_Provided()
            {
                // Given
                var fixture = new LightFixture();

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/Working/tools/light.exe", result.Path.FullPath);
            }
Esempio n. 9
0
 public void OnBeginDrag(PointerEventData eventData)
 {
     lightFixture = transform.parent.GetComponent <PanelSelectedLight>().lightFixture;
     if (float.TryParse(inputField.text, out startValue))
     {
         startValue = float.Parse(inputField.text);
     }
     else
     {
         startValue = 0;
     }
     dragStartX = Input.mousePosition.x;
 }
Esempio n. 10
0
            public void Should_Add_Extensions_To_Arguments_If_Provided()
            {
                // Given
                var fixture = new LightFixture();

                fixture.Settings.Extensions = new[] { "WixUIExtension" };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("-ext WixUIExtension \"/Working/Test.wixobj\"", result.Args);
            }
Esempio n. 11
0
            public void Should_Add_NoLogo_To_Arguments_If_Provided()
            {
                // Given
                var fixture = new LightFixture();

                fixture.Settings.NoLogo = true;

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("-nologo \"/Working/Test.wixobj\"", result.Args);
            }
Esempio n. 12
0
            public void Should_Add_RawArguments_To_Arguments_If_Provided()
            {
                // Given
                var fixture = new LightFixture();

                fixture.Settings.RawArguments = "-dFoo=Bar";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("-dFoo=Bar \"/Working/Test.wixobj\"", result.Args);
            }
Esempio n. 13
0
            public void Should_Throw_If_Settings_Is_Null()
            {
                // Given
                var fixture = new LightFixture();

                fixture.Settings = null;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                AssertEx.IsArgumentNullException(result, "settings");
            }
Esempio n. 14
0
            public void Should_Throw_If_Object_Files_Is_Null()
            {
                // Given
                var fixture = new LightFixture();

                fixture.ObjectFiles = null;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsArgumentNullException(result, "objectFiles");
            }
Esempio n. 15
0
            public void Should_Add_Output_Directory_To_Arguments_If_Provided()
            {
                // Given
                var fixture = new LightFixture();

                fixture.Settings.OutputFile = "./bin/test.msi";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("-o \"/Working/bin/test.msi\" \"/Working/Test.wixobj\"", result.Args);
            }
Esempio n. 16
0
            public void Should_Add_Defines_To_Arguments_If_Provided()
            {
                // Given
                var fixture = new LightFixture();

                fixture.Settings.Defines = new Dictionary <string, string>();
                fixture.Settings.Defines.Add("Foo", "Bar");

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("-dFoo=Bar \"/Working/Test.wixobj\"", result.Args);
            }
Esempio n. 17
0
            public void Should_Throw_If_Object_Files_Is_Empty()
            {
                // Given
                var fixture = new LightFixture();

                fixture.ObjectFiles = new List <FilePath>();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <ArgumentException>(result);
                Assert.Equal("objectFiles", ((ArgumentException)result)?.ParamName);
            }
Esempio n. 18
0
            public void Should_Throw_If_Light_Runner_Was_Not_Found()
            {
                // Given
                var fixture = new LightFixture();

                fixture.GivenDefaultToolDoNotExist();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("Light: Could not locate executable.", result?.Message);
            }
Esempio n. 19
0
            public void Should_Use_Light_Runner_From_Tool_Path_If_Provided(string toolPath, string expected)
            {
                // Given
                var fixture = new LightFixture();

                fixture.Settings.ToolPath = toolPath;
                fixture.GivenSettingsToolPathExist();

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal(expected, result.Path.FullPath);
            }
Esempio n. 20
0
            public void Should_Throw_If_Process_Was_Not_Started()
            {
                // Given
                var fixture = new LightFixture();

                fixture.GivenProcessCannotStart();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("Light: Process was not started.", result?.Message);
            }
    public void DeleteLight(LightFixture lightFixture)
    {
        if (captureImport.lightFixtures.Contains(lightFixture))
        {
            captureImport.lightFixtures.Remove(lightFixture);
        }
        captureImport.captureData.importLights.Remove(lightFixture.captureData.importLight);
        int channelId = lightFixture.captureData.channel;
        captureImport.channels[channelId].lightIds.Remove(lightFixture.captureData.id);

        int id = lightFixture.captureData.id;
        DeselectAll();
        lightManager.lightIds.Remove(id);
        Destroy(lightFixture.gameObject);        
    }
Esempio n. 22
0
            public void Should_Use_Provided_Object_Files_In_Process_Arguments()
            {
                // Given
                var fixture = new LightFixture();

                fixture.ObjectFiles = new List <FilePath>();
                fixture.ObjectFiles.Add(new FilePath("./Test.wixobj"));
                fixture.ObjectFiles.Add(new FilePath("./Test2.wixobj"));

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("\"/Working/Test.wixobj\" \"/Working/Test2.wixobj\"", result.Args);
            }
Esempio n. 23
0
            public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
            {
                // Given
                var fixture = new LightFixture();

                fixture.GivenProcessExitsWithCode(1);

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("Light: Process returned an error (exit code 1).", result?.Message);
            }
    public void MoveSelectedLightToChannel()
    {
        selectedLightChannelDropdown.onValueChanged.RemoveAllListeners();

        int dropdownIndex = selectedLightChannelDropdown.value;

        string[] label     = selectedLightChannelDropdown.options[dropdownIndex].text.Split(null);
        int      channelId = int.Parse(label[1]);

        if (gameManager.selectedObject != null)
        {
            LightFixture selectedLight = gameManager.selectedObject.GetComponent <LightFixture>();
            gameManager.captureImport.channels[selectedLight.captureData.channel].lightIds.Remove(selectedLight.captureData.id);
            selectedLight.captureData.channel = channelId;
            gameManager.lightMenuOpen.GetComponent <PanelSelectedLight>().channelNumber.text = selectedLight.captureData.channel.ToString();
            gameManager.captureImport.channels[channelId].lightIds.Add(selectedLight.captureData.id);
            //ChannelSelectLight(selectedLight);
        }
    }
Esempio n. 25
0
 public void DeleteLight(LightFixture lightFixture)
 {
     //gameManager.DeleteLight(lightFixture);
     gameManager.DeleteLight(lightFixture);
 }
Esempio n. 26
0
 void HighlightChannel(LightFixture lightFixture)
 {
     gameManager.lightManager.HighlightChannel(lightFixture.captureData.channel);
 }
Esempio n. 27
0
    public void ImportData(string filename)
    {
        string filePath          = Path.Combine(Application.streamingAssetsPath, filename);
        string captureDataImport = File.ReadAllText(filePath);

        captureData = JsonConvert.DeserializeObject <CaptureExportData>(captureDataImport);

        int i = 1;

        channels = new SortedDictionary <int, Channel>();

        // Fixing instantiation order
        if (lightManager.lightIds == null)
        {
            lightManager.lightIds = new Dictionary <int, GameObject>();
        }

        foreach (ImportLight importLight in captureData.importLights)
        {
            importLight.id = i;
            Vector3    importPos = new Vector3(-importLight.posX, importLight.posY, importLight.posZ);
            GameObject newLight  = (GameObject)Instantiate(lightPrefab, importPos, Quaternion.identity);
            newLight.name               = "Light " + i;
            newLight.transform.parent   = lightsParent.transform;
            newLight.transform.rotation = Quaternion.Euler(importLight.focusTilt, importLight.focusPan, 0f);

            Light lightComponent = newLight.GetComponentInChildren <Light>();

            CaptureData data = newLight.GetComponent <CaptureData>();
            data.id          = importLight.id;
            data.fixture     = importLight.fixture;
            data.optics      = importLight.optics;
            data.wattage     = importLight.wattage;
            data.unit        = importLight.unit;
            data.circuit     = importLight.circuit;
            data.channel     = importLight.channel;
            data.patch       = importLight.patch;
            data.dmxmode     = importLight.dmxmode;
            data.dmxchannels = importLight.dmxchannels;
            data.layer       = importLight.layer;
            data.focus       = importLight.focus;
            data.filters     = importLight.filters;
            data.gobos       = importLight.gobos;
            data.accessories = importLight.accessories;
            data.note        = importLight.note;
            data.weight      = importLight.weight;
            data.posX        = importLight.posX;
            data.posY        = importLight.posY;
            data.posZ        = importLight.posZ;
            data.focusPan    = importLight.focusPan;
            if (data.focusPan < 0)
            {
                data.focusPan += 360;                       // Keep Pan in the positive coordinate system, without needing to affect Capture export data
            }
            data.focusTilt = importLight.focusTilt;

            data.importLight = importLight;

            // Process filters, or use previously stored RGB
            if ((importLight.colorR > 0) || (importLight.colorG > 0) || (importLight.colorB > 0))       // If we have previously saved color data (overriding filter values)

            {
                data.colorR = importLight.colorR;
                data.colorG = importLight.colorG;
                data.colorB = importLight.colorB;

                lightComponent.color = new Color(importLight.colorR / 255f, importLight.colorG / 255f, importLight.colorB / 255f);
            }
            else                                                                                        // If not, process filters array, if there is one
            {
                string[] filters = data.filters.Split(',');
                //Debug.Log("Light #" + data.id + " has " + filters.Length + " filters.");
                if (filters.Length > 1)
                {
                    List <float> colorsR = new List <float>();
                    List <float> colorsG = new List <float>();
                    List <float> colorsB = new List <float>();
                    foreach (string filter in filters)
                    {
                        string trimmedFilter = filter.Trim();
                        if (gameManager.gelColorsDictionary.ContainsKey(trimmedFilter))
                        {
                            colorsR.Add(gameManager.gelColorsDictionary[trimmedFilter].colorR);
                            colorsG.Add(gameManager.gelColorsDictionary[trimmedFilter].colorG);
                            colorsB.Add(gameManager.gelColorsDictionary[trimmedFilter].colorB);
                            //Debug.Log("Result: [" + filter + "]");
                        }
                    }

                    float tempColorR = colorsR[0];
                    float tempColorG = colorsG[0];
                    float tempColorB = colorsB[0];
                    for (int j = 1; j < colorsR.Count; j++)
                    {
                        tempColorR = (tempColorR * colorsR[j]) / 255f;
                        tempColorG = (tempColorG * colorsG[j]) / 255f;
                        tempColorB = (tempColorB * colorsB[j]) / 255f;
                    }

                    //Debug.Log("Final Color Values// R:" + tempColorR + " / G:" + tempColorG + " / B:" + tempColorB);
                    data.colorR          = Mathf.Round(tempColorR);
                    data.colorG          = Mathf.Round(tempColorG);
                    data.colorB          = Mathf.Round(tempColorB);
                    lightComponent.color = new Color(tempColorR / 255f, tempColorG / 255f, tempColorB / 255f);
                }
                else
                {
                    if (filters[0] == "")
                    {
                        lightComponent.color = Color.white;
                        data.colorR          = 255;
                        data.colorG          = 255;
                        data.colorB          = 255;
                    }
                    else
                    {
                        if (gameManager.gelColorsDictionary.ContainsKey(filters[0]))
                        {
                            GelColorData gel = gameManager.gelColorsDictionary[filters[0]];
                            lightComponent.color = new Color(gel.colorR / 255f, gel.colorG / 255f, gel.colorB / 255f);
                            data.colorR          = gel.colorR;
                            data.colorG          = gel.colorG;
                            data.colorB          = gel.colorB;
                        }
                        else
                        {
                            lightComponent.color = Color.white;
                            data.colorR          = 255;
                            data.colorG          = 255;
                            data.colorB          = 255;
                        }
                    }
                }

                // Process gobos
                if (data.gobos != null)
                {
                    string[] gobos = data.gobos.Split(',');
                    //Debug.Log("Light #" + data.id + " has " + gobos.Length + " gobos.");
                    if (gobos.Length > 1)
                    {
                        data.gobos = gobos[0];  // Cannot stack Cookies in Unity, so use only the first
                        // If we do need to combine these, a texture combination script exists in TextureTest, although these will likely not be processed as cookies properly
                    }

                    lightComponent.cookie = Resources.Load("Gobos/" + data.gobos) as Texture;
                }
            }

            lightManager.AddToLights(data.id, newLight);

            //LightCues lightCues = newLight.GetComponent<LightCues>();
            //lightsWithCues.Add(lightCues);

            // Replacing LightsWithCues with this, as the old cues paradigm is getting replaced
            LightFixture lightFixture = newLight.GetComponent <LightFixture>();
            lightFixture.SetColor();
            lightFixtures.Add(lightFixture);

            AddToChannel(importLight.channel, importLight.id);

            // TODO: Rethink the light component's range element -- for now, adjust range at load time, and readjust when moving it (see PanelLightSelected)
            // Set range to distance from origin, which seems like a reasonable universal value
            lightFixture.spotlight.range = Vector3.Distance(lightFixture.transform.position, new Vector3(13f, 0, 13f));  // Adjust for center stage
            if (lightFixture.spotlight.range < 40f)
            {
                lightFixture.spotlight.range = 40f;
            }

            i++;
        }

        foreach (KeyValuePair <int, Channel> entry in channels)
        {
            GameObject newButton = (GameObject)Instantiate(uiButtonChannel, uiChannelsList);
            newButton.name = "Channel " + entry.Key.ToString();
            newButton.GetComponent <UIButtonChannel>().label.text = "Channel " + entry.Key.ToString();
            newButton.GetComponent <UIButtonChannel>().channelId  = entry.Key;
        }
    }
    // TODO: Deprecated function
    //public void CaptureImport()
    //{
    //    // Sequence: Called from GelColorImport class, when the gels are processed
    //    // (This is because we need the gel colors before we can assign color values to the imported lights
    //    captureImport.ImportData();
    //    cuesManager.ImportCues();
    //}
    
    void Update () {

        //if (Input.GetKeyDown(KeyCode.P))
        //{
        //    cuesManager.ImportCues();
        //}
        //if (Input.GetKeyDown(KeyCode.O))
        //{
        //    cuesManager.UnsetAllCues();
        //}
        
        if (Input.GetKeyDown(KeyCode.Equals))
        {
            cuesManager.cuesImport.SerializeCuesData(cuesManager.cuesImport.defaultCuesExportData);
        }

        if (Input.GetKeyDown(KeyCode.H))
        {
            if (lightManager.increasedVisibility)
            {
                foreach (KeyValuePair<int, GameObject> entry in lightManager.lightIds)
                {
                    entry.Value.GetComponent<LightFixture>().IncreaseVisibility(false);
                }
                lightManager.increasedVisibility = false;
            } else {
                foreach (KeyValuePair<int, GameObject> entry in lightManager.lightIds)
                {
                    entry.Value.GetComponent<LightFixture>().IncreaseVisibility(true);
                }
                lightManager.increasedVisibility = true;
            }
        }
        
        if (Input.GetButtonDown("Fire1")) { // More flexible than explicitly getting MouseButton 0, for VR, etc.

            if (!EventSystem.current.IsPointerOverGameObject()) { 
                RaycastHit hit;
			    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                
                if (Physics.Raycast(ray, out hit, 200f, layerMask))
                {

                    //Debug.Log("Clicked: " + hit.transform.parent.parent.parent.parent.name);
                    if (hit.transform.tag == "Light")
                    {
                        if (hit.transform.GetComponent<LightFixture>() != null)
                        {
                            LightFixture lightFixture = hit.transform.GetComponent<LightFixture>();
                            SelectLight(lightFixture);
                        }
                    }
                } else {
                    DeselectAll();
                }
			} else {

				if (EventSystem.current.IsPointerOverGameObject()) {

				} else {
                    
                    DeselectAll();

                }
			}
		}			
	}