private static RenderingHighlighter GetDefaultRenderHighlighter(string sortLayer) { //If this layer is not available in tool yet, allow default values. bool usingDefaultValues; var defaultRenderingHighlighter = new RenderingHighlighter { LayerName = sortLayer, sortingOrderTextColor = GetCorrectTextColorForLayer(sortLayer), layerTexture = GetCorrectTextureForLayer(sortLayer, out usingDefaultValues) }; //If using default values, we set a custom layer name - a substring of the original name if (usingDefaultValues) { defaultRenderingHighlighter.customLayerName = sortLayer.Substring(0, 3); } return defaultRenderingHighlighter; }
public static void ResyncAssetFile() { string[] sortingLayerNames = GetSortingLayerNames(); //Fill them up with defaults var newRenderingHighlighters = new List<RenderingHighlighter>(sortingLayerNames.Length); for (int i = 0; i < sortingLayerNames.Length; i++) { newRenderingHighlighters.Add(GetDefaultRenderHighlighter(sortingLayerNames[i])); } var renderingHighlighters = _renderingHighlightersDataFile.RenderingHighlightersList; for (int i = 0; i < newRenderingHighlighters.Count; i++) { RenderingHighlighter newRenderingHighlighter = newRenderingHighlighters[i]; foreach (RenderingHighlighter renderingHighlighter in renderingHighlighters) { if (newRenderingHighlighter.LayerName != renderingHighlighter.LayerName) { continue; } if (renderingHighlighter.layerTexture == null) { bool isUsingDefaultTexture; renderingHighlighter.layerTexture = GetCorrectTextureForLayer(newRenderingHighlighter.LayerName, out isUsingDefaultTexture); } //If custom layer was changed before - use the one set by the user if (!string.IsNullOrEmpty(renderingHighlighter.customLayerName)) { newRenderingHighlighter.customLayerName = renderingHighlighter.customLayerName; } newRenderingHighlighters[i] = renderingHighlighter; } } for (int i = 0; i < NGUIHighlighterConstants.NUMBER_OF_NGUI_LAYERS; i++) { //Add a manual layer for the NGUI widgets var widgetRenderingHighlighterForLayer = new RenderingHighlighter { LayerName = NGUIHighlighterConstants.NGUI_LAYER + i, layerTexture = AssetDatabase.LoadAssetAtPath( RendererHighlighterConstants.iconsFilePath + NGUIHighlighterConstants.NGUI_ICON + i + RendererHighlighterConstants.TIF_EXTENSION, typeof(Texture2D)) as Texture2D, sortingOrderTextColor = Color.white }; newRenderingHighlighters.Add(widgetRenderingHighlighterForLayer); } for (int i = 0; i < NGUIHighlighterConstants.NUMBER_OF_NGUI_LAYERS; i++) { //Add a manual layer for the NGUI panels var panelRenderingHighlighterForLayer = new RenderingHighlighter { LayerName = NGUIHighlighterConstants.NGUIPANEL_LAYER + i, layerTexture = AssetDatabase.LoadAssetAtPath( RendererHighlighterConstants.iconsFilePath + NGUIHighlighterConstants.NGUI_ICON + i + RendererHighlighterConstants.TIF_EXTENSION, typeof(Texture2D)) as Texture2D, layerSecondaryTexture = AssetDatabase.LoadAssetAtPath(RendererHighlighterConstants.iconsFilePath + NGUIHighlighterConstants.NGUI_PANEL_ICON, typeof(Texture2D)) as Texture2D, sortingOrderTextColor = Color.white }; newRenderingHighlighters.Add(panelRenderingHighlighterForLayer); } _renderingHighlightersDataFile.RenderingHighlightersList = newRenderingHighlighters; }