/// <summary> /// Requests to reload the knobTexture and adapts it to the position and orientation /// </summary> protected void UpdateKnobTexture() { ReloadTexture(); if (knobTexture == null) { throw new UnityException("Knob texture of " + name + " could not be loaded!"); } if (side != defaultSide) { // Rotate Knob texture according to the side it's used on int rotationSteps = getRotationStepsAntiCW(defaultSide, side); string[] mods = new string[] { "Rotation:" + rotationSteps }; Texture2D modKnobTex = null; // Try to get standard texture in memory ResourceManager.MemoryTexture memoryTex = ResourceManager.FindInMemory(knobTexture); if (memoryTex != null) { // Texture does exist in memory, so built a mod including rotation and try to find it again mods = ResourceManager.AppendMod(memoryTex.modifications, "Rotation:" + rotationSteps); ResourceManager.TryGetTexture(memoryTex.path, ref modKnobTex, mods); } if (modKnobTex == null) { // Rotated version does not exist yet, so create and record it modKnobTex = RTEditorGUI.RotateTextureCCW(knobTexture, rotationSteps); ResourceManager.AddTextureToMemory(memoryTex.path, modKnobTex, mods); } knobTexture = modKnobTex; } }
protected void ReloadKnobTexture() { ReloadType(); if (side != defaultSide) { // Rotate Knob texture according to the side it's used on int rotationSteps = getRotationStepsAntiCW(defaultSide, side); ResourceManager.MemoryTexture memoryTex = ResourceManager.FindInMemory(knobTexture); List <string> mods = memoryTex.modifications.ToList(); mods.Add("Rotation:" + rotationSteps); Texture2D knobTextureInMemory = ResourceManager.GetTexture(texturePath, mods.ToArray()); if (knobTextureInMemory != null) { knobTexture = knobTextureInMemory; } else { knobTexture = RTEditorGUI.RotateTextureAntiCW(knobTexture, rotationSteps); ResourceManager.AddTexture(texturePath, knobTexture, mods.ToArray()); } } }
protected void ReloadKnobTexture() { ReloadTexture(); if ((UnityEngine.Object)knobTexture == (UnityEngine.Object)null) { throw new UnityException("Knob texture of " + base.name + " could not be loaded!"); } if (side != defaultSide) { ResourceManager.SetDefaultResourcePath(NodeEditor.editorPath + "Resources/"); int rotationStepsAntiCW = getRotationStepsAntiCW(defaultSide, side); ResourceManager.MemoryTexture memoryTexture = ResourceManager.FindInMemory(knobTexture); if (memoryTexture != null) { string[] array = new string[memoryTexture.modifications.Length + 1]; memoryTexture.modifications.CopyTo(array, 0); array[array.Length - 1] = "Rotation:" + rotationStepsAntiCW; Texture2D texture = ResourceManager.GetTexture(memoryTexture.path, array); if ((UnityEngine.Object)texture != (UnityEngine.Object)null) { knobTexture = texture; } else { knobTexture = RTEditorGUI.RotateTextureCCW(knobTexture, rotationStepsAntiCW); ResourceManager.AddTextureToMemory(memoryTexture.path, knobTexture, array.ToArray()); } } else { knobTexture = RTEditorGUI.RotateTextureCCW(knobTexture, rotationStepsAntiCW); } } }
/// <summary> /// Requests to teload the knobTexture and adapts it to the position and orientation /// </summary> protected void ReloadKnobTexture() { ReloadTexture(); if (knobTexture == null) { throw new UnityException("Knob texture of " + name + " could not be loaded!"); } if (side != defaultSide) { // Rotate Knob texture according to the side it's used on ResourceManager.SetDefaultResourcePath(NodeEditor.editorPath + "Resources/"); int rotationSteps = getRotationStepsAntiCW(defaultSide, side); // Get standard texture in memory ResourceManager.MemoryTexture memoryTex = ResourceManager.FindInMemory(knobTexture); if (memoryTex != null) { // Texture does exist in memory, so built a mod including rotation string[] mods = new string[memoryTex.modifications.Length + 1]; memoryTex.modifications.CopyTo(mods, 0); mods[mods.Length - 1] = "Rotation:" + rotationSteps; // Try to find the rotated version in memory Texture2D knobTextureInMemory = ResourceManager.GetTexture(memoryTex.path, mods); if (knobTextureInMemory != null) { // Rotated version does exist knobTexture = knobTextureInMemory; } else { // Rotated version does not exist, so create and reord it knobTexture = RTEditorGUI.RotateTextureCCW(knobTexture, rotationSteps); ResourceManager.AddTextureToMemory(memoryTex.path, knobTexture, mods.ToArray()); } } else { // If it does not exist in memory, we have no path for it so we just silently rotate and use it // Note that this way we have to rotate it over and over again later on knobTexture = RTEditorGUI.RotateTextureCCW(knobTexture, rotationSteps); } } }
protected void ReloadKnobTexture() { ReloadTexture(); if (knobTexture == null) { throw new UnityException("Knob texture of " + name + " could not be loaded!"); } if (side != defaultSide) { ResourceManager.SetDefaultResourcePath(NodeEditor.editorPath + "EditorResources/"); int rotationSteps = getRotationStepsAntiCW(defaultSide, side); ResourceManager.MemoryTexture memoryTex = ResourceManager.FindInMemory(knobTexture); if (memoryTex != null) { string[] mods = new string[memoryTex.modifications.Length + 1]; memoryTex.modifications.CopyTo(mods, 0); mods[mods.Length - 1] = "Rotation:" + rotationSteps; Texture2D knobTextureInMemory = ResourceManager.GetTexture(memoryTex.path, mods); if (knobTextureInMemory != null) { knobTexture = knobTextureInMemory; } else { knobTexture = RTEditorGUI.RotateTextureCCW(knobTexture, rotationSteps); ResourceManager.AddTextureToMemory(memoryTex.path, knobTexture, mods.ToArray()); } } else { knobTexture = RTEditorGUI.RotateTextureCCW(knobTexture, rotationSteps); } } }