private void AddEventTrigger(EventTrigger evTrig, UnityAction<BaseEventData> action, EventTriggerType triggerType) { EventTrigger.TriggerEvent triggerEvent = new EventTrigger.TriggerEvent(); triggerEvent.AddListener((eventData) => action(eventData)); EventTrigger.Entry entry = new EventTrigger.Entry() { callback = triggerEvent, eventID = triggerType }; evTrig.triggers.Add(entry); }
private void AddPointerEnterTrigger(EventTrigger evTrig, EventTriggerType triggerType) { EventTrigger.TriggerEvent triggerEvent = new EventTrigger.TriggerEvent(); AddEventTrigger(evTrig, d => OnPointerEnter(d, evTrig.gameObject), EventTriggerType.PointerEnter); EventTrigger.Entry entry = new EventTrigger.Entry() { callback = triggerEvent, eventID = triggerType }; evTrig.triggers.Add(entry); }
void AssignAllActions(System.Action<BaseEventData> pressedAction, System.Action<BaseEventData> releasedAction, ref EventTrigger trigger) { EventTrigger.Entry entry1 = new EventTrigger.Entry(); entry1.eventID = EventTriggerType.PointerDown; entry1.callback.AddListener(eventData => pressedAction.Invoke(eventData)); trigger.triggers.Add(entry1); EventTrigger.Entry entry2 = new EventTrigger.Entry(); entry2.eventID = EventTriggerType.PointerUp; entry2.callback.AddListener(eventData => releasedAction.Invoke(eventData)); trigger.triggers.Add(entry2); EventTrigger.Entry entry3 = new EventTrigger.Entry(); entry3.eventID = EventTriggerType.PointerExit; entry3.callback.AddListener(eventData => releasedAction.Invoke(eventData)); trigger.triggers.Add(entry3); }
// ------------------ Constants and statics // ------------------ Events // ------------------ Serialized fields and properties // ------------------ Non-serialized fields // ------------------ Methods public static void AddEventTrigger(EventTrigger eventTrigger, UnityAction unityAction, EventTriggerType eventTriggerType) { EventTrigger.TriggerEvent triggerEvent = new EventTrigger.TriggerEvent(); triggerEvent.AddListener((eventData) => unityAction()); // ignore event data EventTrigger.Entry entry = new EventTrigger.Entry() { callback = triggerEvent, eventID = eventTriggerType }; eventTrigger.triggers.Add(entry); }
public override void OnEnter () { handler = gameObject.Value.GetComponent<EventTrigger> (); if (handler == null) { handler = gameObject.Value.AddComponent<EventTrigger>(); } EventTrigger.Entry entry = new EventTrigger.Entry (); entry.eventID = type; entry.callback.AddListener (OnTrigger); handler.delegates.Add (entry); }
// Use this for initialization void Start() { thisEventTrigger = GetComponent<EventTrigger>(); entry.eventID = EventTriggerType.PointerUp; entry.callback.AddListener( (eventData) => {OnFingerUp(); } ); thisEventTrigger.triggers.Add(entry); }
public NumericValidationTriggerPage () { var t = new EventTrigger (); t.Event = "TextChanged"; t.Actions.Add (new NumericValidationTriggerAction ()); var l = new Label { Text = "Text becomes red if the entry is not a valid double" }; l.FontSize = Device.GetNamedSize (NamedSize.Small, l); var e = new Entry { Placeholder = "Enter a System.Double" }; e.Triggers.Add(t); Padding = new Thickness (0, 20, 0, 0); Content = new StackLayout { Children = { l, e } }; }
// Use this for initialization void Start() { thisEventTrigger = GetComponent<EventTrigger>(); entry.eventID = EventTriggerType.PointerDown; entry.callback.AddListener( (eventData) => {CallGameManager(); } ); thisEventTrigger.triggers.Add(entry); }
void Start() { Debug.Log(this.gameObject.name); eventTrigger = this.gameObject.GetComponent<EventTrigger>(); AddEventTrgger( OnPointDown, EventTriggerType.PointerDown); AddEventTrgger(OnPointUp, EventTriggerType.PointerUp); }
void Start() { this.trigger = this.gameObject.AddComponent<EventTrigger>(); // this.AddListener(EventTriggerType.PointerDown, (eventData) => { Down(); }); // this.AddListener(EventTriggerType.PointerUp, (eventData) => { Up(); }); this.AddListener(EventTriggerType.PointerEnter, (eventData) => { Down(); }); this.AddListener(EventTriggerType.PointerExit, (eventData) => { Up(); }); }
private void Awake() { targetButton = GetComponent<Button>(); rectTransform = GetComponent<RectTransform>(); trigger = targetButton.gameObject.AddComponent<EventTrigger>(); AddEventTrigger(EventTriggerType.PointerEnter, OnPointerEnter); }
void Start () { //PC = GameObject.Find ("PC").GetComponent<PC_Main> (); rigBod = GetComponent<Rigidbody>(); eventTrigger = GetComponent<EventTrigger>(); AddEventTrigger(OnPointerClick, EventTriggerType.PointerUp); normSize = transform.localScale; normPos = transform.localPosition; largeSize = new Vector3 (0.5f, 0.01f, 0.4f); largePos = new Vector3 (0.2f, -0.6f, 0.2f); }
//This is a debug script that provides a button hook to the lobby manager to send players back to the lobby void Start() { eventTrigger = GetComponent<EventTrigger>(); foreach (EventTrigger.Entry e in eventTrigger.triggers) { if (e.eventID == EventTriggerType.PointerUp) { e.callback.AddListener((data) => { OnPointerDownDelegate((PointerEventData)data); }); } } }
private Task DoTimer(int milleseconds) { var et = new EventTrigger(); var tcs = new TaskCompletionSource<object>(); et.Ready += (sender, args) => { tcs.SetResult(null); }; et.Run(milleseconds); return tcs.Task; }
private void addEventTrigger(EventTrigger eventTrigger, UnityAction<BaseEventData> action, EventTriggerType triggerType) { // Create a nee TriggerEvent and add a listener EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener(action); // you can capture and pass the event data to the listener // Create and initialise EventTrigger.Entry using the created TriggerEvent EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = triggerType }; // Add the EventTrigger.Entry to delegates list on the EventTrigger eventTrigger.triggers.Add(entry); }
// Use this for initialization void Start() { idle = GetComponent<Image> ().color; gameObject.GetComponent<Image> ().color = idle; thisEventTrigger = GetComponent<EventTrigger>(); entry.eventID = EventTriggerType.PointerDown; entry2.eventID = EventTriggerType.PointerUp; entry.callback.AddListener( (eventData) => {OnFingerDown(); } ); entry2.callback.AddListener( (eventData) => {OnFingerUp (); } ); thisEventTrigger.triggers.Add(entry); thisEventTrigger.triggers.Add(entry2); }
// Use this for initialization void Start() { eventTrigger = gameObject.GetComponent<EventTrigger>(); AddEventTrigger(OnPointerClick, EventTriggerType.PointerClick); AddEventTrigger(OnPointerEnter, EventTriggerType.PointerEnter, toggle); AddEventTrigger(OnPointerExit, EventTriggerType.PointerExit); AddEventTrigger(OnPointerDown, EventTriggerType.PointerDown); AddEventTrigger(OnPointerUp, EventTriggerType.PointerUp); AddEventTrigger(OnDrag, EventTriggerType.Drag); AddEventTrigger(OnDrop, EventTriggerType.Drop); AddEventTrigger(OnScroll, EventTriggerType.Scroll); }
// Use this for initialization void Start() { gameObject.GetComponent<Text> ().color = idle; thisEventTrigger = GetComponent<EventTrigger>(); entry.eventID = EventTriggerType.PointerDown; entry2.eventID = EventTriggerType.PointerUp; entry.callback.AddListener( (eventData) => {OnFingerDown(); } ); entry2.callback.AddListener( (eventData) => {OnFingerUp (); } ); thisEventTrigger.triggers.Add(entry); thisEventTrigger.triggers.Add(entry2); idleSize = new Vector3(1f,1f,1f); highLightedSize = idleSize * enlargeScale; }
void AddTriggers() { print ("triggers added"); down = new UnityAction (NavBoatControl.s_instance.RudderSliderValueWasChangedTrue); up = new UnityAction (NavBoatControl.s_instance.RudderSliderValueWasChangedFalse); trigger = GetComponent<EventTrigger> (); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerDown; entry.callback.AddListener((eventData) => down() ); trigger.triggers.Add(entry); EventTrigger.Entry entry2 = new EventTrigger.Entry(); entry2.eventID = EventTriggerType.PointerUp; entry2.callback.AddListener((eventData) => up() ); trigger.triggers.Add(entry2); }
public void UpdateObjectHit(EventTrigger objectHit) { // current object is changed only if the state is hovering // Previous object is no longer hit if (currentObject != null && objectHit != currentObject && currentObjectState == ObjectState.Hovering) { currentObject.OnHoverOut(); } if (objectHit != null && objectHit != currentObject && currentObjectState == ObjectState.Hovering) { currentObjectState = ObjectState.Hovering; objectHit.OnHoverIn(); } if (currentObjectState == ObjectState.Hovering) { currentObject = objectHit; } if (currentObject == null) { return; } // We are calling the press only if the current object is being hovered if (Input.GetMouseButtonDown(0) && currentObjectState == ObjectState.Hovering) { currentObjectState = ObjectState.Pressing; currentObject.OnPress(); } // Only if we are currently pressing if (Input.GetMouseButtonUp(0) && currentObjectState == ObjectState.Pressing) { currentObject.OnRelease(); currentObjectState = ObjectState.Hovering; // Only if we are currently pressing and the object hit is the same we call the on click if (objectHit == currentObject) { currentObject.OnClick(); } } }
private void InputParametersTreeView_OnItemPrepared(object sender, RadTreeViewItemPreparedEventArgs e) { if (e.PreparedItem.Item is WebMethodCallParameterViewModel) { var eventTrigger = new EventTrigger(RadTreeViewItem.LoadOnDemandEvent.Name); var action = new CallMethodAction { MethodName = ReflectionHelper.GetMethodName<WebMethodCallParameterViewModel>( x => x.PopulateChildren(null, null)) }; BindingOperations.SetBinding(action, CallMethodAction.TargetObjectProperty, new Binding()); eventTrigger.Actions.Add(action); var triggers = Interaction.GetTriggers(e.PreparedItem); triggers.Add(eventTrigger); } }
public PressEventer(EventTrigger trigger) { this.trigger = trigger; var onDown = new EventTrigger.Entry(); onDown.eventID = EventTriggerType.PointerDown; onDown.callback.AddListener(OnDown); trigger.triggers.Add(onDown); var onCancel = new EventTrigger.Entry(); onCancel.eventID = EventTriggerType.Cancel; onCancel.callback.AddListener(ResetTimer); trigger.triggers.Add(onCancel); var onExit = new EventTrigger.Entry(); onExit.eventID = EventTriggerType.PointerExit; onExit.callback.AddListener(ResetTimer); trigger.triggers.Add(onExit); var onUp = new EventTrigger.Entry(); onUp.eventID = EventTriggerType.PointerUp; onUp.callback.AddListener(OnUp); trigger.triggers.Add(onUp); }
/** The media player contains the following elements: * - Media element * - Control panel: * - Timeline panel to keep track of media progress and provide seek to functionality * - Playback panel: * - Pause button * - Resume button * - Replay button * - Volume controls: * - Mute/unmute * - Volume slider */ private static FrameworkElement RenderMediaPlayer(AdaptiveRenderContext context, AdaptiveMediaSource mediaSource, FrameworkElement uiMedia) { var uiMediaPlayer = new Grid(); var mediaElement = new MediaElement() { Stretch = Stretch.Fill, }; uiMediaPlayer.Children.Add(mediaElement); // Add some height to keep the controls (timeline panel + playback panel) if (!IsAudio(mediaSource)) { uiMediaPlayer.MinHeight = _panelHeight * 2 + _childMargin * 4; } var uiControlPanel = new StackPanel() { VerticalAlignment = VerticalAlignment.Bottom, Background = _controlBackgroundColor, }; #region Timeline Panel // Using Grid to stretch the timeline slider var uiTimelinePanel = new Grid() { HorizontalAlignment = HorizontalAlignment.Stretch, Height = _panelHeight, }; TextBlock uiCurrentTime = new TextBlock() { Text = "00:00:00", Foreground = _controlForegroundColor, VerticalAlignment = VerticalAlignment.Center, Margin = _marginThickness, }; uiTimelinePanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20, GridUnitType.Auto), }); Grid.SetColumn(uiCurrentTime, 0); uiTimelinePanel.Children.Add(uiCurrentTime); Slider uiTimelineSlider = new Slider() { Margin = _marginThickness, IsEnabled = false, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, }; uiTimelinePanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20, GridUnitType.Star), }); Grid.SetColumn(uiTimelineSlider, 1); uiTimelinePanel.Children.Add(uiTimelineSlider); TextBlock uiMaxTime = new TextBlock() { Text = "00:00:00", Foreground = _controlForegroundColor, VerticalAlignment = VerticalAlignment.Center, Margin = _marginThickness, }; uiTimelinePanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20, GridUnitType.Auto), }); Grid.SetColumn(uiMaxTime, 2); uiTimelinePanel.Children.Add(uiMaxTime); #endregion uiControlPanel.Children.Add(uiTimelinePanel); #region Playback + Volume Panel var uiPlaybackVolumePanel = new Grid() { Height = _panelHeight, }; #region Create Playback Control Container var uiPlaybackControlContainer = new StackPanel() { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, Orientation = Orientation.Horizontal, Height = _panelHeight, }; // Play trigger attached with the thumbnail button var playTrigger = new EventTrigger(UIElement.MouseUpEvent) { SourceName = "thumbnailButton", }; var mediaTimeline = new MediaTimeline() { // This URI was previously confirmed to be valid Source = context.Config.ResolveFinalAbsoluteUri(mediaSource.Url), }; Storyboard.SetTarget(mediaTimeline, mediaElement); var storyboard = new Storyboard() { SlipBehavior = SlipBehavior.Slip, }; storyboard.Children.Add(mediaTimeline); var beginStoryboard = new BeginStoryboard() { // An arbitrary name is necessary for the storyboard to work correctly Name = "beginStoryboard", Storyboard = storyboard, }; playTrigger.Actions.Add(beginStoryboard); // The play trigger needs to be added to uiMedia since // uiThumbnailButton is inside uiMedia uiMedia.Triggers.Add(playTrigger); // Buffering signal var uiBuffering = new TextBlock() { Text = "⏳ Buffering...", Foreground = _controlForegroundColor, VerticalAlignment = VerticalAlignment.Center, Margin = _marginThickness, }; uiPlaybackControlContainer.Children.Add(uiBuffering); // Pause button var uiPauseButton = RenderPlaybackButton("⏸"); uiPlaybackControlContainer.Children.Add(uiPauseButton); // Resume button var uiResumeButton = RenderPlaybackButton("⏵"); uiPlaybackControlContainer.Children.Add(uiResumeButton); // Replay button var uiReplayButton = RenderPlaybackButton("🔄"); uiPlaybackControlContainer.Children.Add(uiReplayButton); // Click events MediaState currentMediaState = MediaState.NotStarted; uiPauseButton.MouseUp += (sender, e) => { storyboard.Pause(uiMedia); currentMediaState = MediaState.IsPaused; HandlePlaybackButtonVisibility(currentMediaState, uiPauseButton, uiResumeButton, uiReplayButton); }; uiResumeButton.MouseUp += (sender, e) => { storyboard.Resume(uiMedia); currentMediaState = MediaState.IsPlaying; HandlePlaybackButtonVisibility(currentMediaState, uiPauseButton, uiResumeButton, uiReplayButton); }; #endregion // Add to control panel uiPlaybackVolumePanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20, GridUnitType.Star), }); Grid.SetColumn(uiPlaybackControlContainer, 0); uiPlaybackVolumePanel.Children.Add(uiPlaybackControlContainer); #region Create Volume Control Container var uiVolumeControlContainer = new Grid() { Height = _panelHeight, VerticalAlignment = VerticalAlignment.Center, }; // 2 overlapping buttons to alternate between mute/unmute states var uiVolumeMuteButton = new TextBlock() { Text = "🔊", FontFamily = _symbolFontFamily, FontSize = _childHeight, Foreground = _controlForegroundColor, Margin = _marginThickness, VerticalAlignment = VerticalAlignment.Center, }; uiVolumeControlContainer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20, GridUnitType.Auto), }); Grid.SetColumn(uiVolumeMuteButton, 0); uiVolumeControlContainer.Children.Add(uiVolumeMuteButton); var uiVolumeUnmuteButton = new TextBlock() { Text = "🔇", FontFamily = _symbolFontFamily, FontSize = _childHeight, Foreground = _controlForegroundColor, Margin = _marginThickness, VerticalAlignment = VerticalAlignment.Center, Visibility = Visibility.Collapsed, }; uiVolumeControlContainer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20, GridUnitType.Auto), }); Grid.SetColumn(uiVolumeUnmuteButton, 0); uiVolumeControlContainer.Children.Add(uiVolumeUnmuteButton); Slider uiVolumeSlider = new Slider() { Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center, Width = 100, Minimum = 0, Maximum = 1, Value = 0.5, }; uiVolumeControlContainer.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20, GridUnitType.Auto), }); Grid.SetColumn(uiVolumeSlider, 1); uiVolumeControlContainer.Children.Add(uiVolumeSlider); // Initialize media volume to 0.5 mediaElement.Volume = uiVolumeSlider.Value; // Volume control handlers void muteVolume(object sender, MouseEventArgs e) { uiVolumeMuteButton.Visibility = Visibility.Collapsed; uiVolumeUnmuteButton.Visibility = Visibility.Visible; mediaElement.Volume = 0; } void unmuteVolume(object sender, RoutedEventArgs e) { uiVolumeUnmuteButton.Visibility = Visibility.Collapsed; uiVolumeMuteButton.Visibility = Visibility.Visible; mediaElement.Volume = uiVolumeSlider.Value; } uiVolumeMuteButton.MouseUp += muteVolume; uiVolumeUnmuteButton.MouseUp += unmuteVolume; uiVolumeSlider.ValueChanged += unmuteVolume; #endregion // Add to control panel uiPlaybackVolumePanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20, GridUnitType.Auto), }); Grid.SetColumn(uiVolumeControlContainer, 1); uiPlaybackVolumePanel.Children.Add(uiVolumeControlContainer); #endregion uiControlPanel.Children.Add(uiPlaybackVolumePanel); uiMediaPlayer.Children.Add(uiControlPanel); #region Other events void showControlPanel(object sender, MouseEventArgs e) { uiControlPanel.Visibility = Visibility.Visible; } void collapseControlPanel(object sender, MouseEventArgs e) { uiControlPanel.Visibility = Visibility.Collapsed; } void mediaStarted(object sender, RoutedEventArgs e) { // Playback button visibility currentMediaState = MediaState.IsPlaying; uiBuffering.Visibility = Visibility.Collapsed; HandlePlaybackButtonVisibility(currentMediaState, uiPauseButton, uiResumeButton, uiReplayButton); // Control panel visibility if (!IsAudio(mediaSource)) { // Hide when the video starts playing uiControlPanel.Visibility = Visibility.Collapsed; // Assign mouse hover events to avoid blocking the video uiMediaPlayer.MouseEnter += showControlPanel; uiMediaPlayer.MouseLeave += collapseControlPanel; } } void mediaEnded(object sender, EventArgs e) { // Playback button visibility currentMediaState = MediaState.NotStarted; HandlePlaybackButtonVisibility(currentMediaState, uiPauseButton, uiResumeButton, uiReplayButton); // Control panel visibility if (!IsAudio(mediaSource)) { // Show when the video is complete uiControlPanel.Visibility = Visibility.Visible; // Remove mouse hover events to always show controls uiMediaPlayer.MouseEnter -= showControlPanel; uiMediaPlayer.MouseLeave -= collapseControlPanel; } } mediaElement.MediaOpened += mediaStarted; storyboard.Completed += mediaEnded; uiReplayButton.MouseUp += (sender, e) => { // Seek to beginning storyboard.Seek(uiMedia, new TimeSpan(0, 0, 0, 0, 0), TimeSeekOrigin.BeginTime); // And start the media as usual mediaStarted(sender, e); }; // Timeline slider events mediaElement.MediaOpened += (sender, e) => { uiTimelineSlider.Maximum = mediaElement.NaturalDuration.TimeSpan.TotalMilliseconds; uiTimelineSlider.IsEnabled = true; uiMaxTime.Text = mediaElement.NaturalDuration.TimeSpan.ToString(@"hh\:mm\:ss"); }; storyboard.CurrentTimeInvalidated += (sender, e) => { uiTimelineSlider.Value = mediaElement.Position.TotalMilliseconds; uiCurrentTime.Text = mediaElement.Position.ToString(@"hh\:mm\:ss"); }; // Thumb events uiTimelineSlider.AddHandler(Thumb.DragStartedEvent, new DragStartedEventHandler((sender, e) => { storyboard.Pause(uiMedia); })); uiTimelineSlider.AddHandler(Thumb.DragDeltaEvent, new DragDeltaEventHandler((sender, e) => { int sliderValue = (int)uiTimelineSlider.Value; TimeSpan selectedTimeSpan = new TimeSpan(0, 0, 0, 0, sliderValue); uiCurrentTime.Text = selectedTimeSpan.ToString(@"hh\:mm\:ss"); })); uiTimelineSlider.AddHandler(Thumb.DragCompletedEvent, new DragCompletedEventHandler((sender, e) => { int sliderValue = (int)uiTimelineSlider.Value; storyboard.Seek(uiMedia, new TimeSpan(0, 0, 0, 0, sliderValue), TimeSeekOrigin.BeginTime); // Only resume playing if it's in playing mode if (currentMediaState == MediaState.IsPlaying) { storyboard.Resume(uiMedia); } })); #endregion return(uiMediaPlayer); }
private void CreateUI() { if (canvas == null) { log.LogMessage(" "); log.LogMessage("Creating UI Elements"); // Create a GameObject with a Canvas canvas = instance.createUICanvas(); Object.DontDestroyOnLoad(canvas); // Add a Panel to the Canvas. See createUIPanel for why we pass height/width as string uiPanel = instance.createUIPanel(canvas, "550", "200", null); // This is how we'll hook mouse Events for window dragging EventTrigger comp1 = new EventTrigger(uiPanel.AddComponent(UnhollowerRuntimeLib.Il2CppType.Of <EventTrigger>()).Pointer); WindowDragHandler comp2 = new WindowDragHandler(uiPanel.AddComponent(UnhollowerRuntimeLib.Il2CppType.Of <WindowDragHandler>()).Pointer); Image panelImage = uiPanel.GetComponent <Image>(); panelImage.color = instance.HTMLString2Color("#2D2D30FF").Unbox <Color32>(); #region [Panel Elements] // NOTE: Elements are spaced in increments/decrements of 35 in localPosition #region [Add a Button] Sprite btnSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#7AB900FF")); GameObject uiButton = instance.createUIButton(uiPanel, btnSprite); uiButton.GetComponent <RectTransform>().localPosition = new Vector3(0, 250, 0); #endregion #region [Add a Toggle] Sprite toggleBgSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#3E3E42FF")); Sprite toggleSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#7AB900FF")); GameObject uiToggle = instance.createUIToggle(uiPanel, toggleBgSprite, toggleSprite); uiToggle.GetComponentInChildren <Text>().color = Color.white; uiToggle.GetComponentInChildren <Toggle>().isOn = false; uiToggle.GetComponent <RectTransform>().localPosition = new Vector3(0, 215, 0); #endregion #region [Add a Slider] Sprite sliderBgSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#9E9E9EFF")); Sprite sliderFillSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#7AB900FF")); Sprite sliderKnobSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#191919FF")); GameObject uiSlider = instance.createUISlider(uiPanel, sliderBgSprite, sliderFillSprite, sliderKnobSprite); uiSlider.GetComponentInChildren <Slider>().value = 0.5f; uiSlider.GetComponent <RectTransform>().localPosition = new Vector3(0, 185, 0); #endregion #region [Add a Text (Label)] Sprite txtBgSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#7AB900FF")); GameObject uiText = instance.createUIText(uiPanel, txtBgSprite, "#FFFFFFFF"); uiText.GetComponent <Text>().text = "This is a new Text Label"; uiText.GetComponent <RectTransform>().localPosition = new Vector3(0, 150, 0); #endregion #region [Add a InputField] Sprite inputFieldSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#7AB900FF")); GameObject uiInputField = instance.createUIInputField(uiPanel, inputFieldSprite, "#000000FF"); #region [Dev Note] // The following line is odd. It sets the text but doesn't display it, WTF? The default child object PlaceHolder // has Text component but Unhollower thinks it's a UnityEngine.Graphic? // uiInputField.transform.GetChild(0).gameObject.GetComponent<Text>().text = "Search..."; // Checked in Unity Editor too, it's definately Text, why does unhollower think it's Graphic? // // We'll just use the InputField component directly. It works, but PlaceHolder is nice... #endregion uiInputField.GetComponent <InputField>().text = "Some Input Field..."; uiInputField.GetComponent <RectTransform>().localPosition = new Vector3(0, 115, 0); #endregion #region [Add a DropDown] // NOTE: This wierd, it does it's thing and work's but then the rest on the UI disappears... hmmm... :/ Sprite dropdownBgSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#7AB900FF")); Sprite dropdownScrollbarSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#3E3E42FF")); Sprite dropdownDropDownSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#252526FF")); Sprite dropdownCheckmarkSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#7AB900FF")); Sprite dropdownMaskSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#1E1E1EFF")); GameObject uiDropDown = instance.createUIDropDown(uiPanel, dropdownBgSprite, dropdownScrollbarSprite, dropdownDropDownSprite, dropdownCheckmarkSprite, dropdownMaskSprite); Object.DontDestroyOnLoad(uiDropDown); uiDropDown.GetComponent <RectTransform>().localPosition = new Vector3(0, 75, 0); #endregion #region [Add a ScrollView] Sprite scrollviewBgSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#9E9E9EFF")); Sprite scrollviewScrollbarSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#3E3E42FF")); Sprite scrollviewMaskSprite = instance.createSpriteFrmTexture(instance.createDefaultTexture("#3E3E42FF")); GameObject uiScrollView = instance.createUIScrollView(uiPanel, scrollviewBgSprite, scrollviewMaskSprite, scrollviewScrollbarSprite); // Set some content GameObject content = uiScrollView.GetComponent <ScrollRect>().content.gameObject; GameObject contentTextObj = instance.createUIText(content, scrollviewBgSprite, "#FFFFFFFF"); contentTextObj.GetComponent <Text>().text = "ScrollView Element"; contentTextObj.GetComponent <RectTransform>().localPosition = new Vector3(120, -50, 0); uiScrollView.GetComponent <RectTransform>().localPosition = new Vector3(0, -75, 0); #endregion #region [Add a RawImage] // Our Test Sprite from testBundle for UI RawImage Element if (testAssetBundle != null && stompy != null) { log.LogMessage(" Trying to Load Test Sprite..."); stompy = testAssetBundle.LoadAsset <Sprite>("assets/tools/customassets/test assets/externaltexture.png"); if (stompy != null) { log.LogMessage(" Sprite Loaded!"); } else { log.LogMessage(" Failed to Load Sprite!"); } GameObject uiImage = instance.createUIRawImage(uiPanel, stompy); uiImage.GetComponent <RectTransform>().localPosition = new Vector3(0, -220, 0); uiImage.GetComponent <RectTransform>().localScale = new Vector3(0.3f, 0.3f); } else { log.LogMessage(" Skipping - Test AssetBundle Not Loaded!"); } #endregion #endregion isVisible = true; log.LogMessage("Complete!"); } }
private static System.Collections.ObjectModel.ObservableCollection<object> Get_TabControl_Items() { System.Collections.ObjectModel.ObservableCollection<object> items = new System.Collections.ObjectModel.ObservableCollection<object>(); // e_3 element TabItem e_3 = new TabItem(); e_3.Name = "e_3"; e_3.HorizontalContentAlignment = HorizontalAlignment.Stretch; e_3.Header = "Controls"; // e_4 element Grid e_4 = new Grid(); e_3.Content = e_4; e_4.Name = "e_4"; RowDefinition row_e_4_0 = new RowDefinition(); row_e_4_0.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_0); RowDefinition row_e_4_1 = new RowDefinition(); row_e_4_1.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_1); RowDefinition row_e_4_2 = new RowDefinition(); row_e_4_2.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_2); RowDefinition row_e_4_3 = new RowDefinition(); row_e_4_3.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_3); RowDefinition row_e_4_4 = new RowDefinition(); row_e_4_4.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_4); RowDefinition row_e_4_5 = new RowDefinition(); row_e_4_5.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_5); RowDefinition row_e_4_6 = new RowDefinition(); row_e_4_6.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_6); RowDefinition row_e_4_7 = new RowDefinition(); row_e_4_7.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_7); RowDefinition row_e_4_8 = new RowDefinition(); row_e_4_8.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_8); RowDefinition row_e_4_9 = new RowDefinition(); row_e_4_9.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_9); ColumnDefinition col_e_4_0 = new ColumnDefinition(); col_e_4_0.Width = new GridLength(1F, GridUnitType.Auto); e_4.ColumnDefinitions.Add(col_e_4_0); ColumnDefinition col_e_4_1 = new ColumnDefinition(); e_4.ColumnDefinitions.Add(col_e_4_1); // e_5 element TextBlock e_5 = new TextBlock(); e_4.Children.Add(e_5); e_5.Name = "e_5"; e_5.VerticalAlignment = VerticalAlignment.Center; e_5.Text = "Button"; // button1 element Button button1 = new Button(); e_4.Children.Add(button1); button1.Name = "button1"; button1.Height = 30F; button1.Width = 200F; button1.Margin = new Thickness(5F, 5F, 5F, 5F); button1.HorizontalAlignment = HorizontalAlignment.Left; button1.TabIndex = 1; button1.Content = "Button 1"; button1.CommandParameter = "Click Button 1"; Grid.SetColumn(button1, 1); Grid.SetRow(button1, 0); Binding binding_button1_Command = new Binding("ButtonCommand"); button1.SetBinding(Button.CommandProperty, binding_button1_Command); // button2 element Button button2 = new Button(); e_4.Children.Add(button2); button2.Name = "button2"; button2.Height = 30F; button2.Width = 200F; button2.Margin = new Thickness(5F, 5F, 5F, 5F); button2.HorizontalAlignment = HorizontalAlignment.Left; button2.TabIndex = 2; button2.Content = "Button 2"; button2.CommandParameter = "Click Button 2"; Grid.SetColumn(button2, 1); Grid.SetRow(button2, 1); Binding binding_button2_IsEnabled = new Binding("ButtonEnabled"); button2.SetBinding(Button.IsEnabledProperty, binding_button2_IsEnabled); Binding binding_button2_Command = new Binding("ButtonCommand"); button2.SetBinding(Button.CommandProperty, binding_button2_Command); // buttonResult element TextBlock buttonResult = new TextBlock(); e_4.Children.Add(buttonResult); buttonResult.Name = "buttonResult"; buttonResult.HorizontalAlignment = HorizontalAlignment.Left; Grid.SetColumn(buttonResult, 1); Grid.SetRow(buttonResult, 2); Binding binding_buttonResult_Text = new Binding("ButtonResult"); buttonResult.SetBinding(TextBlock.TextProperty, binding_buttonResult_Text); // e_6 element TextBlock e_6 = new TextBlock(); e_4.Children.Add(e_6); e_6.Name = "e_6"; e_6.VerticalAlignment = VerticalAlignment.Center; e_6.Text = "CheckBox"; Grid.SetRow(e_6, 3); // checkBox element CheckBox checkBox = new CheckBox(); e_4.Children.Add(checkBox); checkBox.Name = "checkBox"; checkBox.Margin = new Thickness(5F, 5F, 5F, 5F); checkBox.HorizontalAlignment = HorizontalAlignment.Left; checkBox.TabIndex = 3; checkBox.Content = "Check Box"; Grid.SetColumn(checkBox, 1); Grid.SetRow(checkBox, 3); // e_7 element TextBlock e_7 = new TextBlock(); e_4.Children.Add(e_7); e_7.Name = "e_7"; e_7.VerticalAlignment = VerticalAlignment.Center; e_7.Text = "ProgressBar"; Grid.SetRow(e_7, 4); // e_8 element ProgressBar e_8 = new ProgressBar(); e_4.Children.Add(e_8); e_8.Name = "e_8"; e_8.Height = 30F; e_8.Width = 200F; e_8.Margin = new Thickness(5F, 5F, 5F, 5F); e_8.HorizontalAlignment = HorizontalAlignment.Left; Grid.SetColumn(e_8, 1); Grid.SetRow(e_8, 4); Binding binding_e_8_Value = new Binding("ProgressValue"); e_8.SetBinding(ProgressBar.ValueProperty, binding_e_8_Value); // e_9 element TextBlock e_9 = new TextBlock(); e_4.Children.Add(e_9); e_9.Name = "e_9"; e_9.VerticalAlignment = VerticalAlignment.Center; e_9.Text = "Slider"; Grid.SetRow(e_9, 5); // slider element Slider slider = new Slider(); e_4.Children.Add(slider); slider.Name = "slider"; slider.Width = 200F; slider.HorizontalAlignment = HorizontalAlignment.Left; slider.TabIndex = 4; slider.Minimum = 5F; slider.Maximum = 20F; Grid.SetColumn(slider, 1); Grid.SetRow(slider, 5); Binding binding_slider_Value = new Binding("SliderValue"); slider.SetBinding(Slider.ValueProperty, binding_slider_Value); // e_10 element TextBlock e_10 = new TextBlock(); e_4.Children.Add(e_10); e_10.Name = "e_10"; e_10.VerticalAlignment = VerticalAlignment.Center; e_10.Text = "TextBox"; Grid.SetRow(e_10, 6); // textBox element TextBox textBox = new TextBox(); e_4.Children.Add(textBox); textBox.Name = "textBox"; textBox.Width = 200F; textBox.Margin = new Thickness(5F, 5F, 5F, 5F); textBox.HorizontalAlignment = HorizontalAlignment.Left; textBox.TabIndex = 5; Grid.SetColumn(textBox, 1); Grid.SetRow(textBox, 6); Binding binding_textBox_Text = new Binding("TextBoxText"); textBox.SetBinding(TextBox.TextProperty, binding_textBox_Text); // e_11 element TextBlock e_11 = new TextBlock(); e_4.Children.Add(e_11); e_11.Name = "e_11"; e_11.VerticalAlignment = VerticalAlignment.Center; e_11.Text = "PasswordBox"; Grid.SetRow(e_11, 7); // e_12 element PasswordBox e_12 = new PasswordBox(); e_4.Children.Add(e_12); e_12.Name = "e_12"; e_12.Width = 200F; e_12.Margin = new Thickness(5F, 5F, 5F, 5F); e_12.HorizontalAlignment = HorizontalAlignment.Left; e_12.TabIndex = 6; Grid.SetColumn(e_12, 1); Grid.SetRow(e_12, 7); // e_13 element TextBlock e_13 = new TextBlock(); e_4.Children.Add(e_13); e_13.Name = "e_13"; e_13.VerticalAlignment = VerticalAlignment.Center; e_13.Text = "ComboBox"; Grid.SetRow(e_13, 8); // combo element ComboBox combo = new ComboBox(); e_4.Children.Add(combo); combo.Name = "combo"; combo.Width = 200F; combo.Margin = new Thickness(5F, 5F, 5F, 5F); combo.HorizontalAlignment = HorizontalAlignment.Left; combo.TabIndex = 7; combo.ItemsSource = Get_combo_Items(); combo.SelectedIndex = 2; Grid.SetColumn(combo, 1); Grid.SetRow(combo, 8); // e_14 element TextBlock e_14 = new TextBlock(); e_4.Children.Add(e_14); e_14.Name = "e_14"; e_14.VerticalAlignment = VerticalAlignment.Center; e_14.Text = "ListBox"; Grid.SetRow(e_14, 9); // e_15 element ListBox e_15 = new ListBox(); e_4.Children.Add(e_15); e_15.Name = "e_15"; e_15.TabIndex = 8; e_15.ItemsSource = Get_e_15_Items(); Grid.SetColumn(e_15, 1); Grid.SetRow(e_15, 9); items.Add(e_3); // e_22 element TabItem e_22 = new TabItem(); e_22.Name = "e_22"; e_22.Header = "DataGrid"; // e_23 element DataGrid e_23 = new DataGrid(); e_22.Content = e_23; e_23.Name = "e_23"; e_23.AutoGenerateColumns = false; DataGridTextColumn e_23_Col0 = new DataGridTextColumn(); e_23_Col0.Header = "#"; Binding e_23_Col0_b = new Binding("Number"); e_23_Col0.Binding = e_23_Col0_b; e_23.Columns.Add(e_23_Col0); DataGridTextColumn e_23_Col1 = new DataGridTextColumn(); e_23_Col1.Header = "Text"; Style e_23_Col1_e_s = new Style(typeof(DataGridCell)); Setter e_23_Col1_e_s_S_0 = new Setter(DataGridCell.BackgroundProperty, new SolidColorBrush(new ColorW(128, 128, 128, 255))); e_23_Col1_e_s.Setters.Add(e_23_Col1_e_s_S_0); Setter e_23_Col1_e_s_S_1 = new Setter(DataGridCell.HorizontalAlignmentProperty, HorizontalAlignment.Center); e_23_Col1_e_s.Setters.Add(e_23_Col1_e_s_S_1); Setter e_23_Col1_e_s_S_2 = new Setter(DataGridCell.VerticalAlignmentProperty, VerticalAlignment.Center); e_23_Col1_e_s.Setters.Add(e_23_Col1_e_s_S_2); e_23_Col1.ElementStyle = e_23_Col1_e_s; Binding e_23_Col1_b = new Binding("Text"); e_23_Col1.Binding = e_23_Col1_b; e_23.Columns.Add(e_23_Col1); DataGridCheckBoxColumn e_23_Col2 = new DataGridCheckBoxColumn(); e_23_Col2.Header = "Bool"; Binding e_23_Col2_b = new Binding("Boolean"); e_23_Col2.Binding = e_23_Col2_b; e_23.Columns.Add(e_23_Col2); DataGridTemplateColumn e_23_Col3 = new DataGridTemplateColumn(); e_23_Col3.Width = 200F; // e_24 element TextBlock e_24 = new TextBlock(); e_24.Name = "e_24"; e_24.Text = "Template Column"; e_23_Col3.Header = e_24; Style e_23_Col3_h_s = new Style(typeof(DataGridColumnHeader)); Setter e_23_Col3_h_s_S_0 = new Setter(DataGridColumnHeader.ForegroundProperty, new SolidColorBrush(new ColorW(255, 165, 0, 255))); e_23_Col3_h_s.Setters.Add(e_23_Col3_h_s_S_0); e_23_Col3.HeaderStyle = e_23_Col3_h_s; Func<UIElement, UIElement> e_23_Col3_ct_dtFunc = e_23_Col3_ct_dtMethod; e_23_Col3.CellTemplate = new DataTemplate(e_23_Col3_ct_dtFunc); e_23.Columns.Add(e_23_Col3); Binding binding_e_23_ItemsSource = new Binding("GridData"); e_23.SetBinding(DataGrid.ItemsSourceProperty, binding_e_23_ItemsSource); items.Add(e_22); // e_30 element TabItem e_30 = new TabItem(); e_30.Name = "e_30"; e_30.Header = "TreeView"; // e_31 element TreeView e_31 = new TreeView(); e_30.Content = e_31; e_31.Name = "e_31"; Binding binding_e_31_ItemsSource = new Binding("TreeItems"); e_31.SetBinding(TreeView.ItemsSourceProperty, binding_e_31_ItemsSource); items.Add(e_30); // e_32 element TabItem e_32 = new TabItem(); e_32.Name = "e_32"; e_32.Header = "Shapes"; // e_33 element Grid e_33 = new Grid(); e_32.Content = e_33; e_33.Name = "e_33"; RowDefinition row_e_33_0 = new RowDefinition(); e_33.RowDefinitions.Add(row_e_33_0); RowDefinition row_e_33_1 = new RowDefinition(); e_33.RowDefinitions.Add(row_e_33_1); RowDefinition row_e_33_2 = new RowDefinition(); e_33.RowDefinitions.Add(row_e_33_2); ColumnDefinition col_e_33_0 = new ColumnDefinition(); e_33.ColumnDefinitions.Add(col_e_33_0); ColumnDefinition col_e_33_1 = new ColumnDefinition(); e_33.ColumnDefinitions.Add(col_e_33_1); ColumnDefinition col_e_33_2 = new ColumnDefinition(); e_33.ColumnDefinitions.Add(col_e_33_2); // e_34 element Rectangle e_34 = new Rectangle(); e_33.Children.Add(e_34); e_34.Name = "e_34"; e_34.Height = 100F; e_34.Width = 200F; e_34.Margin = new Thickness(5F, 5F, 5F, 5F); e_34.Fill = new SolidColorBrush(new ColorW(0, 128, 0, 255)); e_34.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255)); e_34.StrokeThickness = 5F; e_34.RadiusX = 10F; e_34.RadiusY = 10F; // e_35 element Rectangle e_35 = new Rectangle(); e_33.Children.Add(e_35); e_35.Name = "e_35"; e_35.Height = 100F; e_35.Width = 200F; e_35.Margin = new Thickness(5F, 5F, 5F, 5F); e_35.Fill = new SolidColorBrush(new ColorW(255, 165, 0, 255)); Grid.SetColumn(e_35, 1); // e_36 element Rectangle e_36 = new Rectangle(); e_33.Children.Add(e_36); e_36.Name = "e_36"; e_36.Height = 100F; e_36.Width = 200F; e_36.Margin = new Thickness(5F, 5F, 5F, 5F); LinearGradientBrush e_36_Fill = new LinearGradientBrush(); e_36_Fill.StartPoint = new PointF(0F, 0F); e_36_Fill.EndPoint = new PointF(1F, 1F); e_36_Fill.SpreadMethod = GradientSpreadMethod.Pad; e_36_Fill.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0.5F)); e_36_Fill.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0F)); e_36.Fill = e_36_Fill; LinearGradientBrush e_36_Stroke = new LinearGradientBrush(); e_36_Stroke.StartPoint = new PointF(0F, 0F); e_36_Stroke.EndPoint = new PointF(1F, 1F); e_36_Stroke.SpreadMethod = GradientSpreadMethod.Pad; e_36_Stroke.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0.5F)); e_36_Stroke.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0F)); e_36.Stroke = e_36_Stroke; e_36.StrokeThickness = 5F; e_36.RadiusX = 10F; e_36.RadiusY = 10F; Grid.SetColumn(e_36, 2); // e_37 element Ellipse e_37 = new Ellipse(); e_33.Children.Add(e_37); e_37.Name = "e_37"; e_37.Height = 100F; e_37.Width = 200F; e_37.Margin = new Thickness(5F, 5F, 5F, 5F); e_37.Fill = new SolidColorBrush(new ColorW(128, 128, 128, 255)); e_37.Stroke = new SolidColorBrush(new ColorW(0, 128, 0, 255)); e_37.StrokeThickness = 10F; Grid.SetRow(e_37, 1); // e_38 element Ellipse e_38 = new Ellipse(); e_33.Children.Add(e_38); e_38.Name = "e_38"; e_38.Height = 100F; e_38.Width = 200F; e_38.Margin = new Thickness(5F, 5F, 5F, 5F); e_38.Stroke = new SolidColorBrush(new ColorW(255, 165, 0, 255)); e_38.StrokeThickness = 10F; Grid.SetColumn(e_38, 1); Grid.SetRow(e_38, 1); // e_39 element Ellipse e_39 = new Ellipse(); e_33.Children.Add(e_39); e_39.Name = "e_39"; e_39.Height = 100F; e_39.Width = 200F; e_39.Margin = new Thickness(5F, 5F, 5F, 5F); LinearGradientBrush e_39_Fill = new LinearGradientBrush(); e_39_Fill.StartPoint = new PointF(0F, 0F); e_39_Fill.EndPoint = new PointF(1F, 1F); e_39_Fill.SpreadMethod = GradientSpreadMethod.Pad; e_39_Fill.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0.5F)); e_39_Fill.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0F)); e_39.Fill = e_39_Fill; LinearGradientBrush e_39_Stroke = new LinearGradientBrush(); e_39_Stroke.StartPoint = new PointF(0F, 0F); e_39_Stroke.EndPoint = new PointF(1F, 1F); e_39_Stroke.SpreadMethod = GradientSpreadMethod.Pad; e_39_Stroke.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0.5F)); e_39_Stroke.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0F)); e_39.Stroke = e_39_Stroke; e_39.StrokeThickness = 10F; Grid.SetColumn(e_39, 2); Grid.SetRow(e_39, 1); // e_40 element Line e_40 = new Line(); e_33.Children.Add(e_40); e_40.Name = "e_40"; e_40.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255)); e_40.StrokeThickness = 10F; e_40.X1 = 10F; e_40.X2 = 150F; e_40.Y1 = 10F; e_40.Y2 = 150F; Grid.SetRow(e_40, 2); // e_41 element Line e_41 = new Line(); e_33.Children.Add(e_41); e_41.Name = "e_41"; e_41.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255)); e_41.StrokeThickness = 10F; e_41.X1 = 100F; e_41.X2 = 100F; e_41.Y1 = 10F; e_41.Y2 = 100F; Grid.SetRow(e_41, 2); // e_42 element Line e_42 = new Line(); e_33.Children.Add(e_42); e_42.Name = "e_42"; e_42.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255)); e_42.StrokeThickness = 10F; e_42.X1 = 10F; e_42.X2 = 100F; e_42.Y1 = 100F; e_42.Y2 = 100F; Grid.SetRow(e_42, 2); // e_43 element Rectangle e_43 = new Rectangle(); e_33.Children.Add(e_43); e_43.Name = "e_43"; e_43.Height = 100F; e_43.Width = 200F; e_43.Margin = new Thickness(5F, 5F, 5F, 5F); ImageBrush e_43_Fill = new ImageBrush(); BitmapImage e_43_Fill_bm = new BitmapImage(); e_43_Fill_bm.TextureAsset = "Images/MonoGameLogo"; e_43_Fill.ImageSource = e_43_Fill_bm; e_43_Fill.Stretch = Stretch.None; e_43.Fill = e_43_Fill; e_43.Stroke = new SolidColorBrush(new ColorW(255, 255, 255, 255)); e_43.StrokeThickness = 1F; e_43.RadiusX = 10F; e_43.RadiusY = 10F; Grid.SetColumn(e_43, 1); Grid.SetRow(e_43, 2); items.Add(e_32); // e_44 element TabItem e_44 = new TabItem(); e_44.Name = "e_44"; e_44.Header = "Animations"; // e_45 element Grid e_45 = new Grid(); e_44.Content = e_45; e_45.Name = "e_45"; ColumnDefinition col_e_45_0 = new ColumnDefinition(); e_45.ColumnDefinitions.Add(col_e_45_0); ColumnDefinition col_e_45_1 = new ColumnDefinition(); e_45.ColumnDefinitions.Add(col_e_45_1); // e_46 element StackPanel e_46 = new StackPanel(); e_45.Children.Add(e_46); e_46.Name = "e_46"; // animButton1 element Button animButton1 = new Button(); e_46.Children.Add(animButton1); animButton1.Name = "animButton1"; animButton1.TabIndex = 1; animButton1.Content = "Mouse Over me!"; animButton1.SetResourceReference(Button.StyleProperty, "buttonAnimStyle"); // animButton2 element Button animButton2 = new Button(); e_46.Children.Add(animButton2); animButton2.Name = "animButton2"; animButton2.TabIndex = 2; animButton2.Content = "Mouse Over me!"; animButton2.SetResourceReference(Button.StyleProperty, "buttonAnimStyle"); // animButton3 element Button animButton3 = new Button(); e_46.Children.Add(animButton3); animButton3.Name = "animButton3"; animButton3.TabIndex = 3; animButton3.Content = "Mouse Over me!"; animButton3.SetResourceReference(Button.StyleProperty, "buttonAnimStyle"); // animButton4 element Button animButton4 = new Button(); e_46.Children.Add(animButton4); animButton4.Name = "animButton4"; animButton4.TabIndex = 4; animButton4.Content = "Mouse Over me!"; animButton4.SetResourceReference(Button.StyleProperty, "buttonAnimStyle"); // animBorder1 element Border animBorder1 = new Border(); e_45.Children.Add(animBorder1); animBorder1.Name = "animBorder1"; animBorder1.Height = 100F; animBorder1.Width = 200F; animBorder1.Margin = new Thickness(0F, 10F, 0F, 10F); animBorder1.VerticalAlignment = VerticalAlignment.Top; EventTrigger animBorder1_ET_0 = new EventTrigger(Border.LoadedEvent, animBorder1); animBorder1.Triggers.Add(animBorder1_ET_0); BeginStoryboard animBorder1_ET_0_AC_0 = new BeginStoryboard(); animBorder1_ET_0_AC_0.Name = "animBorder1_ET_0_AC_0"; animBorder1_ET_0.AddAction(animBorder1_ET_0_AC_0); Storyboard animBorder1_ET_0_AC_0_SB = new Storyboard(); animBorder1_ET_0_AC_0.Storyboard = animBorder1_ET_0_AC_0_SB; animBorder1_ET_0_AC_0_SB.Name = "animBorder1_ET_0_AC_0_SB"; SolidColorBrushAnimation animBorder1_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation(); animBorder1_ET_0_AC_0_SB_TL_0.Name = "animBorder1_ET_0_AC_0_SB_TL_0"; animBorder1_ET_0_AC_0_SB_TL_0.AutoReverse = true; animBorder1_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 5, 0)); animBorder1_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever; animBorder1_ET_0_AC_0_SB_TL_0.From = new ColorW(255, 255, 0, 255); animBorder1_ET_0_AC_0_SB_TL_0.To = new ColorW(0, 0, 255, 255); ExponentialEase animBorder1_ET_0_AC_0_SB_TL_0_EA = new ExponentialEase(); animBorder1_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder1_ET_0_AC_0_SB_TL_0_EA; Storyboard.SetTargetName(animBorder1_ET_0_AC_0_SB_TL_0, "animBorder1"); Storyboard.SetTargetProperty(animBorder1_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty); animBorder1_ET_0_AC_0_SB.Children.Add(animBorder1_ET_0_AC_0_SB_TL_0); Grid.SetColumn(animBorder1, 1); // animBorder2 element Border animBorder2 = new Border(); e_45.Children.Add(animBorder2); animBorder2.Name = "animBorder2"; animBorder2.Height = 50F; animBorder2.Width = 100F; animBorder2.Margin = new Thickness(50F, 35F, 50F, 35F); animBorder2.VerticalAlignment = VerticalAlignment.Top; EventTrigger animBorder2_ET_0 = new EventTrigger(Border.LoadedEvent, animBorder2); animBorder2.Triggers.Add(animBorder2_ET_0); BeginStoryboard animBorder2_ET_0_AC_0 = new BeginStoryboard(); animBorder2_ET_0_AC_0.Name = "animBorder2_ET_0_AC_0"; animBorder2_ET_0.AddAction(animBorder2_ET_0_AC_0); Storyboard animBorder2_ET_0_AC_0_SB = new Storyboard(); animBorder2_ET_0_AC_0.Storyboard = animBorder2_ET_0_AC_0_SB; animBorder2_ET_0_AC_0_SB.Name = "animBorder2_ET_0_AC_0_SB"; SolidColorBrushAnimation animBorder2_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation(); animBorder2_ET_0_AC_0_SB_TL_0.Name = "animBorder2_ET_0_AC_0_SB_TL_0"; animBorder2_ET_0_AC_0_SB_TL_0.AutoReverse = true; animBorder2_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 3, 0)); animBorder2_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever; animBorder2_ET_0_AC_0_SB_TL_0.From = new ColorW(255, 0, 0, 255); animBorder2_ET_0_AC_0_SB_TL_0.To = new ColorW(255, 255, 255, 255); CubicEase animBorder2_ET_0_AC_0_SB_TL_0_EA = new CubicEase(); animBorder2_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder2_ET_0_AC_0_SB_TL_0_EA; Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_0, "animBorder2"); Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty); animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_0); FloatAnimation animBorder2_ET_0_AC_0_SB_TL_1 = new FloatAnimation(); animBorder2_ET_0_AC_0_SB_TL_1.Name = "animBorder2_ET_0_AC_0_SB_TL_1"; animBorder2_ET_0_AC_0_SB_TL_1.AutoReverse = true; animBorder2_ET_0_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 4, 0)); animBorder2_ET_0_AC_0_SB_TL_1.RepeatBehavior = RepeatBehavior.Forever; animBorder2_ET_0_AC_0_SB_TL_1.From = 1F; animBorder2_ET_0_AC_0_SB_TL_1.To = 0F; Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_1, "animBorder2"); Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_1, Border.OpacityProperty); animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_1); Grid.SetColumn(animBorder2, 1); items.Add(e_44); // e_47 element TabItem e_47 = new TabItem(); e_47.Name = "e_47"; e_47.Header = "Tetris"; // e_48 element Border e_48 = new Border(); e_47.Content = e_48; e_48.Name = "e_48"; // e_49 element Grid e_49 = new Grid(); e_48.Child = e_49; e_49.Name = "e_49"; e_49.Margin = new Thickness(10F, 10F, 10F, 10F); RowDefinition row_e_49_0 = new RowDefinition(); row_e_49_0.Height = new GridLength(1F, GridUnitType.Auto); e_49.RowDefinitions.Add(row_e_49_0); RowDefinition row_e_49_1 = new RowDefinition(); row_e_49_1.Height = new GridLength(420F, GridUnitType.Pixel); e_49.RowDefinitions.Add(row_e_49_1); ColumnDefinition col_e_49_0 = new ColumnDefinition(); e_49.ColumnDefinitions.Add(col_e_49_0); ColumnDefinition col_e_49_1 = new ColumnDefinition(); e_49.ColumnDefinitions.Add(col_e_49_1); ColumnDefinition col_e_49_2 = new ColumnDefinition(); e_49.ColumnDefinitions.Add(col_e_49_2); // e_50 element StackPanel e_50 = new StackPanel(); e_49.Children.Add(e_50); e_50.Name = "e_50"; e_50.HorizontalAlignment = HorizontalAlignment.Right; e_50.Orientation = Orientation.Vertical; Grid.SetRow(e_50, 1); // e_51 element TextBlock e_51 = new TextBlock(); e_50.Children.Add(e_51); e_51.Name = "e_51"; e_51.Text = "Next"; // e_52 element Border e_52 = new Border(); e_50.Children.Add(e_52); e_52.Name = "e_52"; e_52.Height = 81F; e_52.Width = 81F; e_52.BorderBrush = new SolidColorBrush(new ColorW(255, 255, 255, 255)); e_52.BorderThickness = new Thickness(0F, 0F, 1F, 1F); // tetrisNextContainer1 element Canvas tetrisNextContainer1 = new Canvas(); e_52.Child = tetrisNextContainer1; tetrisNextContainer1.Name = "tetrisNextContainer1"; tetrisNextContainer1.Height = 80F; tetrisNextContainer1.Width = 80F; // e_53 element Border e_53 = new Border(); e_49.Children.Add(e_53); e_53.Name = "e_53"; e_53.Height = 401F; e_53.Width = 201F; e_53.BorderBrush = new SolidColorBrush(new ColorW(255, 255, 255, 255)); e_53.BorderThickness = new Thickness(0F, 0F, 1F, 1F); Grid.SetColumn(e_53, 1); Grid.SetRow(e_53, 1); // tetrisContainer1 element Canvas tetrisContainer1 = new Canvas(); e_53.Child = tetrisContainer1; tetrisContainer1.Name = "tetrisContainer1"; tetrisContainer1.Height = 400F; tetrisContainer1.Width = 200F; tetrisContainer1.HorizontalAlignment = HorizontalAlignment.Left; tetrisContainer1.VerticalAlignment = VerticalAlignment.Top; // e_54 element Grid e_54 = new Grid(); e_49.Children.Add(e_54); e_54.Name = "e_54"; RowDefinition row_e_54_0 = new RowDefinition(); row_e_54_0.Height = new GridLength(1F, GridUnitType.Auto); e_54.RowDefinitions.Add(row_e_54_0); RowDefinition row_e_54_1 = new RowDefinition(); row_e_54_1.Height = new GridLength(1F, GridUnitType.Auto); e_54.RowDefinitions.Add(row_e_54_1); ColumnDefinition col_e_54_0 = new ColumnDefinition(); col_e_54_0.Width = new GridLength(1F, GridUnitType.Auto); e_54.ColumnDefinitions.Add(col_e_54_0); ColumnDefinition col_e_54_1 = new ColumnDefinition(); col_e_54_1.Width = new GridLength(1F, GridUnitType.Star); e_54.ColumnDefinitions.Add(col_e_54_1); ColumnDefinition col_e_54_2 = new ColumnDefinition(); col_e_54_2.Width = new GridLength(1F, GridUnitType.Auto); e_54.ColumnDefinitions.Add(col_e_54_2); Grid.SetColumnSpan(e_54, 3); Binding binding_e_54_DataContext = new Binding("Tetris"); e_54.SetBinding(Grid.DataContextProperty, binding_e_54_DataContext); // e_55 element Button e_55 = new Button(); e_54.Children.Add(e_55); e_55.Name = "e_55"; e_55.Height = 30F; e_55.Content = "Start"; Grid.SetColumnSpan(e_55, 3); Binding binding_e_55_Command = new Binding("StartCommand"); e_55.SetBinding(Button.CommandProperty, binding_e_55_Command); // e_56 element Grid e_56 = new Grid(); e_54.Children.Add(e_56); e_56.Name = "e_56"; RowDefinition row_e_56_0 = new RowDefinition(); row_e_56_0.Height = new GridLength(1F, GridUnitType.Auto); e_56.RowDefinitions.Add(row_e_56_0); ColumnDefinition col_e_56_0 = new ColumnDefinition(); e_56.ColumnDefinitions.Add(col_e_56_0); ColumnDefinition col_e_56_1 = new ColumnDefinition(); col_e_56_1.Width = new GridLength(70F, GridUnitType.Pixel); e_56.ColumnDefinitions.Add(col_e_56_1); ColumnDefinition col_e_56_2 = new ColumnDefinition(); e_56.ColumnDefinitions.Add(col_e_56_2); Grid.SetColumn(e_56, 1); Grid.SetRow(e_56, 1); // spPlayer1 element StackPanel spPlayer1 = new StackPanel(); e_56.Children.Add(spPlayer1); spPlayer1.Name = "spPlayer1"; spPlayer1.HorizontalAlignment = HorizontalAlignment.Right; spPlayer1.Orientation = Orientation.Vertical; // e_57 element TextBlock e_57 = new TextBlock(); spPlayer1.Children.Add(e_57); e_57.Name = "e_57"; Binding binding_e_57_Text = new Binding("Score"); e_57.SetBinding(TextBlock.TextProperty, binding_e_57_Text); // e_58 element TextBlock e_58 = new TextBlock(); spPlayer1.Children.Add(e_58); e_58.Name = "e_58"; Binding binding_e_58_Text = new Binding("Lines"); e_58.SetBinding(TextBlock.TextProperty, binding_e_58_Text); // e_59 element TextBlock e_59 = new TextBlock(); spPlayer1.Children.Add(e_59); e_59.Name = "e_59"; Binding binding_e_59_Text = new Binding("Level"); e_59.SetBinding(TextBlock.TextProperty, binding_e_59_Text); // e_60 element StackPanel e_60 = new StackPanel(); e_56.Children.Add(e_60); e_60.Name = "e_60"; e_60.HorizontalAlignment = HorizontalAlignment.Center; e_60.Orientation = Orientation.Vertical; Grid.SetColumn(e_60, 1); // e_61 element TextBlock e_61 = new TextBlock(); e_60.Children.Add(e_61); e_61.Name = "e_61"; e_61.Text = "SCORE"; // e_62 element TextBlock e_62 = new TextBlock(); e_60.Children.Add(e_62); e_62.Name = "e_62"; e_62.Text = "LINES"; // e_63 element TextBlock e_63 = new TextBlock(); e_60.Children.Add(e_63); e_63.Name = "e_63"; e_63.Text = "LEVEL"; // e_64 element StackPanel e_64 = new StackPanel(); e_56.Children.Add(e_64); e_64.Name = "e_64"; e_64.HorizontalAlignment = HorizontalAlignment.Left; e_64.Orientation = Orientation.Horizontal; // e_65 element TextBlock e_65 = new TextBlock(); e_64.Children.Add(e_65); e_65.Name = "e_65"; e_65.Text = "Use A,S,D,W for left, down, right, rotate"; items.Add(e_47); return items; }
/// <summary> /// Instantiates the item on the grid. /// </summary> /// <returns>The GameObject.</returns> /// <param name="item">The Item to instantiate.</param> public GameObject instantiateObject(ItemInventoryBase item) { GameObject tempItem = Instantiate(itemPrefab) as GameObject; tempItem.transform.SetParent(content.transform, false); //adds item as child of the grid tempItem.name = "InventoryItem" + count.ToString(); count++; //copies the data from item to the ItemInventoryBase component tempItem.GetComponent <ItemInventoryBase>().copyData(item); ObjectList.Add(tempItem); changeImage(tempItem); tempItem.gameObject.GetComponent <Button> ().onClick.AddListener(() => this.setSelectedItem(tempItem.GetComponent <ItemInventoryBase>())); //adds click listener on runtime if (item.getItemType() != ItemType.Glassware) { if (item.getItemType() == ItemType.Others) { //TODO: Implement the triggers for products EventTrigger trigger = tempItem.gameObject.GetComponent <EventTrigger> (); EventTrigger.Entry enter = new EventTrigger.Entry(); enter.eventID = EventTriggerType.PointerEnter; //trigger for entering enter.callback.AddListener((eventData) => { if (limbo.Find(item.index).GetComponent <Glassware>() != null) { if (limbo.Find(item.index).GetComponent <Glassware> ().label.Length != 0) { labelRect.gameObject.SetActive(true); labelRect.rotation = Quaternion.Euler(0f, 0f, 0f); labelRect.GetComponentInChildren <Text> ().rectTransform.localRotation = Quaternion.Euler(0f, 0f, 0f); labelRect.GetComponentInChildren <Text> ().text = limbo.Find(item.index).GetComponent <Glassware> ().label; labelRect.transform.position = new Vector2(tempItem.GetComponent <ItemInventoryBase> ().posTab.position.x, tempItem.GetComponent <ItemInventoryBase> ().posTab.position.y - 50.0f); } } /*refreshLabel (item,true); * glasswareLabel.transform.position = tempItem.GetComponent<ItemInventoryBase> ().posTab.position;*/ }); trigger.triggers.Add(enter); //trigger for leaving EventTrigger.Entry exit = new EventTrigger.Entry(); exit.eventID = EventTriggerType.PointerExit; exit.callback.AddListener((eventData) => { //refreshLabel (null,false); labelRect.gameObject.SetActive(false); }); trigger.triggers.Add(exit); } else { //if reagent, adds triggers for info tab EventTrigger trigger = tempItem.gameObject.GetComponent <EventTrigger> (); EventTrigger.Entry enter = new EventTrigger.Entry(); enter.eventID = EventTriggerType.PointerEnter; //trigger for entering enter.callback.AddListener((eventData) => { refreshTab(item, true); actionTab.transform.position = tempItem.GetComponent <ItemInventoryBase> ().posTab.position; }); trigger.triggers.Add(enter); //trigger for leaving EventTrigger.Entry exit = new EventTrigger.Entry(); exit.eventID = EventTriggerType.PointerExit; exit.callback.AddListener((eventData) => { refreshTab(null, false); }); trigger.triggers.Add(exit); } } //returns the instantiated object return(tempItem); }
public EventTrigger GetEventTrigger() { eventCaller = new EventTrigger(eventEntityArchetype, out entityCommandBuffer); return(eventCaller); }
void Start() { eventTrigger = GetComponent <EventTrigger> (); AddEventTrigger(OnPointDown, EventTriggerType.PointerDown); AddEventTrigger(OnPointUp, EventTriggerType.PointerUp); }
private void InitializeComponent() { this.FontSize = 13.33333F; this.SetResourceReference(SoundManager.SoundsProperty, "Sounds"); InitializeElementResources(this); // e_0 element this.e_0 = new Grid(); this.Content = this.e_0; this.e_0.Name = "e_0"; RowDefinition row_e_0_0 = new RowDefinition(); row_e_0_0.Height = new GridLength(110F, GridUnitType.Pixel); this.e_0.RowDefinitions.Add(row_e_0_0); RowDefinition row_e_0_1 = new RowDefinition(); this.e_0.RowDefinitions.Add(row_e_0_1); ColumnDefinition col_e_0_0 = new ColumnDefinition(); this.e_0.ColumnDefinitions.Add(col_e_0_0); ColumnDefinition col_e_0_1 = new ColumnDefinition(); this.e_0.ColumnDefinitions.Add(col_e_0_1); // e_1 element this.e_1 = new StackPanel(); this.e_0.Children.Add(this.e_1); this.e_1.Name = "e_1"; this.e_1.Background = new SolidColorBrush(new ColorW(0, 0, 0, 255)); Grid.SetColumnSpan(this.e_1, 2); // logo element this.logo = new Image(); this.e_1.Children.Add(this.logo); this.logo.Name = "logo"; this.logo.HorizontalAlignment = HorizontalAlignment.Center; BitmapImage logo_bm = new BitmapImage(); logo_bm.TextureAsset = "Images/EmptyKeysLogoTextSmall"; this.logo.Source = logo_bm; this.logo.Stretch = Stretch.None; this.logo.SetResourceReference(Image.SourceProperty, "logoEmptyKeys"); // e_2 element this.e_2 = new TextBlock(); this.e_1.Children.Add(this.e_2); this.e_2.Name = "e_2"; this.e_2.HorizontalAlignment = HorizontalAlignment.Center; this.e_2.VerticalAlignment = VerticalAlignment.Center; this.e_2.Foreground = new SolidColorBrush(new ColorW(211, 211, 211, 255)); this.e_2.TextWrapping = TextWrapping.Wrap; this.e_2.FontFamily = new FontFamily("Segoe UI"); this.e_2.FontSize = 20F; this.e_2.FontStyle = FontStyle.Bold; this.e_2.SetResourceReference(TextBlock.TextProperty, "TitleResource"); // e_3 element this.e_3 = new StackPanel(); this.e_0.Children.Add(this.e_3); this.e_3.Name = "e_3"; Grid.SetRow(this.e_3, 1); // combo element this.combo = new ComboBox(); this.e_3.Children.Add(this.combo); this.combo.Name = "combo"; this.combo.Width = 200F; this.combo.Margin = new Thickness(5F, 5F, 5F, 5F); Func<UIElement, UIElement> combo_dtFunc = combo_dtMethod; this.combo.ItemTemplate = new DataTemplate(combo_dtFunc); Binding binding_combo_ItemsSource = new Binding("ComboBoxSource"); this.combo.SetBinding(ComboBox.ItemsSourceProperty, binding_combo_ItemsSource); Binding binding_combo_SelectedIndex = new Binding("SelectedIndex"); this.combo.SetBinding(ComboBox.SelectedIndexProperty, binding_combo_SelectedIndex); // button1 element this.button1 = new Button(); this.e_3.Children.Add(this.button1); this.button1.Name = "button1"; this.button1.Height = 30F; this.button1.Width = 200F; this.button1.Margin = new Thickness(5F, 5F, 5F, 5F); ToolTip tt_button1 = new ToolTip(); this.button1.ToolTip = tt_button1; tt_button1.Content = "Click Me!"; this.button1.Content = "1"; this.button1.CommandParameter = "Click Button 1"; Binding binding_button1_Command = new Binding("ButtonCommand"); this.button1.SetBinding(Button.CommandProperty, binding_button1_Command); // button2 element this.button2 = new Button(); this.e_3.Children.Add(this.button2); this.button2.Name = "button2"; this.button2.Height = 30F; this.button2.Margin = new Thickness(5F, 5F, 5F, 5F); this.button2.Content = "2"; this.button2.CommandParameter = "Click Button 2"; Binding binding_button2_Command = new Binding("ButtonCommand"); this.button2.SetBinding(Button.CommandProperty, binding_button2_Command); this.button2.SetResourceReference(Button.StyleProperty, "buttonStyle"); // button3 element this.button3 = new Button(); this.e_3.Children.Add(this.button3); this.button3.Name = "button3"; this.button3.Height = 30F; this.button3.Width = 200F; this.button3.Margin = new Thickness(5F, 5F, 5F, 5F); this.button3.FontFamily = new FontFamily("Segoe UI"); this.button3.FontSize = 20F; this.button3.FontStyle = FontStyle.Bold; this.button3.Content = "3"; this.button3.CommandParameter = "Click Button 3"; Binding binding_button3_Command = new Binding("OpenMessageBox"); this.button3.SetBinding(Button.CommandProperty, binding_button3_Command); this.button3.SetResourceReference(Button.ToolTipProperty, "ToolTipText"); // buttonResult element this.buttonResult = new TextBlock(); this.e_3.Children.Add(this.buttonResult); this.buttonResult.Name = "buttonResult"; this.buttonResult.HorizontalAlignment = HorizontalAlignment.Center; Binding binding_buttonResult_Text = new Binding("ButtonResult"); this.buttonResult.SetBinding(TextBlock.TextProperty, binding_buttonResult_Text); // slider element this.slider = new Slider(); this.e_3.Children.Add(this.slider); this.slider.Name = "slider"; this.slider.Width = 200F; this.slider.Minimum = 5F; this.slider.Maximum = 20F; Binding binding_slider_Value = new Binding("SliderValue"); this.slider.SetBinding(Slider.ValueProperty, binding_slider_Value); // textBox element this.textBox = new TextBox(); this.e_3.Children.Add(this.textBox); this.textBox.Name = "textBox"; this.textBox.Width = 200F; this.textBox.Margin = new Thickness(5F, 5F, 5F, 5F); Binding binding_textBox_Text = new Binding("TextBoxText"); this.textBox.SetBinding(TextBox.TextProperty, binding_textBox_Text); // checkBox element this.checkBox = new CheckBox(); this.e_3.Children.Add(this.checkBox); this.checkBox.Name = "checkBox"; this.checkBox.Margin = new Thickness(5F, 5F, 5F, 5F); this.checkBox.HorizontalAlignment = HorizontalAlignment.Center; this.checkBox.Content = "Check Box"; // e_5 element this.e_5 = new TabControl(); this.e_3.Children.Add(this.e_5); this.e_5.Name = "e_5"; this.e_5.Height = 150F; this.e_5.Width = 400F; this.e_5.ItemsSource = Get_e_5_Items(); // e_18 element this.e_18 = new ProgressBar(); this.e_3.Children.Add(this.e_18); this.e_18.Name = "e_18"; this.e_18.Height = 30F; this.e_18.Width = 400F; this.e_18.Margin = new Thickness(5F, 5F, 5F, 5F); this.e_18.Value = 39F; // imageButton element this.imageButton = new Button(); this.e_3.Children.Add(this.imageButton); this.imageButton.Name = "imageButton"; this.imageButton.Height = 68F; this.imageButton.Width = 57F; ImageBrush imageButton_Background = new ImageBrush(); BitmapImage imageButton_Background_bm = new BitmapImage(); imageButton_Background_bm.TextureAsset = "Images/SunBurn"; imageButton_Background.ImageSource = imageButton_Background_bm; imageButton_Background.Stretch = Stretch.None; this.imageButton.Background = imageButton_Background; // e_19 element this.e_19 = new StackPanel(); this.e_0.Children.Add(this.e_19); this.e_19.Name = "e_19"; Grid.SetColumn(this.e_19, 1); Grid.SetRow(this.e_19, 1); // animButton1 element this.animButton1 = new Button(); this.e_19.Children.Add(this.animButton1); this.animButton1.Name = "animButton1"; this.animButton1.Content = "Mouse Over me!"; this.animButton1.SetResourceReference(Button.StyleProperty, "buttonAnimStyle"); // animButton2 element this.animButton2 = new Button(); this.e_19.Children.Add(this.animButton2); this.animButton2.Name = "animButton2"; this.animButton2.Content = "Mouse Over me!"; this.animButton2.SetResourceReference(Button.StyleProperty, "buttonAnimStyle"); // animButton3 element this.animButton3 = new Button(); this.e_19.Children.Add(this.animButton3); this.animButton3.Name = "animButton3"; this.animButton3.Content = "Mouse Over me!"; this.animButton3.SetResourceReference(Button.StyleProperty, "buttonAnimStyle"); // animButton4 element this.animButton4 = new Button(); this.e_19.Children.Add(this.animButton4); this.animButton4.Name = "animButton4"; this.animButton4.Content = "Mouse Over me!"; this.animButton4.SetResourceReference(Button.StyleProperty, "buttonAnimStyle"); // e_20 element this.e_20 = new Grid(); this.e_19.Children.Add(this.e_20); this.e_20.Name = "e_20"; // animBorder1 element this.animBorder1 = new Border(); this.e_20.Children.Add(this.animBorder1); this.animBorder1.Name = "animBorder1"; this.animBorder1.Height = 100F; this.animBorder1.Width = 200F; this.animBorder1.Margin = new Thickness(0F, 10F, 0F, 10F); EventTrigger animBorder1_ET_0 = new EventTrigger(Border.LoadedEvent, this.animBorder1); animBorder1.Triggers.Add(animBorder1_ET_0); BeginStoryboard animBorder1_ET_0_AC_0 = new BeginStoryboard(); animBorder1_ET_0_AC_0.Name = "animBorder1_ET_0_AC_0"; animBorder1_ET_0.AddAction(animBorder1_ET_0_AC_0); Storyboard animBorder1_ET_0_AC_0_SB = new Storyboard(); animBorder1_ET_0_AC_0.Storyboard = animBorder1_ET_0_AC_0_SB; animBorder1_ET_0_AC_0_SB.Name = "animBorder1_ET_0_AC_0_SB"; SolidColorBrushAnimation animBorder1_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation(); animBorder1_ET_0_AC_0_SB_TL_0.Name = "animBorder1_ET_0_AC_0_SB_TL_0"; animBorder1_ET_0_AC_0_SB_TL_0.AutoReverse = true; animBorder1_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 5, 0)); animBorder1_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever; animBorder1_ET_0_AC_0_SB_TL_0.From = new ColorW(255, 255, 0, 255); animBorder1_ET_0_AC_0_SB_TL_0.To = new ColorW(0, 0, 255, 255); ExponentialEase animBorder1_ET_0_AC_0_SB_TL_0_EA = new ExponentialEase(); animBorder1_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder1_ET_0_AC_0_SB_TL_0_EA; Storyboard.SetTargetName(animBorder1_ET_0_AC_0_SB_TL_0, "animBorder1"); Storyboard.SetTargetProperty(animBorder1_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty); animBorder1_ET_0_AC_0_SB.Children.Add(animBorder1_ET_0_AC_0_SB_TL_0); // animBorder2 element this.animBorder2 = new Border(); this.e_20.Children.Add(this.animBorder2); this.animBorder2.Name = "animBorder2"; this.animBorder2.Height = 50F; this.animBorder2.Width = 100F; this.animBorder2.Margin = new Thickness(50F, 35F, 50F, 35F); EventTrigger animBorder2_ET_0 = new EventTrigger(Border.LoadedEvent, this.animBorder2); animBorder2.Triggers.Add(animBorder2_ET_0); BeginStoryboard animBorder2_ET_0_AC_0 = new BeginStoryboard(); animBorder2_ET_0_AC_0.Name = "animBorder2_ET_0_AC_0"; animBorder2_ET_0.AddAction(animBorder2_ET_0_AC_0); Storyboard animBorder2_ET_0_AC_0_SB = new Storyboard(); animBorder2_ET_0_AC_0.Storyboard = animBorder2_ET_0_AC_0_SB; animBorder2_ET_0_AC_0_SB.Name = "animBorder2_ET_0_AC_0_SB"; SolidColorBrushAnimation animBorder2_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation(); animBorder2_ET_0_AC_0_SB_TL_0.Name = "animBorder2_ET_0_AC_0_SB_TL_0"; animBorder2_ET_0_AC_0_SB_TL_0.AutoReverse = true; animBorder2_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 3, 0)); animBorder2_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever; animBorder2_ET_0_AC_0_SB_TL_0.From = new ColorW(255, 0, 0, 255); animBorder2_ET_0_AC_0_SB_TL_0.To = new ColorW(255, 255, 255, 255); CubicEase animBorder2_ET_0_AC_0_SB_TL_0_EA = new CubicEase(); animBorder2_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder2_ET_0_AC_0_SB_TL_0_EA; Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_0, "animBorder2"); Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty); animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_0); FloatAnimation animBorder2_ET_0_AC_0_SB_TL_1 = new FloatAnimation(); animBorder2_ET_0_AC_0_SB_TL_1.Name = "animBorder2_ET_0_AC_0_SB_TL_1"; animBorder2_ET_0_AC_0_SB_TL_1.AutoReverse = true; animBorder2_ET_0_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 4, 0)); animBorder2_ET_0_AC_0_SB_TL_1.RepeatBehavior = RepeatBehavior.Forever; animBorder2_ET_0_AC_0_SB_TL_1.From = 1F; animBorder2_ET_0_AC_0_SB_TL_1.To = 0F; Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_1, "animBorder2"); Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_1, Border.OpacityProperty); animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_1); ImageManager.Instance.AddImage("Images/EmptyKeysLogoTextSmall"); ImageManager.Instance.AddImage("Images/SunBurn"); FontManager.Instance.AddFont("Segoe UI", 13.33333F, FontStyle.Regular, "Segoe_UI_10_Regular"); FontManager.Instance.AddFont("Segoe UI", 20F, FontStyle.Bold, "Segoe_UI_15_Bold"); FontManager.Instance.AddFont("Segoe UI", 12F, FontStyle.Regular, "Segoe_UI_9_Regular"); }
void Awake() { this.eventTrigger = this.GetComponent <EventTrigger> (); }
public void EnterEventTrigger(EventTrigger e) { _speakEventIcon.SetActive(true); _toSpeak = e; }
public LoginPage() { #region Binding Context ViewModel = new LoginViewModel(); BindingContext = ViewModel.UserModel; #endregion //BackgroundImage = "backImage.png"; BackgroundColor = Color.Red; #region Set Few Properties on the Page Padding = new Thickness(20); Title = "Login"; #endregion #region Using Triggers var emailValTrig = new EventTrigger(); emailValTrig.Event = "TextChanged"; emailValTrig.Actions.Add(new EmailValidationTrigger()); //Password var passwordValTrig = new EventTrigger(); passwordValTrig.Event = "TextChanged"; passwordValTrig.Actions.Add(new EmptyTextValidation()); #endregion #region Create some Entry controls to capture username and password. Entry loginInput = new Entry { Placeholder = "User Name" }; loginInput.SetBinding(Entry.TextProperty, "UserName"); loginInput.Triggers.Add(emailValTrig); Entry passwordInput = new Entry { IsPassword = true, Placeholder = "Password" }; passwordInput.SetBinding(Entry.TextProperty, "Password"); passwordInput.Triggers.Add(passwordValTrig); #endregion #region Create a button to login with Button loginButton = new Button { Text = "Login", BorderRadius = 5, TextColor = Color.White, BackgroundColor = Color.Gray, Command = ViewModel.SelectionChangedCommand }; // loginButton.SetBinding(BackgroundColorProperty, new Binding("LoginButtonColour")); var dataTrigger = new DataTrigger(typeof(Button)); dataTrigger.Binding = new Binding("Text.Length", BindingMode.Default, source: loginInput); dataTrigger.Value = 0; dataTrigger.Setters.Add(new Setter { Property = Button.IsEnabledProperty, Value = false }); loginButton.Triggers.Add(dataTrigger); #endregion #region Adding Controls to Stack Layout Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { loginInput, passwordInput, loginButton }, Spacing = 10, }; #endregion }
void UpdateInventory(GameObject item, int index, string tooltip, Sprite itemicon) { //If the item slot based on the element is empty if (go_Inventory[index] == null) { //Add the gameobject into the array based on the element go_Inventory[index] = item; //Set the item tooltip st_ItemTooltip[index] = tooltip; //Set the event trigger variable to obtain the event trigger component EventTrigger TriggerButton = InventoryButtons[index].GetComponent <EventTrigger>(); //Create new entries for the entry and exit button EventTrigger.Entry MouseHover = new EventTrigger.Entry(); EventTrigger.Entry MouseClick = new EventTrigger.Entry(); EventTrigger.Entry MouseExit = new EventTrigger.Entry(); //Set event ID for the pointer enter event trigger type MouseHover.eventID = EventTriggerType.PointerEnter; //Add the listener for revealing the tooltip MouseHover.callback.AddListener(delegate { RevealTooltip(index, st_ItemTooltip[index]); }); //Add the trigger for the mouse hover TriggerButton.triggers.Add(MouseHover); //Set event ID for the pointer click event trigger type MouseClick.eventID = EventTriggerType.PointerClick; //Add the listener for updating the tooltip MouseClick.callback.AddListener(delegate { UpdateTooltip(index); }); //Add the trigger for the mouse click TriggerButton.triggers.Add(MouseClick); //Set event ID for the pointer exit event trigger type MouseExit.eventID = EventTriggerType.PointerExit; //Add the listener for hiding the tooltip MouseExit.callback.AddListener(delegate { HideTooltip(); }); //Add the trigger for the mouse exit TriggerButton.triggers.Add(MouseExit); //Update the sprite with the item icon InventoryButtons[index].image.sprite = itemicon; //Add the listener InventoryButtons[index].onClick.AddListener(delegate { UseItem(index); }); } else { //If the item slot is not empty then make it empty go_Inventory[index] = null; //Set the item tooltip to blank st_ItemTooltip[index] = ""; //Updates the sprite InventoryButtons[index].image.sprite = sp_InventoryBox; //Remove the listener InventoryButtons[index].onClick.RemoveListener(delegate { UseItem(index); }); } }
public void Start() { eraseMode = false; down = false; tiles = new List <GameObject>(); contour = new List <GameObject>(); grid = new List <GameObject>(); colors = new Color[4]; ColorUtility.TryParseHtmlString("#4285F4", out colors[0]); ColorUtility.TryParseHtmlString("#FBBC05", out colors[1]); ColorUtility.TryParseHtmlString("#EA4335", out colors[2]); ColorUtility.TryParseHtmlString("#34A853", out colors[3]); palette = GameObject.FindObjectOfType <PalettePD>(); palette.ColorCount = 2; // It must be taken from Puzzle int toolbarScenario = 0; if (toolbarMode) { toolbarScenario = Screen.height / 10; } puzzleString = puzzleString.Replace(' ', '\n'); currentPuzzle = new PuzzleBT("bb0bb00b0001b011b111bb1b", 2, 4, 6, false, false); currentPuzzle.Clear(); cols = currentPuzzle.width; rows = currentPuzzle.height; tileMargin = (int)Mathf.Ceil(Screen.width / 720.0f); verticalFieldMargin = tileMargin; //Screen.width * 5 / 180; fieldHeight = Screen.height - 2 * verticalFieldMargin - Screen.width / 5 - toolbarScenario; tileSize = Mathf.Min((fieldHeight - 2 * tileMargin * rows) / rows, (Screen.width - 2 * tileMargin * cols) / cols); centringTop = (fieldHeight - rows * (tileSize + 2 * tileMargin)) / 2; centringLeft = (Screen.width - cols * (tileSize + 2 * tileMargin)) / 2; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { int index = i * cols + j; int X = centringLeft + tileMargin + j * (tileSize + 2 * tileMargin); int Y = Screen.height - toolbarScenario - centringTop - verticalFieldMargin - tileMargin - i * (tileSize + 2 * tileMargin); tiles.Add(Instantiate(tile, new Vector3(X, Y, 0), Quaternion.identity) as GameObject); tiles[index].transform.SetParent(gameField.transform, true); tiles[index].GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, tileSize); tiles[index].GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, tileSize); switch (currentPuzzle[i, j]) { case 'b': tiles[index].GetComponent <Image>().color = Color.clear; break; case 'e': tiles[index].GetComponent <Image>().color = Color.white; break; } EventTrigger trigger = tiles[index].GetComponent <EventTrigger>(); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerDown; entry.callback.AddListener(delegate { TileDown(index); }); trigger.triggers.Add(entry); entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerEnter; entry.callback.AddListener(delegate { TileHover(index); }); trigger.triggers.Add(entry); } } DrawGrid(); }
void Start() { eventTrigger = GetComponent <EventTrigger>(); eventTrigger.AddEventTrigger(OnDrag, EventTriggerType.Drag); scroll = GetComponentInParent <Scroll>(); }
void ButtonSetting(Button button) { EventTrigger trigger = button.GetComponent <EventTrigger>(); EventTrigger.Entry entry_down = new EventTrigger.Entry(); entry_down.eventID = EventTriggerType.PointerDown; EventTrigger.Entry entry_up = new EventTrigger.Entry(); entry_up.eventID = EventTriggerType.PointerUp; switch (button.name.ToString()) { case "RJ1 up Button": entry_down.callback.AddListener((x) => { push_j1_up = true; MakeCommand(); }); entry_up.callback.AddListener((x) => { push_j1_up = false; MakeCommand(); }); break; case "RJ1 down Button": entry_down.callback.AddListener((x) => { push_j1_down = true; MakeCommand(); }); entry_up.callback.AddListener((x) => { push_j1_down = false; MakeCommand(); }); break; case "RJ2 up Button": entry_down.callback.AddListener((x) => { push_j2_up = true; MakeCommand(); }); entry_up.callback.AddListener((x) => { push_j2_up = false; MakeCommand(); }); break; case "RJ2 down Button": entry_down.callback.AddListener((x) => { push_j2_down = true; MakeCommand(); }); entry_up.callback.AddListener((x) => { push_j2_down = false; MakeCommand(); }); break; case "RJ3 up Button": entry_down.callback.AddListener((x) => { push_j3_up = true; MakeCommand(); }); entry_up.callback.AddListener((x) => { push_j3_up = false; MakeCommand(); }); break; case "RJ3 down Button": entry_down.callback.AddListener((x) => { push_j3_down = true; MakeCommand(); }); entry_up.callback.AddListener((x) => { push_j3_down = false; MakeCommand(); }); break; case "RJ4 up Button": entry_down.callback.AddListener((x) => { push_j4_up = true; MakeCommand(); }); entry_up.callback.AddListener((x) => { push_j4_up = false; MakeCommand(); }); break; case "RJ4 down Button": entry_down.callback.AddListener((x) => { push_j4_down = true; MakeCommand(); }); entry_up.callback.AddListener((x) => { push_j4_down = false; MakeCommand(); }); break; case "RJ5 up Button": entry_down.callback.AddListener((x) => { push_j5_up = true; MakeCommand(); }); entry_up.callback.AddListener((x) => { push_j5_up = false; MakeCommand(); }); break; case "RJ5 down Button": entry_down.callback.AddListener((x) => { push_j5_down = true; MakeCommand(); }); entry_up.callback.AddListener((x) => { push_j5_down = false; MakeCommand(); }); break; case "RJ6 up Button": entry_down.callback.AddListener((x) => { push_j6_up = true; MakeCommand(); }); entry_up.callback.AddListener((x) => { push_j6_up = false; MakeCommand(); }); break; case "RJ6 down Button": entry_down.callback.AddListener((x) => { push_j6_down = true; MakeCommand(); }); entry_up.callback.AddListener((x) => { push_j6_down = false; MakeCommand(); }); break; case "RJ7 up Button": entry_down.callback.AddListener((x) => { push_j7_up = true; MakeCommand(); }); entry_up.callback.AddListener((x) => { push_j7_up = false; MakeCommand(); }); break; case "RJ7 down Button": entry_down.callback.AddListener((x) => { push_j7_down = true; MakeCommand(); }); entry_up.callback.AddListener((x) => { push_j7_down = false; MakeCommand(); }); break; } trigger.triggers.Add(entry_down); trigger.triggers.Add(entry_up); }
public static void AddEventTriggerEntry(EventTrigger eventTrigger, UnityAction <BaseEventData> action, EventTriggerType eventTriggerType) {
// Use this for initialization void Start () { PC = GameObject.Find ("PC").GetComponent<PC_Main> (); eventTrigger = GetComponent<EventTrigger>(); AddEventTrigger(OnPointerClick, EventTriggerType.PointerUp); }
public static void Up(this EventTrigger eventTrigger, UnityAction <BaseEventData> callback) { eventTrigger.Trigger(EventTriggerType.PointerUp, callback); }
// Use this for initialization void Start() { PC = GameObject.Find("PC").GetComponent <PC_Main> (); eventTrigger = GetComponent <EventTrigger>(); AddEventTrigger(OnPointerClick, EventTriggerType.PointerUp); }
public EventTrigger GetEventTrigger() { entityCommandBuffer = endSimulationEntityCommandBufferSystem.CreateCommandBuffer(); eventCaller = new EventTrigger(eventEntityArchetype, entityCommandBuffer); return(eventCaller); }
public static void RemoveEventTrigger(EventTrigger eventTrigger, EventTriggerType eventType) { eventTrigger.triggers.RemoveAll(x => x.eventID == eventType); }
private void InitializeResources() { // Resource - [ToolTipText] String this.Add("ToolTipText", "Click to open message box"); // Resource - [TitleResource] String this.Add("TitleResource", "Basic UI Example"); // Resource - [logoSunburn] BitmapImage BitmapImage r_2_bm = new BitmapImage(); r_2_bm.TextureAsset = "Images/SunBurn"; this.Add("logoSunburn", r_2_bm); // Resource - [buttonStyle] Style var r_3_s_bo = this[typeof(Button)]; Style r_3_s = new Style(typeof(Button), r_3_s_bo as Style); Setter r_3_s_S_0 = new Setter(Button.BackgroundProperty, new SolidColorBrush(new ColorW(255, 140, 0, 255))); r_3_s.Setters.Add(r_3_s_S_0); Setter r_3_s_S_1 = new Setter(Button.WidthProperty, 200F); r_3_s.Setters.Add(r_3_s_S_1); Setter r_3_s_S_2 = new Setter(Button.PaddingProperty, new Thickness(2F)); r_3_s.Setters.Add(r_3_s_S_2); this.Add("buttonStyle", r_3_s); // Resource - [logoEmptyKeys] BitmapImage BitmapImage r_4_bm = new BitmapImage(); r_4_bm.TextureAsset = "Images/EmptyKeysLogoTextSmall"; this.Add("logoEmptyKeys", r_4_bm); // Resource - [buttonAnimStyle] Style var r_5_s_bo = this[typeof(Button)]; Style r_5_s = new Style(typeof(Button), r_5_s_bo as Style); Setter r_5_s_S_0 = new Setter(Button.WidthProperty, 200F); r_5_s.Setters.Add(r_5_s_S_0); Setter r_5_s_S_1 = new Setter(Button.MarginProperty, new Thickness(0F, 1F, 0F, 1F)); r_5_s.Setters.Add(r_5_s_S_1); Setter r_5_s_S_2 = new Setter(Button.SnapsToDevicePixelsProperty, false); r_5_s.Setters.Add(r_5_s_S_2); EventTrigger r_5_s_ET_0 = new EventTrigger(Button.MouseEnterEvent); r_5_s.Triggers.Add(r_5_s_ET_0); BeginStoryboard r_5_s_ET_0_AC_0 = new BeginStoryboard(); r_5_s_ET_0_AC_0.Name = "r_5_s_ET_0_AC_0"; r_5_s_ET_0.AddAction(r_5_s_ET_0_AC_0); Storyboard r_5_s_ET_0_AC_0_SB = new Storyboard(); r_5_s_ET_0_AC_0.Storyboard = r_5_s_ET_0_AC_0_SB; r_5_s_ET_0_AC_0_SB.Name = "r_5_s_ET_0_AC_0_SB"; ThicknessAnimation r_5_s_ET_0_AC_0_SB_TL_0 = new ThicknessAnimation(); r_5_s_ET_0_AC_0_SB_TL_0.Name = "r_5_s_ET_0_AC_0_SB_TL_0"; r_5_s_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500)); r_5_s_ET_0_AC_0_SB_TL_0.From = new Thickness(0F, 1F, 0F, 1F); r_5_s_ET_0_AC_0_SB_TL_0.To = new Thickness(0F, 5F, 0F, 5F); SineEase r_5_s_ET_0_AC_0_SB_TL_0_EA = new SineEase(); r_5_s_ET_0_AC_0_SB_TL_0.EasingFunction = r_5_s_ET_0_AC_0_SB_TL_0_EA; Storyboard.SetTargetProperty(r_5_s_ET_0_AC_0_SB_TL_0, Button.MarginProperty); r_5_s_ET_0_AC_0_SB.Children.Add(r_5_s_ET_0_AC_0_SB_TL_0); FloatAnimation r_5_s_ET_0_AC_0_SB_TL_1 = new FloatAnimation(); r_5_s_ET_0_AC_0_SB_TL_1.Name = "r_5_s_ET_0_AC_0_SB_TL_1"; r_5_s_ET_0_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500)); r_5_s_ET_0_AC_0_SB_TL_1.To = 220F; SineEase r_5_s_ET_0_AC_0_SB_TL_1_EA = new SineEase(); r_5_s_ET_0_AC_0_SB_TL_1.EasingFunction = r_5_s_ET_0_AC_0_SB_TL_1_EA; Storyboard.SetTargetProperty(r_5_s_ET_0_AC_0_SB_TL_1, Button.WidthProperty); r_5_s_ET_0_AC_0_SB.Children.Add(r_5_s_ET_0_AC_0_SB_TL_1); EventTrigger r_5_s_ET_1 = new EventTrigger(Button.MouseLeaveEvent); r_5_s.Triggers.Add(r_5_s_ET_1); BeginStoryboard r_5_s_ET_1_AC_0 = new BeginStoryboard(); r_5_s_ET_1_AC_0.Name = "r_5_s_ET_1_AC_0"; r_5_s_ET_1.AddAction(r_5_s_ET_1_AC_0); Storyboard r_5_s_ET_1_AC_0_SB = new Storyboard(); r_5_s_ET_1_AC_0.Storyboard = r_5_s_ET_1_AC_0_SB; r_5_s_ET_1_AC_0_SB.Name = "r_5_s_ET_1_AC_0_SB"; ThicknessAnimation r_5_s_ET_1_AC_0_SB_TL_0 = new ThicknessAnimation(); r_5_s_ET_1_AC_0_SB_TL_0.Name = "r_5_s_ET_1_AC_0_SB_TL_0"; r_5_s_ET_1_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500)); r_5_s_ET_1_AC_0_SB_TL_0.From = new Thickness(0F, 5F, 0F, 5F); r_5_s_ET_1_AC_0_SB_TL_0.To = new Thickness(0F, 1F, 0F, 1F); SineEase r_5_s_ET_1_AC_0_SB_TL_0_EA = new SineEase(); r_5_s_ET_1_AC_0_SB_TL_0.EasingFunction = r_5_s_ET_1_AC_0_SB_TL_0_EA; Storyboard.SetTargetProperty(r_5_s_ET_1_AC_0_SB_TL_0, Button.MarginProperty); r_5_s_ET_1_AC_0_SB.Children.Add(r_5_s_ET_1_AC_0_SB_TL_0); FloatAnimation r_5_s_ET_1_AC_0_SB_TL_1 = new FloatAnimation(); r_5_s_ET_1_AC_0_SB_TL_1.Name = "r_5_s_ET_1_AC_0_SB_TL_1"; r_5_s_ET_1_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500)); r_5_s_ET_1_AC_0_SB_TL_1.To = 200F; SineEase r_5_s_ET_1_AC_0_SB_TL_1_EA = new SineEase(); r_5_s_ET_1_AC_0_SB_TL_1.EasingFunction = r_5_s_ET_1_AC_0_SB_TL_1_EA; Storyboard.SetTargetProperty(r_5_s_ET_1_AC_0_SB_TL_1, Button.WidthProperty); r_5_s_ET_1_AC_0_SB.Children.Add(r_5_s_ET_1_AC_0_SB_TL_1); this.Add("buttonAnimStyle", r_5_s); // Resource - [MessageBoxButtonYes] String this.Add("MessageBoxButtonYes", "Yes!"); // Resource - [Sounds] SoundSourceCollection var r_7_sounds = new SoundSourceCollection(); r_7_sounds.Add(new SoundSource { SoundType = SoundType.ButtonsClick, SoundAsset = "Click" }); SoundManager.Instance.AddSound("Click"); r_7_sounds.Add(new SoundSource { SoundType = SoundType.TextBoxKeyPress, SoundAsset = "KeyPress" }); SoundManager.Instance.AddSound("KeyPress"); r_7_sounds.Add(new SoundSource { SoundType = SoundType.TabControlMove, SoundAsset = "Move" }); SoundManager.Instance.AddSound("Move"); r_7_sounds.Add(new SoundSource { SoundType = SoundType.TabControlSelect, SoundAsset = "Select" }); SoundManager.Instance.AddSound("Select"); this.Add("Sounds", r_7_sounds); ImageManager.Instance.AddImage("Images/SunBurn"); ImageManager.Instance.AddImage("Images/EmptyKeysLogoTextSmall"); FontManager.Instance.AddFont("Segoe UI", 13.33333F, FontStyle.Regular, "Segoe_UI_10_Regular"); FontManager.Instance.AddFont("Segoe UI", 20F, FontStyle.Bold, "Segoe_UI_15_Bold"); FontManager.Instance.AddFont("Segoe UI", 12F, FontStyle.Regular, "Segoe_UI_9_Regular"); }
void Start() { tankSelected = 0; tankTarget = new Vector3(tankSelected * -1200, 0, 0); resumeLevel = PlayerPrefs.GetInt("ResumeLevel", 1); //ToDo take level from memero Resume.onClick.AddListener(() => { Debug.Log("Resume"); StartGame(resumeLevel, false); }); EventTrigger trigger = Resume.GetComponent <EventTrigger>(); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.Select; entry.callback.AddListener( (data) => { MoveTanksAbsolute(resumeLevel - 1); }); trigger.triggers.Add(entry); NewGame.onClick.AddListener(() => { Debug.Log("New Game"); //ToDo clear SaveGame StartGame(1, true); }); trigger = NewGame.GetComponent <EventTrigger>(); entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.Select; entry.callback.AddListener( (data) => { MoveTanksAbsolute(0); }); trigger.triggers.Add(entry); SelectTank.onClick.AddListener(() => ToggleTankSelect(true)); TankHighlight.onClick.AddListener(() => StartGame(tankSelected + 1, true)); trigger = TankHighlight.GetComponent <EventTrigger>(); entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.Cancel; entry.callback.AddListener( (data) => { ToggleTankSelect(true); }); trigger.triggers.Add(entry); entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.Move; entry.callback.AddListener( (data) => { var d = (AxisEventData)data; if (d.moveDir == MoveDirection.Right) { MoveTanksRelative(1); } if (d.moveDir == MoveDirection.Left) { MoveTanksRelative(-1); } }); trigger.triggers.Add(entry); ToggleTankSelect(false); EventSystem.SetSelectedGameObject(Resume.gameObject); }
/// <summary> /// 建立紅色書包圖標 /// </summary> /// <param name="gameMode">遊戲模式</param> /// <param name="param">我知道這不安全,但這很方便σ`∀´)σ</param> internal static void DrawRedBagBtn(FBIOpenUp.GameMode gameMode, object param = null) { GameObject original, parent; Vector2 offsetMin, offsetMax; FBIOpenUp.nowGameMode = gameMode; switch (FBIOpenUp.nowGameMode) { case FBIOpenUp.GameMode.Studio: CharaList charaList = param as CharaList; original = GameObject.Find($"StudioScene/Canvas Main Menu/01_Add/{charaList.name}/Button Change"); parent = original.transform.parent.gameObject; offsetMin = new Vector2(-120, -270); offsetMax = new Vector2(-40, -190); break; case FBIOpenUp.GameMode.Maker: original = GameObject.Find("CustomScene/CustomRoot/FrontUIGroup/CustomUIGroup/CvsMenuTree/01_BodyTop/tglShape/ShapeTop/Scroll View/Viewport/Content/grpBtn/btnS"); parent = GameObject.Find("CustomScene/CustomRoot/FrontUIGroup/CustomUIGroup/CvsCoordinateType").gameObject; offsetMin = new Vector2(849.64f, -120f); offsetMax = new Vector2(914.64f, -55f); break; case FBIOpenUp.GameMode.MainGame: original = GameObject.Find("ActionScene/UI/ActionMenuCanvas/ModeAnimation/State"); parent = original.transform.parent.gameObject; offsetMin = new Vector2(0, -80); offsetMax = new Vector2(80, 0); break; case FBIOpenUp.GameMode.FreeH: original = GameObject.Find("Canvas/SubMenu/ClothCategory/ClothFemale/DressCategory/ClothChange"); int i = (int)param; if (i == 1) { parent = GameObject.Find("Canvas/SubMenu/ClothCategory"); } else { parent = GameObject.Find("Canvas/SubMenu/SecondDressCategory"); } offsetMin = new Vector2(5, -198); offsetMax = new Vector2(107, -96); break; default: return; } GameObject redBagBtn = UnityEngine.Object.Instantiate(original, parent.transform); redBagBtn.name = "redBagBtn"; redBagBtn.transform.SetRect(new Vector2(0, 1), new Vector2(0, 1), offsetMin, offsetMax); redBagBtn.GetComponent <Button>().spriteState = new SpriteState(); redBagBtn.GetComponent <Image>().sprite = ImageHelper.LoadNewSprite("FBIOpenUp.Resources.redBag.png", 100, 100); redBagBtn.GetComponent <Button>().onClick.RemoveAllListeners(); for (int i = 0; i < redBagBtn.GetComponent <Button>().onClick.GetPersistentEventCount(); i++) { redBagBtn.GetComponent <Button>().onClick.SetPersistentListenerState(i, UnityEngine.Events.UnityEventCallState.Off); } if (redBagBtn.transform.Find("Text (TMP)")?.gameObject is GameObject go) { GameObject.Destroy(go); } if (redBagBtn.transform.Find("textBtn")?.gameObject is GameObject go2) { GameObject.Destroy(go2); } redBagBtn.GetComponent <Button>().interactable = true; //因為要handle長按,監聽PointerDown、PointerUp Event //在Update()裡面有對Timer累加 redBagBtn.AddComponent <EventTrigger>(); EventTrigger trigger = redBagBtn.gameObject.GetComponent <EventTrigger>(); EventTrigger.Entry pointerDown = new EventTrigger.Entry { eventID = EventTriggerType.PointerDown, callback = new EventTrigger.TriggerEvent() }; pointerDown.callback.AddListener((baseEventData) => { btnClickTimer = 0; downState = true; }); trigger.triggers.Add(pointerDown); EventTrigger.Entry pointerUp = new EventTrigger.Entry { eventID = EventTriggerType.PointerUp, callback = new EventTrigger.TriggerEvent() }; pointerUp.callback.AddListener((baseEventData) => { downState = false; float clickDeltaTime = btnClickTimer; btnClickTimer = 0; if (step != 0) { return; } switch (FBIOpenUp.nowGameMode) { case FBIOpenUp.GameMode.FreeH: //不分長短按 FBIOpenUp.SetEnabled(); if (FBIOpenUp._isenabled) { step = 10; } else { if (FBIOpenUp.Effect_on_ABMX.Value) { step = 2; } else { step = 20; } } ChangeWithoutShiftPicture = true; StepLightAndPlay(); //開ABMX時不變更狀態 if (FBIOpenUp.Effect_on_ABMX.Value) { FBIOpenUp.SetEnabled(); } ChangeRedBagBtn(redBagBtn); break; case FBIOpenUp.GameMode.Maker: FBIOpenUp.SetEnabled(); if (FBIOpenUp._isenabled) { DrawSlidePic(10); } else { if (FBIOpenUp.Effect_on_ABMX.Value) { DrawSlidePic(2); } else { DrawSlidePic(20); } } //Maker開ABMX時、啟用長按時不變更狀態 if (FBIOpenUp.Effect_on_ABMX.Value || (clickDeltaTime >= 1f && FBIOpenUp._isenabled)) { FBIOpenUp.SetEnabled(); } ChangeRedBagBtn(redBagBtn); break; case FBIOpenUp.GameMode.MainGame: //主遊戲不分長短按 FBIOpenUp.SetEnabled(); if (FBIOpenUp._isenabled) { DrawSlidePic(10); } else { if (FBIOpenUp.Effect_on_ABMX.Value) { DrawSlidePic(2); } else { DrawSlidePic(20); } } if (FBIOpenUp.Effect_on_ABMX.Value) { FBIOpenUp.SetEnabled(); } ChangeRedBagBtn(redBagBtn); break; case FBIOpenUp.GameMode.Studio: //Studio長按時調整狀態而不變人 FBIOpenUp.SetEnabled(); if (clickDeltaTime <= 1f) { if (FBIOpenUp._isenabled) { DrawSlidePic(10); } else { if (FBIOpenUp.Effect_on_ABMX.Value) { DrawSlidePic(2); } else { DrawSlidePic(20); } } ChangeRedBagBtn(redBagBtn); } else { if (FBIOpenUp._isenabled) { DrawSlidePic(1); } else { DrawSlidePic(2); } ChangeRedBagBtn(redBagBtn); } break; } }); trigger.triggers.Add(pointerUp); ChangeRedBagBtn(redBagBtn); }
private static void SpecificComponentsCheck(GameObject go, Component c) { if (c.GetType() == typeof(EventTrigger)) { EventTrigger Comp = c as EventTrigger; for (int i = 0; i < Comp.triggers.Count; i++) { for (int j = 0; j < Comp.triggers[i].callback.GetPersistentEventCount(); j++) { string MethoName = Comp.triggers[i].callback.GetPersistentMethodName(j); Object TObj = Comp.triggers[i].callback.GetPersistentTarget(j); checkMethords(go, TObj, MethoName); } } } else if (c.GetType() == typeof(Button)) { Button Comp = c as Button; for (int j = 0; j < Comp.onClick.GetPersistentEventCount(); j++) { string MethoName = Comp.onClick.GetPersistentMethodName(j); Object TObj = Comp.onClick.GetPersistentTarget(j); checkMethords(go, TObj, MethoName); } } else if (c.GetType() == typeof(Toggle)) { Toggle Comp = c as Toggle; for (int j = 0; j < Comp.onValueChanged.GetPersistentEventCount(); j++) { string MethoName = Comp.onValueChanged.GetPersistentMethodName(j); Object TObj = Comp.onValueChanged.GetPersistentTarget(j); checkMethords(go, TObj, MethoName); } } else if (c.GetType() == typeof(Slider)) { Slider Comp = c as Slider; for (int j = 0; j < Comp.onValueChanged.GetPersistentEventCount(); j++) { string MethoName = Comp.onValueChanged.GetPersistentMethodName(j); Object TObj = Comp.onValueChanged.GetPersistentTarget(j); checkMethords(go, TObj, MethoName); } } else if (c.GetType() == typeof(Scrollbar)) { Scrollbar Comp = c as Scrollbar; for (int j = 0; j < Comp.onValueChanged.GetPersistentEventCount(); j++) { string MethoName = Comp.onValueChanged.GetPersistentMethodName(j); Object TObj = Comp.onValueChanged.GetPersistentTarget(j); checkMethords(go, TObj, MethoName); } } else if (c.GetType() == typeof(Dropdown)) { Dropdown Comp = c as Dropdown; for (int j = 0; j < Comp.onValueChanged.GetPersistentEventCount(); j++) { string MethoName = Comp.onValueChanged.GetPersistentMethodName(j); Object TObj = Comp.onValueChanged.GetPersistentTarget(j); checkMethords(go, TObj, MethoName); } } else if (c.GetType() == typeof(InputField)) { InputField Comp = c as InputField; for (int j = 0; j < Comp.onValueChanged.GetPersistentEventCount(); j++) { string MethoName = Comp.onValueChanged.GetPersistentMethodName(j); Object TObj = Comp.onValueChanged.GetPersistentTarget(j); checkMethords(go, TObj, MethoName); } for (int j = 0; j < Comp.onEndEdit.GetPersistentEventCount(); j++) { string MethoName = Comp.onEndEdit.GetPersistentMethodName(j); Object TObj = Comp.onEndEdit.GetPersistentTarget(j); checkMethords(go, TObj, MethoName); } } else if (c.GetType() == typeof(ScrollRect)) { ScrollRect Comp = c as ScrollRect; for (int j = 0; j < Comp.onValueChanged.GetPersistentEventCount(); j++) { string MethoName = Comp.onValueChanged.GetPersistentMethodName(j); Object TObj = Comp.onValueChanged.GetPersistentTarget(j); checkMethords(go, TObj, MethoName); } } }
private static System.Collections.ObjectModel.ObservableCollection<object> Get_TabControl_Items() { System.Collections.ObjectModel.ObservableCollection<object> items = new System.Collections.ObjectModel.ObservableCollection<object>(); // e_3 element TabItem e_3 = new TabItem(); e_3.Name = "e_3"; e_3.HorizontalContentAlignment = HorizontalAlignment.Stretch; e_3.Header = "Controls"; // e_4 element Grid e_4 = new Grid(); e_3.Content = e_4; e_4.Name = "e_4"; RowDefinition row_e_4_0 = new RowDefinition(); row_e_4_0.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_0); RowDefinition row_e_4_1 = new RowDefinition(); row_e_4_1.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_1); RowDefinition row_e_4_2 = new RowDefinition(); row_e_4_2.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_2); RowDefinition row_e_4_3 = new RowDefinition(); row_e_4_3.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_3); RowDefinition row_e_4_4 = new RowDefinition(); row_e_4_4.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_4); RowDefinition row_e_4_5 = new RowDefinition(); row_e_4_5.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_5); RowDefinition row_e_4_6 = new RowDefinition(); row_e_4_6.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_6); RowDefinition row_e_4_7 = new RowDefinition(); row_e_4_7.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_7); RowDefinition row_e_4_8 = new RowDefinition(); row_e_4_8.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_8); RowDefinition row_e_4_9 = new RowDefinition(); row_e_4_9.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_9); RowDefinition row_e_4_10 = new RowDefinition(); row_e_4_10.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_10); RowDefinition row_e_4_11 = new RowDefinition(); row_e_4_11.Height = new GridLength(1F, GridUnitType.Auto); e_4.RowDefinitions.Add(row_e_4_11); ColumnDefinition col_e_4_0 = new ColumnDefinition(); col_e_4_0.Width = new GridLength(1F, GridUnitType.Auto); e_4.ColumnDefinitions.Add(col_e_4_0); ColumnDefinition col_e_4_1 = new ColumnDefinition(); e_4.ColumnDefinitions.Add(col_e_4_1); // e_5 element TextBlock e_5 = new TextBlock(); e_4.Children.Add(e_5); e_5.Name = "e_5"; e_5.VerticalAlignment = VerticalAlignment.Center; e_5.Text = "Button"; // button1 element Button button1 = new Button(); e_4.Children.Add(button1); button1.Name = "button1"; button1.Height = 30F; button1.Width = 200F; button1.Margin = new Thickness(5F, 5F, 5F, 5F); button1.HorizontalAlignment = HorizontalAlignment.Left; button1.TabIndex = 1; button1.Content = "Button 1"; button1.CommandParameter = "Click Button 1"; Grid.SetColumn(button1, 1); Grid.SetRow(button1, 0); Binding binding_button1_Command = new Binding("ButtonCommand"); button1.SetBinding(Button.CommandProperty, binding_button1_Command); // button2 element Button button2 = new Button(); e_4.Children.Add(button2); button2.Name = "button2"; button2.Height = 30F; button2.Width = 200F; button2.Margin = new Thickness(5F, 5F, 5F, 5F); button2.HorizontalAlignment = HorizontalAlignment.Left; button2.TabIndex = 2; button2.Content = "Button 2"; button2.CommandParameter = "Click Button 2"; Grid.SetColumn(button2, 1); Grid.SetRow(button2, 1); Binding binding_button2_IsEnabled = new Binding("ButtonEnabled"); button2.SetBinding(Button.IsEnabledProperty, binding_button2_IsEnabled); Binding binding_button2_Command = new Binding("ButtonCommand"); button2.SetBinding(Button.CommandProperty, binding_button2_Command); // buttonResult element TextBlock buttonResult = new TextBlock(); e_4.Children.Add(buttonResult); buttonResult.Name = "buttonResult"; buttonResult.HorizontalAlignment = HorizontalAlignment.Left; Grid.SetColumn(buttonResult, 1); Grid.SetRow(buttonResult, 2); Binding binding_buttonResult_Text = new Binding("ButtonResult"); buttonResult.SetBinding(TextBlock.TextProperty, binding_buttonResult_Text); // e_6 element TextBlock e_6 = new TextBlock(); e_4.Children.Add(e_6); e_6.Name = "e_6"; e_6.VerticalAlignment = VerticalAlignment.Center; e_6.Text = "CheckBox"; Grid.SetRow(e_6, 3); // checkBox element CheckBox checkBox = new CheckBox(); e_4.Children.Add(checkBox); checkBox.Name = "checkBox"; checkBox.Margin = new Thickness(5F, 5F, 5F, 5F); checkBox.HorizontalAlignment = HorizontalAlignment.Left; checkBox.TabIndex = 3; checkBox.Content = "Check Box"; Grid.SetColumn(checkBox, 1); Grid.SetRow(checkBox, 3); // e_7 element TextBlock e_7 = new TextBlock(); e_4.Children.Add(e_7); e_7.Name = "e_7"; e_7.VerticalAlignment = VerticalAlignment.Center; e_7.Text = "ProgressBar"; Grid.SetRow(e_7, 4); // e_8 element ProgressBar e_8 = new ProgressBar(); e_4.Children.Add(e_8); e_8.Name = "e_8"; e_8.Height = 30F; e_8.Width = 200F; e_8.Margin = new Thickness(5F, 5F, 5F, 5F); e_8.HorizontalAlignment = HorizontalAlignment.Left; Grid.SetColumn(e_8, 1); Grid.SetRow(e_8, 4); Binding binding_e_8_Value = new Binding("ProgressValue"); e_8.SetBinding(ProgressBar.ValueProperty, binding_e_8_Value); // e_9 element TextBlock e_9 = new TextBlock(); e_4.Children.Add(e_9); e_9.Name = "e_9"; e_9.VerticalAlignment = VerticalAlignment.Center; e_9.Text = "Slider"; Grid.SetRow(e_9, 5); // slider element Slider slider = new Slider(); e_4.Children.Add(slider); slider.Name = "slider"; slider.Width = 200F; slider.HorizontalAlignment = HorizontalAlignment.Left; slider.TabIndex = 4; slider.Minimum = 5F; slider.Maximum = 20F; Grid.SetColumn(slider, 1); Grid.SetRow(slider, 5); Binding binding_slider_Value = new Binding("SliderValue"); slider.SetBinding(Slider.ValueProperty, binding_slider_Value); // e_10 element TextBlock e_10 = new TextBlock(); e_4.Children.Add(e_10); e_10.Name = "e_10"; e_10.VerticalAlignment = VerticalAlignment.Center; e_10.Text = "TextBox"; Grid.SetRow(e_10, 6); // textBox element TextBox textBox = new TextBox(); e_4.Children.Add(textBox); textBox.Name = "textBox"; textBox.Width = 200F; textBox.Margin = new Thickness(5F, 5F, 5F, 5F); textBox.HorizontalAlignment = HorizontalAlignment.Left; textBox.TabIndex = 5; textBox.SelectionBrush = new SolidColorBrush(new ColorW(255, 0, 0, 255)); textBox.UndoLimit = 20; Grid.SetColumn(textBox, 1); Grid.SetRow(textBox, 6); Binding binding_textBox_Text = new Binding("TextBoxText"); textBox.SetBinding(TextBox.TextProperty, binding_textBox_Text); // e_11 element TextBlock e_11 = new TextBlock(); e_4.Children.Add(e_11); e_11.Name = "e_11"; e_11.VerticalAlignment = VerticalAlignment.Center; e_11.Text = "Numeric"; Grid.SetRow(e_11, 7); // numTextBox element NumericTextBox numTextBox = new NumericTextBox(); e_4.Children.Add(numTextBox); numTextBox.Name = "numTextBox"; numTextBox.Width = 200F; numTextBox.Margin = new Thickness(5F, 5F, 5F, 5F); numTextBox.HorizontalAlignment = HorizontalAlignment.Left; numTextBox.TabIndex = 6; numTextBox.ValueFormat = "F0"; numTextBox.ValueStyle = ((System.Globalization.NumberStyles)(7)); Grid.SetColumn(numTextBox, 1); Grid.SetRow(numTextBox, 7); Binding binding_numTextBox_Value = new Binding("NumericTextBoxValue"); numTextBox.SetBinding(NumericTextBox.ValueProperty, binding_numTextBox_Value); // e_12 element TextBlock e_12 = new TextBlock(); e_4.Children.Add(e_12); e_12.Name = "e_12"; e_12.VerticalAlignment = VerticalAlignment.Center; e_12.Text = "PasswordBox"; Grid.SetRow(e_12, 8); // e_13 element PasswordBox e_13 = new PasswordBox(); e_4.Children.Add(e_13); e_13.Name = "e_13"; e_13.Width = 200F; e_13.Margin = new Thickness(5F, 5F, 5F, 5F); e_13.HorizontalAlignment = HorizontalAlignment.Left; e_13.TabIndex = 7; Grid.SetColumn(e_13, 1); Grid.SetRow(e_13, 8); Binding binding_e_13_Password = new Binding("Password"); e_13.SetBinding(PasswordBox.PasswordProperty, binding_e_13_Password); // e_14 element TextBlock e_14 = new TextBlock(); e_4.Children.Add(e_14); e_14.Name = "e_14"; e_14.VerticalAlignment = VerticalAlignment.Center; e_14.Text = "ComboBox"; Grid.SetRow(e_14, 9); // combo element ComboBox combo = new ComboBox(); e_4.Children.Add(combo); combo.Name = "combo"; combo.Width = 200F; combo.Margin = new Thickness(5F, 5F, 5F, 5F); combo.HorizontalAlignment = HorizontalAlignment.Left; combo.TabIndex = 8; combo.ItemsSource = Get_combo_Items(); combo.SelectedIndex = 2; Grid.SetColumn(combo, 1); Grid.SetRow(combo, 9); // e_15 element TextBlock e_15 = new TextBlock(); e_4.Children.Add(e_15); e_15.Name = "e_15"; e_15.VerticalAlignment = VerticalAlignment.Center; e_15.Text = "ListBox"; Grid.SetRow(e_15, 10); // e_16 element Grid e_16 = new Grid(); e_4.Children.Add(e_16); e_16.Name = "e_16"; ColumnDefinition col_e_16_0 = new ColumnDefinition(); e_16.ColumnDefinitions.Add(col_e_16_0); ColumnDefinition col_e_16_1 = new ColumnDefinition(); e_16.ColumnDefinitions.Add(col_e_16_1); Grid.SetColumn(e_16, 1); Grid.SetRow(e_16, 10); // e_17 element ListBox e_17 = new ListBox(); e_16.Children.Add(e_17); e_17.Name = "e_17"; e_17.TabIndex = 9; DragDrop.SetIsDragSource(e_17, true); DragDrop.SetIsDropTarget(e_17, true); Binding binding_e_17_ItemsSource = new Binding("DataOne"); e_17.SetBinding(ListBox.ItemsSourceProperty, binding_e_17_ItemsSource); // e_18 element ListBox e_18 = new ListBox(); e_16.Children.Add(e_18); e_18.Name = "e_18"; e_18.TabIndex = 10; Grid.SetColumn(e_18, 1); DragDrop.SetIsDragSource(e_18, true); DragDrop.SetIsDropTarget(e_18, true); Binding binding_e_18_ItemsSource = new Binding("DataTwo"); e_18.SetBinding(ListBox.ItemsSourceProperty, binding_e_18_ItemsSource); // e_19 element TextBlock e_19 = new TextBlock(); e_4.Children.Add(e_19); e_19.Name = "e_19"; e_19.VerticalAlignment = VerticalAlignment.Center; e_19.Text = "RadioButton"; Grid.SetRow(e_19, 11); // e_20 element StackPanel e_20 = new StackPanel(); e_4.Children.Add(e_20); e_20.Name = "e_20"; e_20.Orientation = Orientation.Horizontal; Grid.SetColumn(e_20, 1); Grid.SetRow(e_20, 11); // e_21 element RadioButton e_21 = new RadioButton(); e_20.Children.Add(e_21); e_21.Name = "e_21"; e_21.Margin = new Thickness(5F, 5F, 5F, 5F); e_21.Content = "Radio Button 1"; e_21.GroupName = "testGroup1"; // e_22 element RadioButton e_22 = new RadioButton(); e_20.Children.Add(e_22); e_22.Name = "e_22"; e_22.Margin = new Thickness(5F, 5F, 5F, 5F); e_22.Content = "Radio Button 2"; e_22.GroupName = "testGroup1"; // e_23 element RadioButton e_23 = new RadioButton(); e_20.Children.Add(e_23); e_23.Name = "e_23"; e_23.Margin = new Thickness(5F, 5F, 5F, 5F); e_23.Content = "Radio Button 3"; e_23.GroupName = "testGroup1"; // e_24 element RadioButton e_24 = new RadioButton(); e_20.Children.Add(e_24); e_24.Name = "e_24"; e_24.Margin = new Thickness(5F, 5F, 5F, 5F); e_24.Content = "Radio Button 4"; e_24.GroupName = "testGroup2"; // e_25 element RadioButton e_25 = new RadioButton(); e_20.Children.Add(e_25); e_25.Name = "e_25"; e_25.Margin = new Thickness(5F, 5F, 5F, 5F); e_25.Content = "Radio Button 5"; e_25.GroupName = "testGroup2"; // e_26 element RadioButton e_26 = new RadioButton(); e_20.Children.Add(e_26); e_26.Name = "e_26"; e_26.Margin = new Thickness(5F, 5F, 5F, 5F); e_26.Content = "Radio Button 6"; e_26.GroupName = "testGroup2"; items.Add(e_3); // e_27 element TabItem e_27 = new TabItem(); e_27.Name = "e_27"; e_27.Header = "DataGrid"; // e_28 element DataGrid e_28 = new DataGrid(); e_27.Content = e_28; e_28.Name = "e_28"; e_28.AutoGenerateColumns = false; DataGridTextColumn e_28_Col0 = new DataGridTextColumn(); e_28_Col0.Header = "#"; Binding e_28_Col0_b = new Binding("Number"); e_28_Col0.Binding = e_28_Col0_b; e_28.Columns.Add(e_28_Col0); DataGridTextColumn e_28_Col1 = new DataGridTextColumn(); e_28_Col1.Width = 200F; e_28_Col1.Header = "Text"; Style e_28_Col1_e_s = new Style(typeof(DataGridCell)); Setter e_28_Col1_e_s_S_0 = new Setter(DataGridCell.BackgroundProperty, new SolidColorBrush(new ColorW(128, 128, 128, 255))); e_28_Col1_e_s.Setters.Add(e_28_Col1_e_s_S_0); Setter e_28_Col1_e_s_S_1 = new Setter(DataGridCell.HorizontalAlignmentProperty, HorizontalAlignment.Center); e_28_Col1_e_s.Setters.Add(e_28_Col1_e_s_S_1); Setter e_28_Col1_e_s_S_2 = new Setter(DataGridCell.VerticalAlignmentProperty, VerticalAlignment.Center); e_28_Col1_e_s.Setters.Add(e_28_Col1_e_s_S_2); e_28_Col1.ElementStyle = e_28_Col1_e_s; Binding e_28_Col1_b = new Binding("Text"); e_28_Col1.Binding = e_28_Col1_b; e_28.Columns.Add(e_28_Col1); DataGridCheckBoxColumn e_28_Col2 = new DataGridCheckBoxColumn(); e_28_Col2.Width = DataGridLength.SizeToHeader; e_28_Col2.Header = "Bool"; Binding e_28_Col2_b = new Binding("Boolean"); e_28_Col2.Binding = e_28_Col2_b; e_28.Columns.Add(e_28_Col2); DataGridTemplateColumn e_28_Col3 = new DataGridTemplateColumn(); e_28_Col3.Width = new DataGridLength(1F, DataGridLengthUnitType.Star); // e_29 element TextBlock e_29 = new TextBlock(); e_29.Name = "e_29"; e_29.Text = "Template Column"; e_28_Col3.Header = e_29; Style e_28_Col3_h_s = new Style(typeof(DataGridColumnHeader)); Setter e_28_Col3_h_s_S_0 = new Setter(DataGridColumnHeader.ForegroundProperty, new SolidColorBrush(new ColorW(255, 165, 0, 255))); e_28_Col3_h_s.Setters.Add(e_28_Col3_h_s_S_0); e_28_Col3.HeaderStyle = e_28_Col3_h_s; Func<UIElement, UIElement> e_28_Col3_ct_dtFunc = e_28_Col3_ct_dtMethod; e_28_Col3.CellTemplate = new DataTemplate(e_28_Col3_ct_dtFunc); e_28.Columns.Add(e_28_Col3); Binding binding_e_28_ItemsSource = new Binding("GridData"); e_28.SetBinding(DataGrid.ItemsSourceProperty, binding_e_28_ItemsSource); items.Add(e_27); // e_35 element TabItem e_35 = new TabItem(); e_35.Name = "e_35"; e_35.Header = "TreeView"; // e_36 element TreeView e_36 = new TreeView(); e_35.Content = e_36; e_36.Name = "e_36"; Binding binding_e_36_ItemsSource = new Binding("TreeItems"); e_36.SetBinding(TreeView.ItemsSourceProperty, binding_e_36_ItemsSource); items.Add(e_35); // e_37 element TabItem e_37 = new TabItem(); e_37.Name = "e_37"; e_37.Header = "Chart"; // e_38 element Chart e_38 = new Chart(); e_37.Content = e_38; e_38.Name = "e_38"; e_38.AxisYMajorUnit = 50F; // e_39 element LineSeries2D e_39 = new LineSeries2D(); e_38.Series.Add(e_39); e_39.Name = "e_39"; // p_40 point SeriesPoint p_40 = new SeriesPoint(); e_39.Points.Add(p_40); p_40.Argument = 0F; p_40.Value = 0F; // p_41 point SeriesPoint p_41 = new SeriesPoint(); e_39.Points.Add(p_41); p_41.Argument = 1F; p_41.Value = 10F; // p_42 point SeriesPoint p_42 = new SeriesPoint(); e_39.Points.Add(p_42); p_42.Argument = 2F; p_42.Value = 20F; // p_43 point SeriesPoint p_43 = new SeriesPoint(); e_39.Points.Add(p_43); p_43.Argument = 3F; p_43.Value = 50F; // p_44 point SeriesPoint p_44 = new SeriesPoint(); e_39.Points.Add(p_44); p_44.Argument = 4F; p_44.Value = 100F; // p_45 point SeriesPoint p_45 = new SeriesPoint(); e_39.Points.Add(p_45); p_45.Argument = 5F; p_45.Value = 200F; // p_46 point SeriesPoint p_46 = new SeriesPoint(); e_39.Points.Add(p_46); p_46.Argument = 6F; p_46.Value = 500F; // e_47 element LineSeries2D e_47 = new LineSeries2D(); e_38.Series.Add(e_47); e_47.Name = "e_47"; e_47.Foreground = new SolidColorBrush(new ColorW(255, 165, 0, 255)); e_47.LineThickness = 1F; Binding binding_e_47_DataSource = new Binding("ChartData"); e_47.SetBinding(LineSeries2D.DataSourceProperty, binding_e_47_DataSource); items.Add(e_37); // e_48 element TabItem e_48 = new TabItem(); e_48.Name = "e_48"; e_48.Header = "Shapes"; // e_49 element Grid e_49 = new Grid(); e_48.Content = e_49; e_49.Name = "e_49"; RowDefinition row_e_49_0 = new RowDefinition(); e_49.RowDefinitions.Add(row_e_49_0); RowDefinition row_e_49_1 = new RowDefinition(); e_49.RowDefinitions.Add(row_e_49_1); RowDefinition row_e_49_2 = new RowDefinition(); e_49.RowDefinitions.Add(row_e_49_2); ColumnDefinition col_e_49_0 = new ColumnDefinition(); e_49.ColumnDefinitions.Add(col_e_49_0); ColumnDefinition col_e_49_1 = new ColumnDefinition(); e_49.ColumnDefinitions.Add(col_e_49_1); ColumnDefinition col_e_49_2 = new ColumnDefinition(); e_49.ColumnDefinitions.Add(col_e_49_2); // e_50 element Rectangle e_50 = new Rectangle(); e_49.Children.Add(e_50); e_50.Name = "e_50"; e_50.Height = 100F; e_50.Width = 200F; e_50.Margin = new Thickness(5F, 5F, 5F, 5F); e_50.Fill = new SolidColorBrush(new ColorW(0, 128, 0, 255)); e_50.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255)); e_50.StrokeThickness = 5F; e_50.RadiusX = 10F; e_50.RadiusY = 10F; // e_51 element Rectangle e_51 = new Rectangle(); e_49.Children.Add(e_51); e_51.Name = "e_51"; e_51.Height = 100F; e_51.Width = 200F; e_51.Margin = new Thickness(5F, 5F, 5F, 5F); e_51.Fill = new SolidColorBrush(new ColorW(255, 165, 0, 255)); Grid.SetColumn(e_51, 1); // e_52 element Rectangle e_52 = new Rectangle(); e_49.Children.Add(e_52); e_52.Name = "e_52"; e_52.Height = 100F; e_52.Width = 200F; e_52.Margin = new Thickness(5F, 5F, 5F, 5F); LinearGradientBrush e_52_Fill = new LinearGradientBrush(); e_52_Fill.StartPoint = new PointF(0F, 0F); e_52_Fill.EndPoint = new PointF(1F, 1F); e_52_Fill.SpreadMethod = GradientSpreadMethod.Pad; e_52_Fill.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0.5F)); e_52_Fill.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0F)); e_52.Fill = e_52_Fill; LinearGradientBrush e_52_Stroke = new LinearGradientBrush(); e_52_Stroke.StartPoint = new PointF(0F, 0F); e_52_Stroke.EndPoint = new PointF(1F, 1F); e_52_Stroke.SpreadMethod = GradientSpreadMethod.Pad; e_52_Stroke.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0.5F)); e_52_Stroke.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0F)); e_52.Stroke = e_52_Stroke; e_52.StrokeThickness = 5F; e_52.RadiusX = 10F; e_52.RadiusY = 10F; Grid.SetColumn(e_52, 2); // e_53 element Ellipse e_53 = new Ellipse(); e_49.Children.Add(e_53); e_53.Name = "e_53"; e_53.Height = 100F; e_53.Width = 200F; e_53.Margin = new Thickness(5F, 5F, 5F, 5F); e_53.Fill = new SolidColorBrush(new ColorW(128, 128, 128, 255)); e_53.Stroke = new SolidColorBrush(new ColorW(0, 128, 0, 255)); e_53.StrokeThickness = 10F; Grid.SetRow(e_53, 1); // e_54 element Ellipse e_54 = new Ellipse(); e_49.Children.Add(e_54); e_54.Name = "e_54"; e_54.Height = 100F; e_54.Width = 200F; e_54.Margin = new Thickness(5F, 5F, 5F, 5F); e_54.Stroke = new SolidColorBrush(new ColorW(255, 165, 0, 255)); e_54.StrokeThickness = 10F; Grid.SetColumn(e_54, 1); Grid.SetRow(e_54, 1); // e_55 element Ellipse e_55 = new Ellipse(); e_49.Children.Add(e_55); e_55.Name = "e_55"; e_55.Height = 100F; e_55.Width = 200F; e_55.Margin = new Thickness(5F, 5F, 5F, 5F); LinearGradientBrush e_55_Fill = new LinearGradientBrush(); e_55_Fill.StartPoint = new PointF(0F, 0F); e_55_Fill.EndPoint = new PointF(1F, 1F); e_55_Fill.SpreadMethod = GradientSpreadMethod.Pad; e_55_Fill.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0.5F)); e_55_Fill.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0F)); e_55.Fill = e_55_Fill; LinearGradientBrush e_55_Stroke = new LinearGradientBrush(); e_55_Stroke.StartPoint = new PointF(0F, 0F); e_55_Stroke.EndPoint = new PointF(1F, 1F); e_55_Stroke.SpreadMethod = GradientSpreadMethod.Pad; e_55_Stroke.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0.5F)); e_55_Stroke.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0F)); e_55.Stroke = e_55_Stroke; e_55.StrokeThickness = 10F; Grid.SetColumn(e_55, 2); Grid.SetRow(e_55, 1); // e_56 element Line e_56 = new Line(); e_49.Children.Add(e_56); e_56.Name = "e_56"; e_56.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255)); e_56.StrokeThickness = 10F; e_56.X1 = 10F; e_56.X2 = 150F; e_56.Y1 = 10F; e_56.Y2 = 150F; Grid.SetRow(e_56, 2); // e_57 element Line e_57 = new Line(); e_49.Children.Add(e_57); e_57.Name = "e_57"; e_57.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255)); e_57.StrokeThickness = 10F; e_57.X1 = 100F; e_57.X2 = 100F; e_57.Y1 = 10F; e_57.Y2 = 100F; Grid.SetRow(e_57, 2); // e_58 element Line e_58 = new Line(); e_49.Children.Add(e_58); e_58.Name = "e_58"; e_58.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255)); e_58.StrokeThickness = 10F; e_58.X1 = 10F; e_58.X2 = 100F; e_58.Y1 = 100F; e_58.Y2 = 100F; Grid.SetRow(e_58, 2); // e_59 element Rectangle e_59 = new Rectangle(); e_49.Children.Add(e_59); e_59.Name = "e_59"; e_59.Height = 100F; e_59.Width = 200F; e_59.Margin = new Thickness(5F, 5F, 5F, 5F); ImageBrush e_59_Fill = new ImageBrush(); BitmapImage e_59_Fill_bm = new BitmapImage(); e_59_Fill_bm.TextureAsset = "Images/MonoGameLogo"; e_59_Fill.ImageSource = e_59_Fill_bm; e_59_Fill.Stretch = Stretch.None; e_59.Fill = e_59_Fill; e_59.Stroke = new SolidColorBrush(new ColorW(255, 255, 255, 255)); e_59.StrokeThickness = 1F; e_59.RadiusX = 10F; e_59.RadiusY = 10F; Grid.SetColumn(e_59, 1); Grid.SetRow(e_59, 2); // e_60 element Image e_60 = new Image(); e_49.Children.Add(e_60); e_60.Name = "e_60"; Grid.SetColumn(e_60, 2); Grid.SetRow(e_60, 2); Binding binding_e_60_Source = new Binding("RenderTargetSource"); e_60.SetBinding(Image.SourceProperty, binding_e_60_Source); items.Add(e_48); // e_61 element TabItem e_61 = new TabItem(); e_61.Name = "e_61"; e_61.Header = "Animations"; // e_62 element Grid e_62 = new Grid(); e_61.Content = e_62; e_62.Name = "e_62"; ColumnDefinition col_e_62_0 = new ColumnDefinition(); e_62.ColumnDefinitions.Add(col_e_62_0); ColumnDefinition col_e_62_1 = new ColumnDefinition(); e_62.ColumnDefinitions.Add(col_e_62_1); // e_63 element StackPanel e_63 = new StackPanel(); e_62.Children.Add(e_63); e_63.Name = "e_63"; // animButton1 element Button animButton1 = new Button(); e_63.Children.Add(animButton1); animButton1.Name = "animButton1"; animButton1.TabIndex = 1; animButton1.Content = "Mouse Over me!"; animButton1.SetResourceReference(Button.StyleProperty, "buttonAnimStyle"); // animButton2 element Button animButton2 = new Button(); e_63.Children.Add(animButton2); animButton2.Name = "animButton2"; animButton2.TabIndex = 2; animButton2.Content = "Mouse Over me!"; animButton2.SetResourceReference(Button.StyleProperty, "buttonAnimStyle"); // animButton3 element Button animButton3 = new Button(); e_63.Children.Add(animButton3); animButton3.Name = "animButton3"; animButton3.TabIndex = 3; animButton3.Content = "Mouse Over me!"; animButton3.SetResourceReference(Button.StyleProperty, "buttonAnimStyle"); // animButton4 element Button animButton4 = new Button(); e_63.Children.Add(animButton4); animButton4.Name = "animButton4"; animButton4.TabIndex = 4; animButton4.Content = "Mouse Over me!"; animButton4.SetResourceReference(Button.StyleProperty, "buttonAnimStyle"); // animBorder1 element Border animBorder1 = new Border(); e_62.Children.Add(animBorder1); animBorder1.Name = "animBorder1"; animBorder1.Height = 100F; animBorder1.Width = 200F; animBorder1.Margin = new Thickness(0F, 10F, 0F, 10F); animBorder1.VerticalAlignment = VerticalAlignment.Top; EventTrigger animBorder1_ET_0 = new EventTrigger(Border.LoadedEvent, animBorder1); animBorder1.Triggers.Add(animBorder1_ET_0); BeginStoryboard animBorder1_ET_0_AC_0 = new BeginStoryboard(); animBorder1_ET_0_AC_0.Name = "animBorder1_ET_0_AC_0"; animBorder1_ET_0.AddAction(animBorder1_ET_0_AC_0); Storyboard animBorder1_ET_0_AC_0_SB = new Storyboard(); animBorder1_ET_0_AC_0.Storyboard = animBorder1_ET_0_AC_0_SB; animBorder1_ET_0_AC_0_SB.Name = "animBorder1_ET_0_AC_0_SB"; SolidColorBrushAnimation animBorder1_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation(); animBorder1_ET_0_AC_0_SB_TL_0.Name = "animBorder1_ET_0_AC_0_SB_TL_0"; animBorder1_ET_0_AC_0_SB_TL_0.AutoReverse = true; animBorder1_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 5, 0)); animBorder1_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever; animBorder1_ET_0_AC_0_SB_TL_0.From = new ColorW(255, 255, 0, 255); animBorder1_ET_0_AC_0_SB_TL_0.To = new ColorW(0, 0, 255, 255); ExponentialEase animBorder1_ET_0_AC_0_SB_TL_0_EA = new ExponentialEase(); animBorder1_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder1_ET_0_AC_0_SB_TL_0_EA; Storyboard.SetTargetName(animBorder1_ET_0_AC_0_SB_TL_0, "animBorder1"); Storyboard.SetTargetProperty(animBorder1_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty); animBorder1_ET_0_AC_0_SB.Children.Add(animBorder1_ET_0_AC_0_SB_TL_0); Grid.SetColumn(animBorder1, 1); // animBorder2 element Border animBorder2 = new Border(); e_62.Children.Add(animBorder2); animBorder2.Name = "animBorder2"; animBorder2.Height = 50F; animBorder2.Width = 100F; animBorder2.Margin = new Thickness(50F, 35F, 50F, 35F); animBorder2.VerticalAlignment = VerticalAlignment.Top; EventTrigger animBorder2_ET_0 = new EventTrigger(Border.LoadedEvent, animBorder2); animBorder2.Triggers.Add(animBorder2_ET_0); BeginStoryboard animBorder2_ET_0_AC_0 = new BeginStoryboard(); animBorder2_ET_0_AC_0.Name = "animBorder2_ET_0_AC_0"; animBorder2_ET_0.AddAction(animBorder2_ET_0_AC_0); Storyboard animBorder2_ET_0_AC_0_SB = new Storyboard(); animBorder2_ET_0_AC_0.Storyboard = animBorder2_ET_0_AC_0_SB; animBorder2_ET_0_AC_0_SB.Name = "animBorder2_ET_0_AC_0_SB"; SolidColorBrushAnimation animBorder2_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation(); animBorder2_ET_0_AC_0_SB_TL_0.Name = "animBorder2_ET_0_AC_0_SB_TL_0"; animBorder2_ET_0_AC_0_SB_TL_0.AutoReverse = true; animBorder2_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 3, 0)); animBorder2_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever; animBorder2_ET_0_AC_0_SB_TL_0.From = new ColorW(255, 0, 0, 255); animBorder2_ET_0_AC_0_SB_TL_0.To = new ColorW(255, 255, 255, 255); CubicEase animBorder2_ET_0_AC_0_SB_TL_0_EA = new CubicEase(); animBorder2_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder2_ET_0_AC_0_SB_TL_0_EA; Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_0, "animBorder2"); Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty); animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_0); FloatAnimation animBorder2_ET_0_AC_0_SB_TL_1 = new FloatAnimation(); animBorder2_ET_0_AC_0_SB_TL_1.Name = "animBorder2_ET_0_AC_0_SB_TL_1"; animBorder2_ET_0_AC_0_SB_TL_1.AutoReverse = true; animBorder2_ET_0_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 4, 0)); animBorder2_ET_0_AC_0_SB_TL_1.RepeatBehavior = RepeatBehavior.Forever; animBorder2_ET_0_AC_0_SB_TL_1.From = 1F; animBorder2_ET_0_AC_0_SB_TL_1.To = 0F; Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_1, "animBorder2"); Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_1, Border.OpacityProperty); animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_1); Grid.SetColumn(animBorder2, 1); items.Add(e_61); // e_64 element TabItem e_64 = new TabItem(); e_64.Name = "e_64"; e_64.Header = "Tetris"; // e_65 element Border e_65 = new Border(); e_64.Content = e_65; e_65.Name = "e_65"; // e_66 element Grid e_66 = new Grid(); e_65.Child = e_66; e_66.Name = "e_66"; e_66.Margin = new Thickness(10F, 10F, 10F, 10F); RowDefinition row_e_66_0 = new RowDefinition(); row_e_66_0.Height = new GridLength(1F, GridUnitType.Auto); e_66.RowDefinitions.Add(row_e_66_0); RowDefinition row_e_66_1 = new RowDefinition(); row_e_66_1.Height = new GridLength(420F, GridUnitType.Pixel); e_66.RowDefinitions.Add(row_e_66_1); ColumnDefinition col_e_66_0 = new ColumnDefinition(); e_66.ColumnDefinitions.Add(col_e_66_0); ColumnDefinition col_e_66_1 = new ColumnDefinition(); e_66.ColumnDefinitions.Add(col_e_66_1); ColumnDefinition col_e_66_2 = new ColumnDefinition(); e_66.ColumnDefinitions.Add(col_e_66_2); // e_67 element StackPanel e_67 = new StackPanel(); e_66.Children.Add(e_67); e_67.Name = "e_67"; e_67.HorizontalAlignment = HorizontalAlignment.Right; e_67.Orientation = Orientation.Vertical; Grid.SetRow(e_67, 1); // e_68 element TextBlock e_68 = new TextBlock(); e_67.Children.Add(e_68); e_68.Name = "e_68"; e_68.Text = "Next"; // e_69 element Border e_69 = new Border(); e_67.Children.Add(e_69); e_69.Name = "e_69"; e_69.Height = 81F; e_69.Width = 81F; e_69.BorderBrush = new SolidColorBrush(new ColorW(255, 255, 255, 255)); e_69.BorderThickness = new Thickness(0F, 0F, 1F, 1F); // tetrisNextContainer1 element Canvas tetrisNextContainer1 = new Canvas(); e_69.Child = tetrisNextContainer1; tetrisNextContainer1.Name = "tetrisNextContainer1"; tetrisNextContainer1.Height = 80F; tetrisNextContainer1.Width = 80F; // e_70 element Border e_70 = new Border(); e_66.Children.Add(e_70); e_70.Name = "e_70"; e_70.Height = 401F; e_70.Width = 201F; e_70.BorderBrush = new SolidColorBrush(new ColorW(255, 255, 255, 255)); e_70.BorderThickness = new Thickness(0F, 0F, 1F, 1F); Grid.SetColumn(e_70, 1); Grid.SetRow(e_70, 1); // tetrisContainer1 element Canvas tetrisContainer1 = new Canvas(); e_70.Child = tetrisContainer1; tetrisContainer1.Name = "tetrisContainer1"; tetrisContainer1.Height = 400F; tetrisContainer1.Width = 200F; tetrisContainer1.HorizontalAlignment = HorizontalAlignment.Left; tetrisContainer1.VerticalAlignment = VerticalAlignment.Top; // e_71 element Grid e_71 = new Grid(); e_66.Children.Add(e_71); e_71.Name = "e_71"; RowDefinition row_e_71_0 = new RowDefinition(); row_e_71_0.Height = new GridLength(1F, GridUnitType.Auto); e_71.RowDefinitions.Add(row_e_71_0); RowDefinition row_e_71_1 = new RowDefinition(); row_e_71_1.Height = new GridLength(1F, GridUnitType.Auto); e_71.RowDefinitions.Add(row_e_71_1); ColumnDefinition col_e_71_0 = new ColumnDefinition(); col_e_71_0.Width = new GridLength(1F, GridUnitType.Auto); e_71.ColumnDefinitions.Add(col_e_71_0); ColumnDefinition col_e_71_1 = new ColumnDefinition(); col_e_71_1.Width = new GridLength(1F, GridUnitType.Star); e_71.ColumnDefinitions.Add(col_e_71_1); ColumnDefinition col_e_71_2 = new ColumnDefinition(); col_e_71_2.Width = new GridLength(1F, GridUnitType.Auto); e_71.ColumnDefinitions.Add(col_e_71_2); Grid.SetColumnSpan(e_71, 3); Binding binding_e_71_DataContext = new Binding("Tetris"); e_71.SetBinding(Grid.DataContextProperty, binding_e_71_DataContext); // e_72 element Button e_72 = new Button(); e_71.Children.Add(e_72); e_72.Name = "e_72"; e_72.Height = 30F; e_72.Content = "Start"; Grid.SetColumnSpan(e_72, 3); Binding binding_e_72_Command = new Binding("StartCommand"); e_72.SetBinding(Button.CommandProperty, binding_e_72_Command); // e_73 element Grid e_73 = new Grid(); e_71.Children.Add(e_73); e_73.Name = "e_73"; RowDefinition row_e_73_0 = new RowDefinition(); row_e_73_0.Height = new GridLength(1F, GridUnitType.Auto); e_73.RowDefinitions.Add(row_e_73_0); ColumnDefinition col_e_73_0 = new ColumnDefinition(); e_73.ColumnDefinitions.Add(col_e_73_0); ColumnDefinition col_e_73_1 = new ColumnDefinition(); col_e_73_1.Width = new GridLength(70F, GridUnitType.Pixel); e_73.ColumnDefinitions.Add(col_e_73_1); ColumnDefinition col_e_73_2 = new ColumnDefinition(); e_73.ColumnDefinitions.Add(col_e_73_2); Grid.SetColumn(e_73, 1); Grid.SetRow(e_73, 1); // spPlayer1 element StackPanel spPlayer1 = new StackPanel(); e_73.Children.Add(spPlayer1); spPlayer1.Name = "spPlayer1"; spPlayer1.HorizontalAlignment = HorizontalAlignment.Right; spPlayer1.Orientation = Orientation.Vertical; // e_74 element TextBlock e_74 = new TextBlock(); spPlayer1.Children.Add(e_74); e_74.Name = "e_74"; Binding binding_e_74_Text = new Binding("Score"); e_74.SetBinding(TextBlock.TextProperty, binding_e_74_Text); // e_75 element TextBlock e_75 = new TextBlock(); spPlayer1.Children.Add(e_75); e_75.Name = "e_75"; Binding binding_e_75_Text = new Binding("Lines"); e_75.SetBinding(TextBlock.TextProperty, binding_e_75_Text); // e_76 element TextBlock e_76 = new TextBlock(); spPlayer1.Children.Add(e_76); e_76.Name = "e_76"; Binding binding_e_76_Text = new Binding("Level"); e_76.SetBinding(TextBlock.TextProperty, binding_e_76_Text); // e_77 element StackPanel e_77 = new StackPanel(); e_73.Children.Add(e_77); e_77.Name = "e_77"; e_77.HorizontalAlignment = HorizontalAlignment.Center; e_77.Orientation = Orientation.Vertical; Grid.SetColumn(e_77, 1); // e_78 element TextBlock e_78 = new TextBlock(); e_77.Children.Add(e_78); e_78.Name = "e_78"; e_78.Text = "SCORE"; // e_79 element TextBlock e_79 = new TextBlock(); e_77.Children.Add(e_79); e_79.Name = "e_79"; e_79.Text = "LINES"; // e_80 element TextBlock e_80 = new TextBlock(); e_77.Children.Add(e_80); e_80.Name = "e_80"; e_80.Text = "LEVEL"; // e_81 element StackPanel e_81 = new StackPanel(); e_73.Children.Add(e_81); e_81.Name = "e_81"; e_81.HorizontalAlignment = HorizontalAlignment.Left; e_81.Orientation = Orientation.Horizontal; // e_82 element TextBlock e_82 = new TextBlock(); e_81.Children.Add(e_82); e_82.Name = "e_82"; e_82.Text = "Use A,S,D,W for left, down, right, rotate"; items.Add(e_64); // e_83 element TabItem e_83 = new TabItem(); e_83.Name = "e_83"; e_83.Header = "User Control"; // e_84 element UserControlTest e_84 = new UserControlTest(); e_83.Content = e_84; e_84.Name = "e_84"; items.Add(e_83); return items; }
public override void Initialize() { if (decisions.Count != 0) { decisionPanel.transform.Find("InformationPanel").GetComponentInChildren <Text>().text = InfoText; switch (DecisionViewType) { case DecisionViewTypes.TextButtons: decisionPanel.GetComponent <RectTransform>().sizeDelta = new Vector3( 395, defaultWindowHeight + ((decisions.Count + 1) / 2) * buttonHeight ); buttonsHolder.GetComponent <RectTransform>().sizeDelta = new Vector3( 395, defaultWindowHeight + ((decisions.Count + 1) / 2) * buttonHeight ); break; case DecisionViewTypes.ImageButtons: decisionPanel.GetComponent <RectTransform>().sizeDelta = new Vector3( Mathf.Max(395, decisions.Count * 194 + (decisions.Count + 1) * 10), defaultWindowHeight + 300 + 10 ); buttonsHolder.GetComponent <RectTransform>().sizeDelta = new Vector3( decisions.Count * 194 + (decisions.Count + 1) * 10, defaultWindowHeight + 300 + 10 ); break; default: break; } buttonsHolder.transform.localPosition = new Vector2(-buttonsHolder.GetComponent <RectTransform>().sizeDelta.x / 2, -70); int i = 0; foreach (var decision in decisions) { GameObject prefab = null; switch (DecisionViewType) { case DecisionViewTypes.TextButtons: prefab = (GameObject)Resources.Load("Prefabs/DecisionButton", typeof(GameObject)); break; case DecisionViewTypes.ImageButtons: prefab = (GameObject)Resources.Load("Prefabs/SquadBuilder/SmallCardPanel", typeof(GameObject)); break; default: break; } GameObject button = MonoBehaviour.Instantiate(prefab, buttonsHolder.transform); switch (DecisionViewType) { case DecisionViewTypes.TextButtons: button.transform.localPosition = new Vector3((i % 2 == 0) ? 5 : 200, -buttonHeight * (i / 2), 0); button.GetComponentInChildren <Text>().text = decision.Name; button.GetComponentInChildren <Text>().color = (decision.IsRed) ? Color.red : Color.white; if (decision.HasTooltip) { Tooltips.AddTooltip(button, decision.Tooltip); } EventTrigger trigger = button.AddComponent <EventTrigger>(); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerClick; entry.callback.AddListener( (data) => { DecisionButtonWasPressed(decision, button); } ); trigger.triggers.Add(entry); break; case DecisionViewTypes.ImageButtons: button.transform.localPosition = new Vector3(10 * (i + 1) + i * 194, 0, 0); SmallCardPanel script = button.GetComponent <SmallCardPanel>(); script.Initialize( decision.Name, decision.Tooltip, delegate { GameMode.CurrentGameMode.TakeDecision(decision, button); }, decision.Count ); break; default: break; } button.name = "Button" + i; i++; } if (DecisionOwner == null) { DecisionOwner = Roster.GetPlayer(Phases.CurrentPhasePlayer); } if (ShowSkipButton) { UI.ShowSkipButton(); } else { UI.HideSkipButton(); } GameMode.CurrentGameMode.FinishSyncDecisionPreparation(); } }
public void Init(Game game, BattleHistory battleHistory) { this.game = game; // Copy the history, except for the moves; they'll be applied later. this.history = battleHistory; List <object> moveHistory = battleHistory.moves; this.history.moves = new List <object>(); Scenario scenario = this.history.scenario; BattleMap map = this.history.startingMap; this.mapDisplay.Init(this, map.size); // Build misc objects. { // Let us know when anything on the UI is clicked (and not handled by a button or something). EventTrigger eventTrigger = this.uiRefs.canvas.gameObject.AddComponent <EventTrigger>(); var entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerClick; entry.callback.AddListener((data) => { var button = ((PointerEventData)data).button; if (button == PointerEventData.InputButton.Left) { this.MouseEvent(null, MapDisplay.MouseEventType.Click); } else if (button == PointerEventData.InputButton.Right) { this.MouseEvent(null, MapDisplay.MouseEventType.RightClick); } }); eventTrigger.triggers.Add(entry); } // Build map. this.mapSize = map.size; this.tiles = new BattleTile[this.mapSize.x * this.mapSize.y]; TileData baseTileData = GameData.GetTile(map.baseTileName); TileData tileData = baseTileData; this.pathNetwork = new PathNetwork(); for (int y = 0; y < map.size.y; ++y) { for (int x = 0; x < map.size.x; ++x) { var pos = new Vector2i(x, y); tileData = baseTileData; foreach (var o in map.tileOverrides) { if (o.pos == pos) { tileData = GameData.GetTile(o.name); break; } } MapTile mapTile = this.mapDisplay.GetTile(pos); BattleTile newTile = mapTile.gameObject.AddComponent <BattleTile>(); newTile.Init(this, x, y, tileData); this.tiles[x + y * this.mapSize.x] = newTile; } } foreach (BattleTile tile in this.tiles) { for (int n = 0; n < 6; ++n) { BattleTile neighbor = tile.GetNeighbor(n); if (neighbor) { this.pathNetwork.ConnectNodes(tile, neighbor); } } if (tile.data.allowsMovement == false) { this.pathNetwork.SetNodeEnabled(tile, false); } } // Create teams and place mechs. var playerSpawns = new Stack <Vector2i>(); var enemySpawns = new Stack <Vector2i>(); foreach (var e in map.entities) { if (e.name == "PlayerMechSpawn") { playerSpawns.Push(e.pos); } else if (e.name == "EnemyMechSpawn") { enemySpawns.Push(e.pos); } } this.teams = new List <BattleTeam>(); foreach (Scenario.Team teamData in scenario.teams) { BattleTeam team = new BattleTeam(); this.teams.Add(team); team.mechs = new List <BattleMech>(); team.isPlayer = teamData.isPlayer; if (team.isPlayer == false) { team.ai = new BattleTeamAi(team); } team.visibleTiles = new bool[this.tiles.Length]; foreach (Scenario.Mech m in teamData.mechs) { MechData mechData = GameData.GetMech(m.mechName); Vector2i spawnPos = team.isPlayer ? playerSpawns.Pop() : enemySpawns.Pop(); BattleTile tile = this.GetTile(spawnPos); GameObject mechGO = new GameObject(string.Concat("Mech: ", mechData.name)); mechGO.transform.parent = tile.transform; BattleMech mech = mechGO.AddComponent <BattleMech>(); mech.Init(this, mechData); mech.PlaceAtMapTile(tile.mapTile); mech.SetDirection(m.direction); Assert.IsTrue(tile.mech == null); tile.mech = mech; mech.tile = tile; if (team.isPlayer == false) { mech.ai = new BattleMechAi(mech); } this.pathNetwork.SetNodeEnabled(tile, false); team.mechs.Add(mech); mech.team = team; } } this.currentTeamIndex = this.history.scenario.startingTeamIndex; this.currentTeam = this.teams[this.currentTeamIndex]; // UI stuff. this.uiRefs.advanceAiButton.interactable = false; this.uiRefs.tileInfoBorder.SetActive(false); this.uiRefs.mechTab.SetActive(false); this.uiRefs.pilotTab.SetActive(false); this.uiRefs.tileTab.SetActive(false); this.uiRefs.actionsPanel.SetActive(false); Utility.AddButtonClickListener(this.uiRefs.finishTurnButton, this.UnitListButtonPressed); Utility.AddButtonClickListener(this.uiRefs.advanceAiButton, this.UnitListButtonPressed); Utility.AddButtonClickListener(this.uiRefs.mechTabButton, this.TileInfoTabButtonClicked); Utility.AddButtonClickListener(this.uiRefs.pilotTabButton, this.TileInfoTabButtonClicked); Utility.AddButtonClickListener(this.uiRefs.tileTabButton, this.TileInfoTabButtonClicked); Utility.AddButtonClickListener(this.uiRefs.moveButton, this.ActionButtonPressed); Utility.AddButtonClickListener(this.uiRefs.setTargetButton, this.ActionButtonPressed); Utility.AddButtonClickListener(this.uiRefs.fireNowButton, this.ActionButtonPressed); Utility.AddToggleListener(this.uiRefs.fireAutoToggle, this.ActionToggleChanged); Utility.AddButtonHoverListener(this.uiRefs.fireNowButton, this.ActionButtonHoverChanged); this.BringTileTabButtonToFront(this.uiRefs.mechTabButton); this.UpdateRightPanel(); this.apTextOriginalColor = this.uiRefs.apText.color; // Execute any moves to start with. foreach (object o in moveHistory) { this.ExecuteMove(o); } this.currentTeamIndex = battleHistory.currentTeamIndex; this.currentTeam = this.teams[this.currentTeamIndex]; // Start first state. this.UpdateFogOfWar(); if (this.currentTeam.isPlayer) { this.SetState(BattleState.SelectingAction); } else { this.SetState(BattleState.AiControl); } }
private void Move(MoveDirection dir) { int currentIndex = GetMapIndex(listGameObj[3].transform.Find("SceneImage").GetComponent <Image>().overrideSprite.name); switch (dir) { case MoveDirection.Right: GameObject loadObjLeft = Resources.Load("UI/MapPrefabs/Map0") as GameObject; GameObject newObjLeft = Instantiate(loadObjLeft); EventTrigger ETL = newObjLeft.AddComponent <EventTrigger>(); EventTrigger.Entry entryL = new EventTrigger.Entry(); entryL.eventID = EventTriggerType.PointerDown; entryL.callback.AddListener((data) => { if (!isTouch) { isTouch = true; } }); ETL.triggers.Add(entryL); newObjLeft.transform.SetParent(GameObject.Find("Canvas/Window/CreateWindow/Maps").transform, false); newObjLeft.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f); newObjLeft.transform.localPosition = listGameObjPos[listGameObjPos.Count - 1] + new Vector3(250, 0, 0); newObjLeft.GetComponent <Transform>().SetSiblingIndex(0); //string nameLeft = GetMapNamePath(listGameObj[listGameObj.Count - 1 - 3].transform.Find("SceneImage").GetComponent<Image>().overrideSprite.name); string nameLeft = GetMapNamePath(listMapName[currentIndex + 4 > listMapName.Count - 1 ? (currentIndex + 4) % listMapName.Count : currentIndex + 4]); newObjLeft.transform.Find("SceneImage").GetComponent <Image>().overrideSprite = Resources.Load(nameLeft, typeof(Sprite)) as Sprite; listGameObj.Add(newObjLeft); Sequence moveLeft = DOTween.Sequence(); for (int i = 1; i < listGameObj.Count; i++) { int x = (int)listGameObj[i].transform.localPosition.x; moveLeft.Insert(0, listGameObj[i].transform.DOLocalMoveX(x - 250, 0.5f)).SetRelative().Pause(); if (i == 1 || i == 7) { moveLeft.Insert(0, listGameObj[i].transform.DOScale(new Vector3(0.7f, 0.7f, 0.7f), 0.25f)).Pause(); ChangeSiblingIndex(i, 0); } else if (i == 2 || i == 6) { moveLeft.Insert(0, listGameObj[i].transform.DOScale(new Vector3(0.8f, 0.8f, 0.8f), 0.25f)).Pause(); ChangeSiblingIndex(i, 1); } else if (i == 3 || i == 5) { moveLeft.Insert(0, listGameObj[i].transform.DOScale(new Vector3(0.9f, 0.9f, 0.9f), 0.25f)).Pause(); ChangeSiblingIndex(i, 2); } else if (i == 4) { moveLeft.Insert(0, listGameObj[i].transform.DOScale(new Vector3(1f, 1f, 1f), 0.25f)).Pause(); ChangeSiblingIndex(i, 3); GameObject.Find("Canvas/Window/CreateWindow/Maps/MapName").GetComponent <Text>().text = GetMapName(listGameObj[i].transform.Find("SceneImage").GetComponent <Image>().overrideSprite.name); Mapindex = GetMapIndex(listGameObj[i].transform.Find("SceneImage").GetComponent <Image>().overrideSprite.name); } } moveLeft.Play().OnComplete(() => { isMove = false; }); Destroy(listGameObj[0]); listGameObj.RemoveAt(0); break; case MoveDirection.Left: GameObject loadObjRight = Resources.Load("UI/MapPrefabs/Map0") as GameObject; GameObject newObjRight = Instantiate(loadObjRight); EventTrigger ETR = newObjRight.AddComponent <EventTrigger>(); EventTrigger.Entry entryR = new EventTrigger.Entry(); entryR.eventID = EventTriggerType.PointerDown; entryR.callback.AddListener((data) => { if (!isTouch) { isTouch = true; } }); ETR.triggers.Add(entryR); newObjRight.transform.SetParent(GameObject.Find("Canvas/Window/CreateWindow/Maps").transform, false); newObjRight.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f); newObjRight.transform.localPosition = listGameObjPos[0] + new Vector3(-250, 0, 0); newObjRight.GetComponent <Transform>().SetSiblingIndex(0); //string nameRight = GetMapNamePath(listGameObj[0 + 3].transform.Find("SceneImage").GetComponent<Image>().overrideSprite.name); string nameRight = GetMapNamePath(listMapName[currentIndex - 4 < 0 ? listMapName.Count + (currentIndex - 4) : currentIndex - 4]); newObjRight.transform.Find("SceneImage").GetComponent <Image>().overrideSprite = Resources.Load(nameRight, typeof(Sprite)) as Sprite; listGameObj.Insert(0, newObjRight); Sequence moveRight = DOTween.Sequence(); for (int i = 0; i < listGameObj.Count - 1; i++) { int x = (int)listGameObj[i].transform.localPosition.x; moveRight.Insert(0, listGameObj[i].transform.DOLocalMoveX(x + 250, 0.5f)).Pause(); if (i == 0 || i == 6) { moveRight.Insert(0, listGameObj[i].transform.DOScale(new Vector3(0.7f, 0.7f, 0.7f), 0.25f)).Pause(); ChangeSiblingIndex(i, 0); } else if (i == 1 || i == 5) { moveRight.Insert(0, listGameObj[i].transform.DOScale(new Vector3(0.8f, 0.8f, 0.8f), 0.25f)).Pause(); ChangeSiblingIndex(i, 1); } else if (i == 2 || i == 4) { moveRight.Insert(0, listGameObj[i].transform.DOScale(new Vector3(0.9f, 0.9f, 0.9f), 0.25f)).Pause(); ChangeSiblingIndex(i, 2); } else if (i == 3) { moveRight.Insert(0, listGameObj[i].transform.DOScale(new Vector3(1f, 1f, 1f), 0.25f)).Pause(); ChangeSiblingIndex(i, 3); GameObject.Find("Canvas/Window/CreateWindow/Maps/MapName").GetComponent <Text>().text = GetMapName(listGameObj[i].transform.Find("SceneImage").GetComponent <Image>().overrideSprite.name); Mapindex = GetMapIndex(listGameObj[i].transform.Find("SceneImage").GetComponent <Image>().overrideSprite.name); } } moveRight.Play().OnComplete(() => { isMove = false; }); Destroy(listGameObj[listGameObj.Count - 1]); listGameObj.RemoveAt(listGameObj.Count - 1); break; } }
//Events Initialization For Steering Wheel. void SteeringWheelEventsInit(){ eventTrigger = steeringWheelGameObject.GetComponent<EventTrigger>(); var a = new EventTrigger.TriggerEvent(); a.AddListener( data => { var evData = (PointerEventData)data; data.Use(); steeringWheelPressed = true; steeringWheelTouchPos = evData.position; steeringWheelTempAngle = Vector2.Angle(Vector2.up, evData.position - steeringWheelCenter); }); eventTrigger.triggers.Add(new EventTrigger.Entry{callback = a, eventID = EventTriggerType.PointerDown}); var b = new EventTrigger.TriggerEvent(); b.AddListener( data => { var evData = (PointerEventData)data; data.Use(); steeringWheelTouchPos = evData.position; }); eventTrigger.triggers.Add(new EventTrigger.Entry{callback = b, eventID = EventTriggerType.Drag}); var c = new EventTrigger.TriggerEvent(); c.AddListener( data => { steeringWheelPressed = false; }); eventTrigger.triggers.Add(new EventTrigger.Entry{callback = c, eventID = EventTriggerType.EndDrag}); }
public void Refresh() { List <string> itemList = Managers.Inventory.GetItemList(); // display inventory items int len = itemIcons.Length; for (int i = 0; i < len; i++) { if (i < itemList.Count) { itemIcons[i].gameObject.SetActive(true); itemLabels[i].gameObject.SetActive(true); string item = itemList[i]; Sprite sprite = Resources.Load <Sprite>("Icons/" + item); itemIcons[i].sprite = sprite; itemIcons[i].SetNativeSize(); int count = Managers.Inventory.GetItemCount(item); string message = "x" + count; if (item == Managers.Inventory.equippedItem) { message = "Equipped\n" + message; } itemLabels[i].text = message; // enable clicking on icons EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerClick; entry.callback.AddListener((BaseEventData data) => { OnItem(item); }); EventTrigger trigger = itemIcons[i].GetComponent <EventTrigger>(); /* IMPORTANT * Unity 5.1 required an update in this code. In Unity 5.0 it said: * trigger.delegates.Clear(); * trigger.delegates.Add(entry); */ trigger.triggers.Clear(); trigger.triggers.Add(entry); } else { itemIcons[i].gameObject.SetActive(false); itemLabels[i].gameObject.SetActive(false); } } // display current selection if (!itemList.Contains(_curItem)) { _curItem = null; } if (_curItem == null) { curItemLabel.gameObject.SetActive(false); equipButton.gameObject.SetActive(false); useButton.gameObject.SetActive(false); } else { curItemLabel.gameObject.SetActive(true); equipButton.gameObject.SetActive(true); if (_curItem == "health") { useButton.gameObject.SetActive(true); } else { useButton.gameObject.SetActive(false); } curItemLabel.text = _curItem + ":"; } }
private void Awake() { // 컬레 데이터를 자기 있는 오브젝트를 찾는다// UI_BaseColorSetting cSet = GameObject .Find(getColorObjName) .GetComponent <UI_BaseColorSetting>(); // 각각의 컬러를 외부에서 가져와 지정한다.// baseColor = cSet.GetBaseColor(); lineColor = cSet.GetLineColor01(); iconColor = cSet.GetIconColor(); // 베이스가 되는 이미지를 지정한다.// btnBase = GetComponent <Image>(); // 베이스의 아웃라인이 되는 이미지를 지정한다.// int chCount = transform.childCount; for (int i = 0; i < chCount; i++) { btnLine = transform.GetChild(i).GetComponent <Image>(); if (btnLine != null) { string cName = btnLine.name; if (cName.ToLower().Contains("outline")) { break; } } } // 베이스의 아이콘이 되는 이미지를 지정한다.// for (int i = 0; i < chCount; i++) { btnIcon = transform.GetChild(i).GetComponent <Image>(); if (btnIcon != null) { string cName = btnIcon.name; if (cName.ToLower().Contains("icon")) { break; } } } // 이벤트 트리거를 세팅한다.// // (이벤트 트리거를 컴포넌트로 붙인다.)// if (GetComponent <EventTrigger>() == null) { gameObject.AddComponent <EventTrigger>(); } EventTrigger trigger = GetComponent <EventTrigger>(); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerClick; //Debug.Log(name + "트리거 내용 지정"); entry.callback.AddListener((eventData) => { ActivationButton(); }); //Debug.Log("트리거 생성"); trigger.triggers.Add(entry); }
private void listGameObjInit() { listGameObj = new List <GameObject>(); listGameObjPos = new List <Vector3>(); listGameObjPos.Add(new Vector3(-750, 0, 0)); listGameObjPos.Add(new Vector3(-500, 0, 0)); listGameObjPos.Add(new Vector3(-250, 0, 0)); listGameObjPos.Add(Vector3.zero); listGameObjPos.Add(new Vector3(250, 0, 0)); listGameObjPos.Add(new Vector3(500, 0, 0)); listGameObjPos.Add(new Vector3(750, 0, 0)); for (int i = 0; i < listGameObjPos.Count; i++) { GameObject loadObj = Resources.Load("UI/MapPrefabs/Map0") as GameObject; GameObject temp = Instantiate(loadObj); EventTrigger ET = temp.AddComponent <EventTrigger>(); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerDown; entry.callback.AddListener((data) => { if (!isTouch) { isTouch = true; } }); ET.triggers.Add(entry); temp.transform.SetParent(GameObject.Find("Canvas/Window/CreateWindow/Maps").transform, false); if (i == 3) { temp.GetComponent <Transform>().SetSiblingIndex(3); temp.transform.localScale = Vector3.one; temp.transform.Find("SceneImage").GetComponent <Image>().overrideSprite = Resources.Load(GetMapNamePath(listMapName[0]), typeof(Sprite)) as Sprite; GameObject.Find("Canvas/Window/CreateWindow/Maps/MapName").GetComponent <Text>().text = GetMapName(temp.transform.Find("SceneImage").GetComponent <Image>().overrideSprite.name); Mapindex = GetMapIndex(temp.transform.Find("SceneImage").GetComponent <Image>().overrideSprite.name); } else if (i == 2 || i == 4) { temp.GetComponent <Transform>().SetSiblingIndex(2); temp.transform.localScale = new Vector3(0.9f, 0.9f, 0.9f); if (i == 2) { temp.transform.Find("SceneImage").GetComponent <Image>().overrideSprite = Resources.Load(GetMapNamePath(listMapName[listMapName.Count - 1]), typeof(Sprite)) as Sprite; } else if (i == 4) { temp.transform.Find("SceneImage").GetComponent <Image>().overrideSprite = Resources.Load(GetMapNamePath(listMapName[1]), typeof(Sprite)) as Sprite; } } else if (i == 1 || i == 5) { temp.GetComponent <Transform>().SetSiblingIndex(1); temp.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f); if (i == 1) { temp.transform.Find("SceneImage").GetComponent <Image>().overrideSprite = Resources.Load(GetMapNamePath(listMapName[listMapName.Count - 1 - 1]), typeof(Sprite)) as Sprite; } else if (i == 5) { temp.transform.Find("SceneImage").GetComponent <Image>().overrideSprite = Resources.Load(GetMapNamePath(listMapName[2]), typeof(Sprite)) as Sprite; } } else if (i == 0 || i == 6) { temp.GetComponent <Transform>().SetSiblingIndex(0); temp.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f); if (i == 0) { temp.transform.Find("SceneImage").GetComponent <Image>().overrideSprite = Resources.Load(GetMapNamePath(listMapName[listMapName.Count - 1 - 2]), typeof(Sprite)) as Sprite; } else if (i == 6) { temp.transform.Find("SceneImage").GetComponent <Image>().overrideSprite = Resources.Load(GetMapNamePath(listMapName[3]), typeof(Sprite)) as Sprite; } } temp.transform.localPosition = listGameObjPos[i]; listGameObj.Add(temp); } }
public EventDispatch() { _eventDispatch = new EventTrigger(); }
private void SceneLoaded(Scene scene, LoadSceneMode lsm) { try { if (_uim != null || ModLoader.LoadedMods == null || UIManager.instance == null) { return; } } catch (NullReferenceException) { //Do Nothing. Something inside of UIManager.instance breaks even if you try to check for null on it. return; } _uim = UIManager.instance; //ADD MODS TO OPTIONS MENU MenuButton defButton = (MenuButton)_uim.optionsMenuScreen.defaultHighlight; MenuButton modButton = Object.Instantiate(defButton.gameObject).GetComponent <MenuButton>(); Navigation nav = modButton.navigation; nav.selectOnUp = defButton.FindSelectableOnDown().FindSelectableOnDown().FindSelectableOnDown().FindSelectableOnDown(); nav.selectOnDown = defButton.FindSelectableOnDown().FindSelectableOnDown().FindSelectableOnDown().FindSelectableOnDown().FindSelectableOnDown(); modButton.navigation = nav; nav = modButton.FindSelectableOnUp().navigation; nav.selectOnDown = modButton; modButton.FindSelectableOnUp().navigation = nav; nav = modButton.FindSelectableOnDown().navigation; nav.selectOnUp = modButton; modButton.FindSelectableOnDown().navigation = nav; modButton.name = "Mods"; modButton.transform.SetParent(modButton.FindSelectableOnUp().transform.parent); modButton.transform.localPosition = new Vector2(0, -120); modButton.transform.localScale = modButton.FindSelectableOnUp().transform.localScale; Object.Destroy(modButton.gameObject.GetComponent <AutoLocalizeTextUI>()); modButton.gameObject.transform.Find("Text").GetComponent <Text>().text = "Mods"; //ADD MODS TO OPTIONS MENU //SETUP MOD MENU GameObject go = Object.Instantiate(_uim.optionsMenuScreen.gameObject); ModMenuScreen = go.GetComponent <MenuScreen>(); ModMenuScreen.title = ModMenuScreen.gameObject.transform.Find("Title").GetComponent <CanvasGroup>(); ModMenuScreen.topFleur = ModMenuScreen.gameObject.transform.Find("TopFleur").GetComponent <Animator>(); ModMenuScreen.content = ModMenuScreen.gameObject.transform.Find("Content").GetComponent <CanvasGroup>(); ModMenuScreen.title.gameObject.GetComponent <Text>().text = "Mods"; Object.Destroy(ModMenuScreen.title.gameObject.GetComponent <AutoLocalizeTextUI>()); ModMenuScreen.transform.SetParent(_uim.optionsMenuScreen.gameObject.transform.parent); ModMenuScreen.transform.localPosition = _uim.optionsMenuScreen.gameObject.transform.localPosition; ModMenuScreen.transform.localScale = _uim.optionsMenuScreen.gameObject.transform.localScale; List <ITogglableMod> managableMods = ModLoader.LoadedMods.Where(x => x is ITogglableMod).Select(x => x).Cast <ITogglableMod>().ToList(); //modMenuScreen.content = modMenuScreen.gameObject.transform.GetChild() ModMenuScreen.defaultHighlight = ModMenuScreen.content.gameObject.transform.GetChild(0).GetChild(0).GetComponent <MenuButton>(); Object.Destroy(ModMenuScreen.defaultHighlight.FindSelectableOnDown().FindSelectableOnDown().FindSelectableOnDown().FindSelectableOnDown().FindSelectableOnDown().gameObject.transform.parent.gameObject); Object.Destroy(ModMenuScreen.defaultHighlight.FindSelectableOnDown().FindSelectableOnDown().FindSelectableOnDown().FindSelectableOnDown().gameObject.transform.parent.gameObject); Object.Destroy(ModMenuScreen.defaultHighlight.FindSelectableOnDown().FindSelectableOnDown().FindSelectableOnDown().gameObject.transform.parent.gameObject); Object.Destroy(ModMenuScreen.defaultHighlight.FindSelectableOnDown().FindSelectableOnDown().gameObject.transform.parent.gameObject); Object.Destroy(ModMenuScreen.defaultHighlight.FindSelectableOnDown().gameObject.transform.parent.gameObject); Back = ModMenuScreen.defaultHighlight.FindSelectableOnUp(); GameObject item = _uim.videoMenuScreen.defaultHighlight.FindSelectableOnDown().gameObject; Object.DestroyImmediate(item.GetComponent <MenuOptionHorizontal>()); Object.DestroyImmediate(item.GetComponent <MenuSetting>()); Object.DestroyImmediate(ModMenuScreen.content.GetComponent <VerticalLayoutGroup>()); Object.Destroy(ModMenuScreen.defaultHighlight.gameObject.transform.parent.gameObject); try { if (managableMods.Count > 0) { ModArray = new Selectable[managableMods.Count]; for (int i = 0; i < managableMods.Count; i++) { GameObject menuItemParent = Object.Instantiate(item.gameObject); FauxMenuOptionHorizontal menuItem = menuItemParent.AddComponent <FauxMenuOptionHorizontal>(); menuItem.navigation = Navigation.defaultNavigation; int modIndex = i; //Manages what should happen when the menu option changes (the user clicks and the mod is toggled On/Off) menuItem.OnUpdate += optionIndex => { ITogglableMod mod = managableMods[modIndex]; string name = mod.GetName(); if (!ModHooks.Instance.GlobalSettings.ModEnabledSettings.ContainsKey(name)) { ModHooks.Instance.GlobalSettings.ModEnabledSettings.Add(name, true); } if (optionIndex == 1) { ModLoader.UnloadMod(mod); } else { ModLoader.LoadMod(mod, true); } }; //dataDump(modArray[i].gameObject, 1); menuItem.OptionList = new[] { "On", "Off" }; menuItem.OptionText = menuItem.gameObject.transform.GetChild(1).GetComponent <Text>(); menuItem.SelectedOptionIndex = ModHooks.Instance.GlobalSettings.ModEnabledSettings[managableMods[i].GetName()] ? 0 : 1; menuItem.LocalizeText = false; menuItem.SheetTitle = managableMods[i].GetName(); Object.DestroyImmediate(menuItem.transform.Find("Label") .GetComponent <AutoLocalizeTextUI>()); menuItem.transform.Find("Label").GetComponent <Text>().text = managableMods[i].GetName(); menuItem.leftCursor = menuItem.transform.Find("CursorLeft").GetComponent <Animator>(); menuItem.rightCursor = menuItem.transform.Find("CursorRight").GetComponent <Animator>(); menuItem.gameObject.name = managableMods[i].GetName(); RectTransform rt = menuItemParent.GetComponent <RectTransform>(); rt.SetParent(ModMenuScreen.content.transform); rt.localScale = new Vector3(2, 2, 2); rt.sizeDelta = new Vector2(960, 120); rt.anchoredPosition = new Vector2(0, (766 / 2) - 90 - (150 * i)); rt.anchorMin = new Vector2(0.5f, 1.0f); rt.anchorMax = new Vector2(0.5f, 1.0f); //Image img = menuItem.AddComponent<Image>(); //img.sprite = nullSprite(); menuItem.cancelAction = Patches.CancelAction.QuitModMenu; ModArray[i] = menuItem; //AutoLocalizeTextUI localizeUI = modArray[i].GetComponent<AutoLocalizeTextUI>(); //modArray[i].transform.GetChild(0).GetComponent<Text>().text = mods[i]; //GameObject.Destroy(localizeUI); } Navigation[] navs = new Navigation[ModArray.Length]; for (int i = 0; i < ModArray.Length; i++) { navs[i] = new Navigation { mode = Navigation.Mode.Explicit, selectOnUp = i == 0 ? Back : ModArray[i - 1], selectOnDown = i == ModArray.Length - 1 ? Back : ModArray[i + 1] }; ModArray[i].navigation = navs[i]; } ModMenuScreen.defaultHighlight = ModArray[0]; Navigation nav2 = Back.navigation; nav2.selectOnUp = ModArray[ModArray.Length - 1]; nav2.selectOnDown = ModArray[0]; Back.navigation = nav2; } } catch (Exception ex) { LogError(ex); } ((Patches.MenuSelectable)Back).cancelAction = Patches.CancelAction.QuitModMenu; EventTrigger backEvents = Back.gameObject.GetComponent <EventTrigger>(); backEvents.triggers = new List <EventTrigger.Entry>(); EventTrigger.Entry backSubmit = new EventTrigger.Entry { eventID = EventTriggerType.Submit }; backSubmit.callback.AddListener(data => { _fauxUim.UIquitModMenu(); }); backEvents.triggers.Add(backSubmit); EventTrigger.Entry backClick = new EventTrigger.Entry { eventID = EventTriggerType.PointerClick }; backClick.callback.AddListener(data => { _fauxUim.UIquitModMenu(); }); backEvents.triggers.Add(backClick); //SETUP MOD MENU LogDebug("About to add the events to the menu option"); //SETUP MOD BUTTON TO RESPOND TO SUBMIT AND CANCEL EVENTS CORRECTLY EventTrigger events = modButton.gameObject.GetComponent <EventTrigger>(); events.triggers = new List <EventTrigger.Entry>(); EventTrigger.Entry submit = new EventTrigger.Entry { eventID = EventTriggerType.Submit }; submit.callback.AddListener(data => { _fauxUim.UIloadModMenu(); }); events.triggers.Add(submit); EventTrigger.Entry click = new EventTrigger.Entry { eventID = EventTriggerType.PointerClick }; click.callback.AddListener(data => { _fauxUim.UIloadModMenu(); }); events.triggers.Add(click); //SETUP MOD BUTTON TO RESPOND TO SUBMIT AND CANCEL EVENTS CORRECTLY }
internal static void AddEntryToEventTrigger(EventTrigger eventTrigger, EventTrigger.Entry entry) { #if UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 if (eventTrigger.delegates == null) { eventTrigger.delegates = new List<EventTrigger.Entry>(); } eventTrigger.delegates.Add(entry); #else if (eventTrigger.triggers == null) { eventTrigger.triggers = new List<EventTrigger.Entry>(); } eventTrigger.triggers.Add(entry); #endif }
public EventDispatch(EventTrigger eventDispatch) { _eventDispatch = eventDispatch; }
public static void RemoveAllEventTriggers(EventTrigger eventTrigger) { eventTrigger.triggers.RemoveAll(e => true); }
protected override void UpdateItemArea() { ItemBlocks.Clear(); foreach (Transform child in itemArea.transform) { GameObject.Destroy(child.gameObject); } foreach (Transform child in inventoryHolder.transform) { GameObject.Destroy(child.gameObject); } for (int i = 0; i < filteredItemList.Count; i++) { GameObject go = Instantiate(ItemBlock); int id = i; go.AddComponent(typeof(EventTrigger)); EventTrigger trigger = go.GetComponent <EventTrigger>(); EventTrigger.Entry clickEntry = new EventTrigger.Entry(); clickEntry.eventID = EventTriggerType.PointerClick; clickEntry.callback.AddListener((eventData) => { CleanSelection(); ((eventData as PointerEventData).pointerPress as GameObject).GetComponentsInChildren <Image>()[0].color = buySelectionColor; UpdateText(id); }); trigger.triggers.Add(clickEntry); Sprite itemSprite = new Sprite(); switch (filteredItemList[i].Item_type) { case Constants.ItemIndex.ARMOR: itemSprite = Armors[filteredItemList[i].Sprite_index]; break; case Constants.ItemIndex.HELMET: itemSprite = Helmets[filteredItemList[i].Sprite_index]; break; case Constants.ItemIndex.LEFT_HAND: itemSprite = LeftHands[filteredItemList[i].Sprite_index]; break; case Constants.ItemIndex.PANTS: itemSprite = Pants[filteredItemList[i].Sprite_index]; break; case Constants.ItemIndex.RIGHT_HAND: itemSprite = RightHands[filteredItemList[i].Sprite_index]; break; case Constants.ItemIndex.SHOES: itemSprite = Shoes[filteredItemList[i].Sprite_index]; break; } go.GetComponentsInChildren <Image>()[1].sprite = itemSprite; go.transform.SetParent(itemArea.transform, false); ItemBlocks.Add(go); } for (int q = 0; q < playerItens.Count; q++) { GameObject go = Instantiate(ItemBlock); int id = q; go.AddComponent(typeof(EventTrigger)); EventTrigger trigger = go.GetComponent <EventTrigger>(); EventTrigger.Entry clickEntry = new EventTrigger.Entry(); clickEntry.eventID = EventTriggerType.PointerClick; clickEntry.callback.AddListener((eventData) => { CleanSelection(); ((eventData as PointerEventData).pointerPress as GameObject).GetComponentsInChildren <Image>()[0].color = sellSelectionColor; UpdateSellText(id); }); trigger.triggers.Add(clickEntry); Sprite itemSprite = new Sprite(); switch (playerItens[q].Item_type) { case Constants.ItemIndex.ARMOR: itemSprite = Armors[playerItens[q].Sprite_index]; break; case Constants.ItemIndex.HELMET: itemSprite = Helmets[playerItens[q].Sprite_index]; break; case Constants.ItemIndex.LEFT_HAND: itemSprite = LeftHands[playerItens[q].Sprite_index]; break; case Constants.ItemIndex.PANTS: itemSprite = Pants[playerItens[q].Sprite_index]; break; case Constants.ItemIndex.RIGHT_HAND: itemSprite = RightHands[playerItens[q].Sprite_index]; break; case Constants.ItemIndex.SHOES: itemSprite = Shoes[playerItens[q].Sprite_index]; break; } go.GetComponentsInChildren <Image>()[1].sprite = itemSprite; go.transform.SetParent(inventoryHolder.transform, false); ItemBlocks.Add(go); } }