public override void OutlineActive(ScriptObjMaterial scriptObj, int isActive) { MatProp = new MaterialPropertyBlock(); render = GetComponentInChildren <MeshRenderer>(); render.GetPropertyBlock(MatProp); scriptObjSave = scriptObj; if (isActive == 1) { MatProp.SetFloat("_Outline", 0.1f); MatProp.SetColor("_ColorOutline", Color.white); } else if (isActive == 2) { MatProp.SetFloat("_Outline", 0.1f); MatProp.SetColor("_ColorOutline", Color.red); } else { MatProp.SetFloat("_Outline", 0); } render.SetPropertyBlock(MatProp); }
// Start is called before the first frame update private void Awake() { if (_instance != null && _instance != this) { Destroy(gameObject); } else { _instance = this; } //selectedTexture = floorTexture; selectedTextureList = floorPlainTextures; selectedTexture = floorPlainTextures[selectedTextureInt]; }
private void UpdateCubeTexture() { cubeData.internalCubeTexture = cubeTexture; //set the texture to save as the user-input cubeTexture cubeData.myCubeTextureString = cubeTexture.name; //set the texture to save's name as the user-input cubeTexture's name cubeTexture = Resources.Load(cubeData.myCubeTextureString) as ScriptObjMaterial; if (staticCube != null) { staticCube.ChangeMaterialPreset(cubeTexture); } if (movableCube != null) { movableCube.ChangeMaterialPreset(cubeTexture); } if (victoryCube != null) { victoryCube.ChangeMaterialPreset(cubeTexture); } if (characterScript != null) { characterScript.ChangeMaterialPreset(cubeTexture); } if (deliveryCube != null) { deliveryCube.ChangeMaterialPreset(cubeTexture); } if (timerCube != null) { timerCube.ChangeMaterialPreset(cubeTexture); } if (stickyCube != null) { stickyCube.ChangeMaterialPreset(cubeTexture); } if (switchCube != null) { switchCube.ChangeMaterialPreset(cubeTexture); } if (mirrorCube != null) { mirrorCube.ChangeMaterialPreset(cubeTexture); } cubeTextureRef = cubeTexture; //prevent function from looping back around }
public virtual void OutlineActive(ScriptObjMaterial scriptObj, int isActive) { MatProp = new MaterialPropertyBlock(); render = GetComponentInChildren <MeshRenderer>(); render.GetPropertyBlock(MatProp); scriptObjSave = scriptObj; if (isActive == 1) { MatProp.SetFloat("_Outline", 0.1f); } else if (isActive == 2) { MatProp.SetFloat("_Outline", 0); } render.SetPropertyBlock(MatProp); }
// USE THIS FUNCTION TO CHANGE SHADER IN REAL TIME public void DynamicChangeMaterialPreset(ScriptObjMaterial scriptObj) { MatProp = new MaterialPropertyBlock(); render = GetComponentInChildren <MeshRenderer>(); render.GetPropertyBlock(MatProp); scriptObjSave = scriptObj; meshFilter.mesh = mesh; // Change mesh MatProp.SetTexture("_MainTex", _MainTex); MatProp.SetTexture("_TexTwo", _TexTwo); MatProp.SetTexture("_Tex", _Tex); MatProp.SetTexture("_Pastille", _Pastille); MatProp.SetColor("_MainColor", _MainColor); MatProp.SetColor("_ColorTwo", _ColorTwo); MatProp.SetColor("_ColorTex", _ColorTex); MatProp.SetFloat("_TexStrength", _TexStrength); MatProp.SetFloat("_TexTwoStrength", _TexTwoStrength); MatProp.SetFloat("_PastilleStrength", _PastilleStrength); MatProp.SetColor("_GradientCenter", _GradientCenter); MatProp.SetColor("_GradientExterior", _GradientExterior); MatProp.SetFloat("_OffsetPastilleX", _OffsetPastilleX); MatProp.SetFloat("_OffsetPastilleY", _OffsetPastilleY); MatProp.SetFloat("_Hue", _Hue); MatProp.SetFloat("_Contrast", _Contrast); MatProp.SetFloat("_Saturation", _Saturation); MatProp.SetFloat("_Brightness", _Brightness); render.SetPropertyBlock(MatProp); }
// CALL THIS TO CHANGE MATERIAL public void ChangeMaterialPreset(ScriptObjMaterial scriptObj) { MatProp = new MaterialPropertyBlock(); render = GetComponentInChildren <MeshRenderer>(); meshFilter = GetComponentInChildren <MeshFilter>(); render.GetPropertyBlock(MatProp); scriptObjSave = scriptObj; mesh = scriptObj.mesh; _MainTex = scriptObj._MainTex; _TexTwo = scriptObj._TexTwo; _Tex = scriptObj._Tex; _Pastille = scriptObj._Pastille; _MainColor = scriptObj._MainColor; _ColorTwo = scriptObj._ColorTwo; _ColorTex = scriptObj._ColorTex; _TexStrength = scriptObj._TexStrength; _TexTwoStrength = scriptObj._TexTwoStrength; _GradientCenter = scriptObj._GradientCenter; _GradientExterior = scriptObj._GradientExterior; _Hue = scriptObj._Hue; _Contrast = scriptObj._Contrast; _Saturation = scriptObj._Saturation; _Brightness = scriptObj._Brightness; // SAVE ALL DATA THEN APPLY IT meshFilter.mesh = mesh; // Change mesh MatProp.SetTexture("_MainTex", _MainTex); MatProp.SetTexture("_TexTwo", _TexTwo); MatProp.SetTexture("_Tex", _Tex); MatProp.SetTexture("_Pastille", _Pastille); MatProp.SetColor("_MainColor", _MainColor); MatProp.SetColor("_ColorTwo", _ColorTwo); MatProp.SetColor("_ColorTex", _ColorTex); MatProp.SetFloat("_TexStrength", _TexStrength); MatProp.SetFloat("_TexTwoStrength", _TexTwoStrength); MatProp.SetFloat("_PastilleStrength", _PastilleStrength); MatProp.SetColor("_GradientCenter", _GradientCenter); MatProp.SetColor("_GradientExterior", _GradientExterior); MatProp.SetFloat("_OffsetPastilleX", _OffsetPastilleX); MatProp.SetFloat("_OffsetPastilleY", _OffsetPastilleY); MatProp.SetFloat("_Hue", _Hue); MatProp.SetFloat("_Contrast", _Contrast); MatProp.SetFloat("_Saturation", _Saturation); MatProp.SetFloat("_Brightness", _Brightness); render.SetPropertyBlock(MatProp); }
//CALLED WHEN PLACING CUBES void CubeTypeMessage(_LevelEditor.EditorCubeType cubeType) { switch (cubeType) { case _LevelEditor.EditorCubeType.Static: cubeData.cubeType = CubeType.Static; staticCube = gameObject.AddComponent(typeof(_StaticCube)) as _StaticCube; staticCube = gameObject.GetComponent <_StaticCube>(); staticCube.ChangeMaterialPreset(cubeTexture); //Cube texture value is set by the LevelEditor script break; case _LevelEditor.EditorCubeType.Moveable: cubeData.cubeType = CubeType.Moveable; movableCube = gameObject.AddComponent(typeof(_MovableCube)) as _MovableCube; movableCube = gameObject.GetComponent <_MovableCube>(); movableCube.ChangeMaterialPreset(cubeTexture); //Cube texture value is set by the LevelEditor script break; case _LevelEditor.EditorCubeType.Victory: cubeData.cubeType = CubeType.Victory; victoryCube = gameObject.AddComponent(typeof(_VictoryCube)) as _VictoryCube; victoryCube = gameObject.GetComponent <_VictoryCube>(); victoryCube.ChangeMaterialPreset(cubeTexture); //Cube texture value is set by the LevelEditor script break; case _LevelEditor.EditorCubeType.Spawn: cubeData.cubeType = CubeType.SpawnPoint; characterScript = gameObject.AddComponent(typeof(_Character)) as _Character; characterScript = gameObject.GetComponent <_Character>(); staticCube.ChangeMaterialPreset(cubeTexture); //Cube texture value is set by the LevelEditor script break; case _LevelEditor.EditorCubeType.Delivery: cubeData.cubeType = CubeType.Delivery; deliveryCube = gameObject.AddComponent(typeof(_DeliveryCube)) as _DeliveryCube; deliveryCube = gameObject.GetComponent <_DeliveryCube>(); deliveryCube.ChangeMaterialPreset(cubeTexture); //Cube texture value is set by the LevelEditor script break; case _LevelEditor.EditorCubeType.Timer: cubeData.cubeType = CubeType.Timer; timerCube = gameObject.AddComponent(typeof(_TimerCube)) as _TimerCube; timerCube = gameObject.GetComponent <_TimerCube>(); timerCube.ChangeMaterialPreset(cubeTexture); //Cube texture value is set by the LevelEditor script break; case _LevelEditor.EditorCubeType.Sticky: cubeData.cubeType = CubeType.Sticky; stickyCube = gameObject.AddComponent(typeof(_StickyCube)) as _StickyCube; stickyCube = gameObject.GetComponent <_StickyCube>(); stickyCube.ChangeMaterialPreset(cubeTexture); //Cube texture value is set by the LevelEditor script break; case _LevelEditor.EditorCubeType.Switch: cubeData.cubeType = CubeType.Switch; switchCube = gameObject.AddComponent(typeof(_SwitchCube)) as _SwitchCube; switchCube = gameObject.GetComponent <_SwitchCube>(); switchCube.ChangeMaterialPreset(cubeTexture); //Cube texture value is set by the LevelEditor script break; case _LevelEditor.EditorCubeType.Mirror: cubeData.cubeType = CubeType.Mirror; mirrorCube = gameObject.AddComponent(typeof(_MirrorCube)) as _MirrorCube; mirrorCube = gameObject.GetComponent <_MirrorCube>(); mirrorCube.ChangeMaterialPreset(cubeTexture); //Cube texture value is set by the LevelEditor script break; case _LevelEditor.EditorCubeType.Elevator: cubeData.cubeType = CubeType.Elevator; elevatorCube = gameObject.AddComponent(typeof(_ElevatorCube)) as _ElevatorCube; elevatorCube = gameObject.GetComponent <_ElevatorCube>(); elevatorCube.ChangeMaterialPreset(cubeTexture); break; case _LevelEditor.EditorCubeType.Unmoveable: cubeData.cubeType = CubeType.Unmoveable; unmoveableCube = gameObject.AddComponent(typeof(_UnmoveableCube)) as _UnmoveableCube; unmoveableCube = gameObject.GetComponent <_UnmoveableCube>(); unmoveableCube.ChangeMaterialPreset(cubeTexture); break; } //save the cubeTexture values (file and name) cubeData.internalCubeTexture = cubeTexture; cubeData.myCubeTextureString = cubeTexture.name; cubeTextureRef = cubeTexture; }
//CALLED ON LOAD, after data has been reassigned, "reconfigures" the cube void ConfigureCube() { cubeTexture = Resources.Load(cubeData.myCubeTextureString) as ScriptObjMaterial; switch (cubeData.cubeType) { case CubeType.Static: staticCube = gameObject.AddComponent(typeof(_StaticCube)) as _StaticCube; staticCube = gameObject.GetComponent <_StaticCube>(); staticCube.ChangeMaterialPreset(cubeTexture); break; case CubeType.Moveable: movableCube = gameObject.AddComponent(typeof(_MovableCube)) as _MovableCube; movableCube = gameObject.GetComponent <_MovableCube>(); movableCube.ChangeMaterialPreset(cubeTexture); break; case CubeType.Victory: victoryCube = gameObject.AddComponent(typeof(_VictoryCube)) as _VictoryCube; victoryCube = gameObject.GetComponent <_VictoryCube>(); victoryCube.ChangeMaterialPreset(cubeTexture); cubeData.isVictory = true; victoryCube.isUnmoveable = cubeData.isUnmoveableCube; break; case CubeType.SpawnPoint: characterScript = gameObject.AddComponent(typeof(_Character)) as _Character; characterScript = gameObject.GetComponent <_Character>(); characterScript.ChangeMaterialPreset(cubeTexture); break; case CubeType.Delivery: deliveryCube = gameObject.AddComponent(typeof(_DeliveryCube)) as _DeliveryCube; deliveryCube = gameObject.GetComponent <_DeliveryCube>(); deliveryCube.ChangeMaterialPreset(cubeTexture); deliveryCube.isMovable = cubeData.isMovable; deliveryCube.forward = cubeData.forward; deliveryCube.right = cubeData.right; deliveryCube.left = cubeData.left; deliveryCube.back = cubeData.back; deliveryCube.up = cubeData.up; deliveryCube.down = cubeData.down; break; case CubeType.Timer: timerCube = gameObject.AddComponent(typeof(_TimerCube)) as _TimerCube; timerCube = gameObject.GetComponent <_TimerCube>(); timerCube.ChangeMaterialPreset(cubeTexture); timerCube.numberOfTimesMoved = cubeData.numberOfTimesToMove; timerCube.numberOfTimesMoved = cubeData.numberOfTimesMoved; timerCube.isMovable = cubeData.isMovable; timerCube.forward = cubeData.forward; timerCube.right = cubeData.right; timerCube.left = cubeData.left; timerCube.back = cubeData.back; timerCube.up = cubeData.up; timerCube.down = cubeData.down; break; case CubeType.Sticky: stickyCube = gameObject.AddComponent(typeof(_StickyCube)) as _StickyCube; stickyCube = gameObject.GetComponent <_StickyCube>(); stickyCube.ChangeMaterialPreset(cubeTexture); //Cube texture value is set by the LevelEditor script stickyCube.forward = cubeData.forward; stickyCube.right = cubeData.right; stickyCube.left = cubeData.left; stickyCube.back = cubeData.back; stickyCube.up = cubeData.up; stickyCube.down = cubeData.down; break; case CubeType.Switch: switchCube = gameObject.AddComponent(typeof(_SwitchCube)) as _SwitchCube; switchCube = gameObject.GetComponent <_SwitchCube>(); switchCube.ChangeMaterialPreset(cubeTexture); //Cbe texture value is set by the LevelEditor script switchCube.forward = cubeData.forward; switchCube.right = cubeData.right; switchCube.left = cubeData.left; switchCube.back = cubeData.back; switchCube.up = cubeData.up; switchCube.down = cubeData.down; break; case CubeType.Mirror: mirrorCube = gameObject.AddComponent(typeof(_MirrorCube)) as _MirrorCube; mirrorCube = gameObject.GetComponent <_MirrorCube>(); mirrorCube.ChangeMaterialPreset(cubeTexture); //Cube texture value is set by the LevelEditor script /*mirrorCube.linkedPositionX = cubeData.savedLinkedPosX; * mirrorCube.linkedPositionY = cubeData.savedLinkedPosY; * mirrorCube.linkedPositionZ = cubeData.savedLinkedPosZ;*/ break; case CubeType.Elevator: elevatorCube = gameObject.AddComponent(typeof(_ElevatorCube)) as _ElevatorCube; elevatorCube = gameObject.GetComponent <_ElevatorCube>(); elevatorCube.ChangeMaterialPreset(cubeTexture); elevatorCube.moveInScanDirection = cubeData.isGreen; elevatorCube.forward = cubeData.forward; elevatorCube.right = cubeData.right; elevatorCube.left = cubeData.left; elevatorCube.back = cubeData.back; elevatorCube.up = cubeData.up; elevatorCube.down = cubeData.down; break; case CubeType.Unmoveable: unmoveableCube = gameObject.AddComponent(typeof(_UnmoveableCube)) as _UnmoveableCube; unmoveableCube = gameObject.GetComponent <_UnmoveableCube>(); unmoveableCube.ChangeMaterialPreset(cubeTexture); break; default: break; } cubeData.internalCubeTexture = cubeTexture; cubeTextureRef = cubeTexture; }
private void SelectCubeTexture() { switch (biomeTypeDropdown.captionText.text) { case "Plains": switch (_LevelEditor.instance.cubeType) { case _LevelEditor.EditorCubeType.Static: //selectedTexture = floorTexture; selectedTextureList = floorPlainTextures; selectedTexture = selectedTextureList[selectedTextureInt]; break; case _LevelEditor.EditorCubeType.Moveable: Debug.Log("I'm moveable"); selectedTexture = moveableTexture; break; case _LevelEditor.EditorCubeType.Elevator: selectedTexture = elevatorTexture; break; case _LevelEditor.EditorCubeType.Unmoveable: selectedTexture = unmoveableTexture; break; case _LevelEditor.EditorCubeType.Victory: selectedTexture = victoryTexture; break; case _LevelEditor.EditorCubeType.Delivery: selectedTexture = deliveryTexture; break; case _LevelEditor.EditorCubeType.Sticky: selectedTexture = stickyTexture; break; case _LevelEditor.EditorCubeType.Timer: selectedTexture = timerTexture; break; case _LevelEditor.EditorCubeType.Switch: selectedTexture = switchTexture; break; case _LevelEditor.EditorCubeType.Mirror: selectedTexture = mirrorTexture; break; case _LevelEditor.EditorCubeType.ChaosBall: selectedTexture = chaosBallTexture; break; default: break; } break; case "Mountains": switch (_LevelEditor.instance.cubeType) { case _LevelEditor.EditorCubeType.Static: //selectedTexture = floorTexture; selectedTextureList = floorMountainTextures; selectedTexture = selectedTextureList[selectedTextureInt]; break; case _LevelEditor.EditorCubeType.Moveable: selectedTexture = moveableTexture; break; case _LevelEditor.EditorCubeType.Elevator: selectedTexture = elevatorTexture; break; case _LevelEditor.EditorCubeType.Unmoveable: selectedTexture = unmoveableTexture; break; case _LevelEditor.EditorCubeType.Victory: selectedTexture = victoryTexture; break; case _LevelEditor.EditorCubeType.Delivery: selectedTexture = deliveryTexture; break; case _LevelEditor.EditorCubeType.Sticky: selectedTexture = stickyTexture; break; case _LevelEditor.EditorCubeType.Timer: selectedTexture = timerTexture; break; case _LevelEditor.EditorCubeType.Switch: selectedTexture = switchTexture; break; case _LevelEditor.EditorCubeType.Mirror: selectedTexture = mirrorTexture; break; case _LevelEditor.EditorCubeType.ChaosBall: selectedTexture = chaosBallTexture; break; default: break; } break; case "Underwater": switch (_LevelEditor.instance.cubeType) { case _LevelEditor.EditorCubeType.Static: //selectedTexture = floorTexture; selectedTextureList = floorUnderwaterTextures; selectedTexture = selectedTextureList[selectedTextureInt]; break; case _LevelEditor.EditorCubeType.Moveable: selectedTexture = moveableTexture; break; case _LevelEditor.EditorCubeType.Elevator: selectedTexture = elevatorTexture; break; case _LevelEditor.EditorCubeType.Unmoveable: selectedTexture = unmoveableTexture; break; case _LevelEditor.EditorCubeType.Victory: selectedTexture = victoryTexture; break; case _LevelEditor.EditorCubeType.Delivery: selectedTexture = deliveryTexture; break; case _LevelEditor.EditorCubeType.Sticky: selectedTexture = stickyTexture; break; case _LevelEditor.EditorCubeType.Timer: selectedTexture = timerTexture; break; case _LevelEditor.EditorCubeType.Switch: selectedTexture = switchTexture; break; case _LevelEditor.EditorCubeType.Mirror: selectedTexture = mirrorTexture; break; case _LevelEditor.EditorCubeType.ChaosBall: selectedTexture = chaosBallTexture; break; default: break; } break; case "Ruins": switch (_LevelEditor.instance.cubeType) { case _LevelEditor.EditorCubeType.Static: //selectedTexture = floorTexture; selectedTextureList = floorRuinTextures; selectedTexture = selectedTextureList[selectedTextureInt]; break; case _LevelEditor.EditorCubeType.Elevator: selectedTexture = elevatorTexture; break; case _LevelEditor.EditorCubeType.Unmoveable: selectedTexture = unmoveableTexture; break; case _LevelEditor.EditorCubeType.Moveable: selectedTexture = moveableTexture; break; case _LevelEditor.EditorCubeType.Victory: selectedTexture = victoryTexture; break; case _LevelEditor.EditorCubeType.Delivery: selectedTexture = deliveryTexture; break; case _LevelEditor.EditorCubeType.Sticky: selectedTexture = stickyTexture; break; case _LevelEditor.EditorCubeType.Timer: selectedTexture = timerTexture; break; case _LevelEditor.EditorCubeType.Switch: selectedTexture = switchTexture; break; case _LevelEditor.EditorCubeType.Mirror: selectedTexture = mirrorTexture; break; case _LevelEditor.EditorCubeType.ChaosBall: selectedTexture = chaosBallTexture; break; default: break; } break; case "Temple": switch (_LevelEditor.instance.cubeType) { case _LevelEditor.EditorCubeType.Static: //selectedTexture = floorTexture; selectedTextureList = floorTempleTextures; selectedTexture = selectedTextureList[selectedTextureInt]; break; case _LevelEditor.EditorCubeType.Moveable: selectedTexture = moveableTexture; break; case _LevelEditor.EditorCubeType.Elevator: selectedTexture = elevatorTexture; break; case _LevelEditor.EditorCubeType.Unmoveable: selectedTexture = unmoveableTexture; break; case _LevelEditor.EditorCubeType.Victory: selectedTexture = victoryTexture; break; case _LevelEditor.EditorCubeType.Delivery: selectedTexture = deliveryTexture; break; case _LevelEditor.EditorCubeType.Sticky: selectedTexture = stickyTexture; break; case _LevelEditor.EditorCubeType.Timer: selectedTexture = timerTexture; break; case _LevelEditor.EditorCubeType.Switch: selectedTexture = switchTexture; break; case _LevelEditor.EditorCubeType.Mirror: selectedTexture = mirrorTexture; break; case _LevelEditor.EditorCubeType.ChaosBall: selectedTexture = chaosBallTexture; break; default: break; } break; case "Statues": switch (_LevelEditor.instance.cubeType) { case _LevelEditor.EditorCubeType.Static: //selectedTexture = floorTexture; selectedTextureList = floorStatuesTextures; selectedTexture = selectedTextureList[selectedTextureInt]; break; case _LevelEditor.EditorCubeType.Moveable: selectedTexture = moveableTexture; break; case _LevelEditor.EditorCubeType.Elevator: selectedTexture = elevatorTexture; break; case _LevelEditor.EditorCubeType.Unmoveable: selectedTexture = unmoveableTexture; break; case _LevelEditor.EditorCubeType.Victory: selectedTexture = victoryTexture; break; case _LevelEditor.EditorCubeType.Delivery: selectedTexture = deliveryTexture; break; case _LevelEditor.EditorCubeType.Sticky: selectedTexture = stickyTexture; break; case _LevelEditor.EditorCubeType.Timer: selectedTexture = timerTexture; break; case _LevelEditor.EditorCubeType.Switch: selectedTexture = switchTexture; break; case _LevelEditor.EditorCubeType.Mirror: selectedTexture = mirrorTexture; break; case _LevelEditor.EditorCubeType.ChaosBall: selectedTexture = chaosBallTexture; break; default: break; } break; case "Chaos": switch (_LevelEditor.instance.cubeType) { case _LevelEditor.EditorCubeType.Static: //selectedTexture = floorTexture; selectedTextureList = floorChaosTextures; selectedTexture = selectedTextureList[selectedTextureInt]; break; case _LevelEditor.EditorCubeType.Moveable: selectedTexture = moveableTexture; break; case _LevelEditor.EditorCubeType.Elevator: selectedTexture = elevatorTexture; break; case _LevelEditor.EditorCubeType.Unmoveable: selectedTexture = unmoveableTexture; break; case _LevelEditor.EditorCubeType.Victory: selectedTexture = victoryTexture; break; case _LevelEditor.EditorCubeType.Delivery: selectedTexture = deliveryTexture; break; case _LevelEditor.EditorCubeType.Sticky: selectedTexture = stickyTexture; break; case _LevelEditor.EditorCubeType.Timer: selectedTexture = timerTexture; break; case _LevelEditor.EditorCubeType.Switch: selectedTexture = switchTexture; break; case _LevelEditor.EditorCubeType.Mirror: selectedTexture = mirrorTexture; break; case _LevelEditor.EditorCubeType.ChaosBall: selectedTexture = chaosBallTexture; break; default: break; } break; default: Debug.Log("F****d it up"); break; } if (_LevelEditor.instance.cubeType == _LevelEditor.EditorCubeType.Spawn) { selectedTexture = playerTexture; } //else selectedTexture = selectedTextureList[selectedTextureInt]; if (Input.GetAxis("Mouse ScrollWheel") > 0f && selectedTextureInt < selectedTextureList.Count - 1) { selectedTextureInt++; //this is scrolling up } else if (Input.GetAxis("Mouse ScrollWheel") < 0f && selectedTextureInt > 0) { selectedTextureInt--; //this is scrolling down } else { return; } }