This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright Fleeting Being | |
// MIT license - https://opensource.org/licenses/MIT | |
// Inspired by AstralByte's AutoHideUILayer | |
// https://www.reddit.com/r/Unity3D/comments/6yaiit/free_editor_script_to_automatically_hide_ui_layer/ | |
using System.Linq; | |
using UnityEditor; | |
using UnityEditor.Animations; | |
using UnityEngine; | |
namespace Plugins.AutoSelectAnimation.Editor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned int color_average(unsigned int a, unsigned int b) | |
{ | |
return (a & b) + (((a ^ b) >> 1) & 0xFF7F7F7F); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned int average(unsigned int a, unsigned int b) | |
{ | |
return (a & b) + ((a ^ b) >> 1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned int average(unsigned int a, unsigned int b) | |
{ | |
return (a / 2) + (b / 2) + (a & b & 1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned int color_average(unsigned int a, unsigned int b) | |
{ | |
return (a + b) / 2; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned int color_average(unsigned int a, unsigned int b) | |
{ | |
unsigned int ra = a & 0xFF0000; | |
unsigned int rb = b & 0xFF0000; | |
unsigned int ga = a & 0xFF00; | |
unsigned int gb = b & 0xFF00; | |
unsigned int ba = a & 0xFF; | |
unsigned int bb = b & 0xFF; | |
unsigned int r = (ra / 2 + rb / 2) & 0xFF0000; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned int color_average(unsigned int a, unsigned int b) | |
{ | |
unsigned int r = ((a & 0xFF0000 + b & 0xFF0000) >> 1) & 0xFF0000; | |
unsigned int g = ((a & 0x00FF00 + b & 0x00FF00) >> 1) & 0x00FF00; | |
unsigned int b = ((a & 0x0000FF + b & 0x0000FF) >> 1) & 0x0000FF; | |
return r | g | b; | |
} |