/// <summary> /// Inspector. /// </summary> protected override void Inspector() { if (baseTarget == null) { baseTarget = base.target as SpriteColorMasks3; } EditorGUIUtility.fieldWidth = 40.0f; baseTarget.strength = (float)SpriteColorFXEditorHelper.IntSliderWithReset(@"Strength", SpriteColorFXEditorHelper.TooltipStrength, Mathf.RoundToInt(baseTarget.strength * 100.0f), 0, 100, 100) * 0.01f; SpriteColorHelper.PixelOp newPixelOp = (SpriteColorHelper.PixelOp)EditorGUILayout.EnumPopup(new GUIContent(@"Blend mode", @"Blend modes"), baseTarget.pixelOp); if (newPixelOp != baseTarget.pixelOp) { baseTarget.SetPixelOp(newPixelOp); } EditorGUILayout.LabelField(@"#1 mask (red)"); { EditorGUI.indentLevel++; baseTarget.strengthMaskRed = (float)SpriteColorFXEditorHelper.IntSliderWithReset(@"Strength", SpriteColorFXEditorHelper.TooltipStrength, Mathf.RoundToInt(baseTarget.strengthMaskRed * 100f), 0, 100, 100) * 0.01f; baseTarget.colorMaskRed = EditorGUILayout.ColorField(@"Color", baseTarget.colorMaskRed); baseTarget.textureMaskRed = (EditorGUILayout.ObjectField(new GUIContent(@"Texture (RGB)", SpriteColorFXEditorHelper.TooltipTextureMask), baseTarget.textureMaskRed, typeof(Texture2D), false, GUILayout.Height(54.0f)) as Texture2D); if (baseTarget.textureMaskRed != null) { EditorGUILayout.LabelField(@"UV params"); UVParamsInspectorGUI(ref baseTarget.textureMaskRedUVParams, ref baseTarget.textureMaskRedUVAngle); } EditorGUI.indentLevel--; } EditorGUILayout.LabelField(@"#2 mask (green)"); { EditorGUI.indentLevel++; baseTarget.strengthMaskGreen = (float)SpriteColorFXEditorHelper.IntSliderWithReset(@"Strength", SpriteColorFXEditorHelper.TooltipStrength, Mathf.RoundToInt(baseTarget.strengthMaskGreen * 100f), 0, 100, 100) * 0.01f; baseTarget.colorMaskGreen = EditorGUILayout.ColorField(@"Color", baseTarget.colorMaskGreen); baseTarget.textureMaskGreen = (EditorGUILayout.ObjectField(new GUIContent(@"Texture (RGB)", SpriteColorFXEditorHelper.TooltipTextureMask), baseTarget.textureMaskGreen, typeof(Texture2D), false, GUILayout.Height(54.0f)) as Texture2D); if (baseTarget.textureMaskGreen != null) { EditorGUILayout.LabelField(@"UV params"); UVParamsInspectorGUI(ref baseTarget.textureMaskGreenUVParams, ref baseTarget.textureMaskGreenUVAngle); } EditorGUI.indentLevel--; } EditorGUILayout.LabelField(@"#3 mask (blue)"); { EditorGUI.indentLevel++; baseTarget.strengthMaskBlue = (float)SpriteColorFXEditorHelper.IntSliderWithReset(@"Strength", SpriteColorFXEditorHelper.TooltipStrength, Mathf.RoundToInt(baseTarget.strengthMaskBlue * 100f), 0, 100, 100) * 0.01f; baseTarget.colorMaskBlue = EditorGUILayout.ColorField(@"Color", baseTarget.colorMaskBlue); baseTarget.textureMaskBlue = (EditorGUILayout.ObjectField(new GUIContent(@"Texture (RGB)", SpriteColorFXEditorHelper.TooltipTextureMask), baseTarget.textureMaskBlue, typeof(Texture2D), false, GUILayout.Height(54.0f)) as Texture2D); if (baseTarget.textureMaskBlue != null) { EditorGUILayout.LabelField(@"UV params"); UVParamsInspectorGUI(ref baseTarget.textureMaskBlueUVParams, ref baseTarget.textureMaskBlueUVAngle); } EditorGUI.indentLevel--; } EditorGUILayout.Separator(); baseTarget.textureMask = (EditorGUILayout.ObjectField(new GUIContent(@"Mask #1 (RGB)", SpriteColorFXEditorHelper.TooltipTextureMask), this.baseTarget.textureMask, typeof(Texture2D), false, GUILayout.Height(54.0f)) as Texture2D); }
private void OnGUI() { if (showGUI == false) { return; } Vector3 screenPosition = Camera.main.WorldToScreenPoint(this.transform.position); float width = 150.0f; const float height = 150.0f; GUILayout.BeginArea(new Rect(screenPosition.x - (width * 0.5f), screenPosition.y - (height * 0.5f), width, height), GUI.skin.box); { spriteColorMask.enabled = GUILayout.Toggle(spriteColorMask.enabled, @" Enable masks"); GUI.enabled = spriteColorMask.enabled; GUILayout.BeginHorizontal(); { GUILayout.Label(@"Strength", GUILayout.Width(50.0f)); spriteColorMask.strength = GUILayout.HorizontalSlider(spriteColorMask.strength, 0.0f, 1.0f); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { if (GUILayout.Button("<<") == true) { changeBlendModes = false; if (spriteColorMask.pixelOp > 0) { spriteColorMask.SetPixelOp(spriteColorMask.pixelOp - 1); } else { spriteColorMask.SetPixelOp(SpriteColorHelper.PixelOp.VividLight); } } GUILayout.FlexibleSpace(); GUILayout.Label(spriteColorMask.pixelOp.ToString(), GUILayout.ExpandWidth(true)); GUILayout.FlexibleSpace(); if (GUILayout.Button(">>") == true) { changeBlendModes = false; if (spriteColorMask.pixelOp < SpriteColorHelper.PixelOp.VividLight) { spriteColorMask.SetPixelOp(spriteColorMask.pixelOp + 1); } else { spriteColorMask.SetPixelOp(SpriteColorHelper.PixelOp.Additive); } } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(@"Mask #1", GUILayout.Width(50.0f)); spriteColorMask.strengthMaskRed = GUILayout.HorizontalSlider(spriteColorMask.strengthMaskRed, 0.0f, 1.0f); GUILayout.Box(textureColors[0], GUILayout.Width(24.0f)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(@"Mask #2", GUILayout.Width(50.0f)); spriteColorMask.strengthMaskGreen = GUILayout.HorizontalSlider(spriteColorMask.strengthMaskGreen, 0.0f, 1.0f); GUILayout.Box(textureColors[1], GUILayout.Width(24.0f)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(@"Mask #3", GUILayout.Width(50.0f)); spriteColorMask.strengthMaskBlue = GUILayout.HorizontalSlider(spriteColorMask.strengthMaskBlue, 0.0f, 1.0f); GUILayout.Box(textureColors[2], GUILayout.Width(24.0f)); } GUILayout.EndHorizontal(); } GUILayout.EndArea(); }