public override void Initialize(params object[] parameters) { base.Initialize(); string text = ""; if (parameters.Length >= 1 && parameters[0] is string txt) { text = txt; } FontFamily font = new FontFamily("Consolas"); if (parameters.Length >= 2 && parameters[1] is FontFamily fnt) { font = fnt; } GUIInteractionColors colors = new GUIInteractionColors( Color.BLACK, Color.BLACK, Color.LIGHT_GRAY ); if (parameters.Length >= 3 && parameters[2] is GUIInteractionColors c) { colors = c; } GUIInteractionGraphics graphics = new GUIInteractionGraphics( GraphicsHandler.CreateDefaultTexture(1, 1, Color.WHITE), GraphicsHandler.CreateDefaultTexture(1, 1, Color.LIGHT_GRAY), GraphicsHandler.CreateDefaultTexture(1, 1, Color.DARK_GRAY) ); if (parameters.Length >= 4 && parameters[3] is GUIInteractionGraphics g) { graphics = g; } this.graphics = graphics; this.colors = colors; this.sprite = GameObject.AddComponent <Sprite>(Color.WHITE, graphics.Get(InteractionState)); this.textSprite = GameObject.AddComponent <TextSprite>(text, 16, font, colors.Get(InteractionState), new Rectangle(0, 0, Width, Height)); UpdateMesh(); UpdateTextureAndColor(); OnMouseEntered += (component, x, y) => UpdateTextureAndColor(); OnMouseExited += (component, x, y) => UpdateTextureAndColor(); OnMouseClicked += (component, x, y) => UpdateTextureAndColor(); OnMouseReleased += (component, x, y) => UpdateTextureAndColor(); OnSizeChanged += UpdateMesh; }
protected override void AdditionalInitialize() { this.knobGraphics = new GUIInteractionColors(Color.SlateGray, Color.SlateGray, Color.SlateGray); OnMouseClicked += OnOnMouseDown; OnMouseDown += OnOnMouseDown; OnMouseReleased += OnOnMouseDown; InteractionGraphics = new GUIInteractionColors(Color.DarkGray, Color.DarkGray, Color.DarkGray); }
public sealed override void Initialize() { Handler = GameObject.GetComponent <GUIHandler>(GameObjectComponentSearchMode.ParentalHierarchy); RenderLayer = -1; this.interactionGraphics = new GUIInteractionColors(); this.shape = new CustomShape(Render); InteractionState = GUIComponentInteractionState.None; Width = 1; Height = 1; AdditionalInitialize(); }