protected override void OnDestroy()
        {
            text = null;
            button = null;

            base.OnDestroy();
        }
Пример #2
0
 internal Button (GameObject parent, string content, bool visible)
     : base (Addon.Instantiate (parent, "Button"), visible)
 {
     button = GameObject.GetComponent<UnityEngine.UI.Button> ();
     text = new Text (GameObject.GetChild ("Text"));
     text.Content = content;
     button.onClick.AddListener (() => {
         Clicked = true;
     });
 }
        protected override void Awake()
        {
            //Get Text component
            text = GetComponentInChildren<UnityEngine.UI.Text>();

            //Get Button component
            button = GetComponentInChildren<UnityEngine.UI.Button>();
            if (button == null)
                throw new Exception("Button component cannot be not found !!");

            base.Awake();
        }
Пример #4
0
 public override void OnEnter()
 {
     GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
     if (go!=null)
     {
         button = go.GetComponent<UnityEngine.UI.Button>();
         if (button!=null)
         {
             button.onClick.AddListener(DoOnClick);
         }else{
             LogError("Missing UI.Button on "+go.name);
         }
     }else{
         LogError("Missing GameObject ");
     }
 }
Пример #5
0
 private void Awake()
 {
     button = GetComponentInChildren <Button>();
     button.onClick.AddListener(OnClick);
 }
Пример #6
0
    public void ReplaceUI(UnityEngine.CanvasGroup newGameControlsCanvasGroup, UnityEngine.CanvasGroup newEndGameCanvasGroup, TMPro.TextMeshProUGUI newGameResultText, UnityEngine.UI.Button newAttackButton, UnityEngine.UI.Button newSwitchButton, UnityEngine.UI.Button newRestartGameButton)
    {
        var index     = GameComponentsLookup.UI;
        var component = (UIComponent)CreateComponent(index, typeof(UIComponent));

        component.gameControlsCanvasGroup = newGameControlsCanvasGroup;
        component.endGameCanvasGroup      = newEndGameCanvasGroup;
        component.gameResultText          = newGameResultText;
        component.attackButton            = newAttackButton;
        component.switchButton            = newSwitchButton;
        component.restartGameButton       = newRestartGameButton;
        ReplaceComponent(index, component);
    }
        protected override bool ExecCommand(StoryInstance instance, long delta)
        {
            UnityEngine.GameObject obj = m_Obj.Value as UnityEngine.GameObject;
            if (null != obj)
            {
                UiStoryInitializer initer = obj.GetComponent <UiStoryInitializer>();
                if (null != initer)
                {
                    UiStoryEventHandler handler = obj.GetComponent <UiStoryEventHandler>();
                    if (null == handler)
                    {
                        handler = obj.AddComponent <UiStoryEventHandler>();
                    }
                    if (null != handler)
                    {
                        int ct = m_VarInfos.Count;
                        for (int ix = 0; ix < ct; ++ix)
                        {
                            string name = m_VarInfos[ix].m_VarName.Value;
                            string path = m_VarInfos[ix].m_ControlPath.Value;
                            UnityEngine.GameObject ctrl = Utility.FindChildObjectByPath(obj, path);
                            AddVariable(instance, name, ctrl);
                        }

                        handler.WindowName = initer.WindowName;
                        var list = m_Inputs;
                        for (int k = 0; k < list.Count; ++k)
                        {
                            string path = list[k].Value;
                            var    comp = Utility.FindComponentInChildren <UnityEngine.UI.InputField>(obj, path);
                            handler.InputLabels.Add(comp);
                        }
                        list = m_Toggles;
                        for (int k = 0; k < list.Count; ++k)
                        {
                            string path = list[k].Value;
                            var    comp = Utility.FindComponentInChildren <UnityEngine.UI.Toggle>(obj, path);
                            handler.InputToggles.Add(comp);
                        }
                        list = m_Sliders;
                        for (int k = 0; k < list.Count; ++k)
                        {
                            string path = list[k].Value;
                            var    comp = Utility.FindComponentInChildren <UnityEngine.UI.Slider>(obj, path);
                            handler.InputSliders.Add(comp);
                        }
                        list = m_DropDowns;
                        for (int k = 0; k < list.Count; ++k)
                        {
                            string path = list[k].Value;
                            var    comp = Utility.FindComponentInChildren <UnityEngine.UI.Dropdown>(obj, path);
                            handler.InputDropdowns.Add(comp);
                        }

                        ct = m_EventInfos.Count;
                        for (int ix = 0; ix < ct; ++ix)
                        {
                            string evt  = m_EventInfos[ix].m_Event.Value;
                            string tag  = m_EventInfos[ix].m_Tag.Value;
                            string path = m_EventInfos[ix].m_Path.Value;
                            if (evt == "button")
                            {
                                UnityEngine.UI.Button button = Utility.FindComponentInChildren <UnityEngine.UI.Button>(obj, path);
                                button.onClick.AddListener(() => { handler.OnClickHandler(tag); });
                            }
                            else if (evt == "toggle")
                            {
                                UnityEngine.UI.Toggle toggle = Utility.FindComponentInChildren <UnityEngine.UI.Toggle>(obj, path);
                                toggle.onValueChanged.AddListener((bool val) => { handler.OnToggleHandler(tag, val); });
                            }
                            else if (evt == "dropdown")
                            {
                                UnityEngine.UI.Dropdown dropdown = Utility.FindComponentInChildren <UnityEngine.UI.Dropdown>(obj, path);
                                dropdown.onValueChanged.AddListener((int val) => { handler.OnDropdownHandler(tag, val); });
                            }
                            else if (evt == "slider")
                            {
                                UnityEngine.UI.Slider slider = Utility.FindComponentInChildren <UnityEngine.UI.Slider>(obj, path);
                                slider.onValueChanged.AddListener((float val) => { handler.OnSliderHandler(tag, val); });
                            }
                            else if (evt == "input")
                            {
                                UnityEngine.UI.InputField input = Utility.FindComponentInChildren <UnityEngine.UI.InputField>(obj, path);
                                input.onEndEdit.AddListener((string val) => { handler.OnInputHandler(tag, val); });
                            }
                        }
                    }
                }
            }
            return(false);
        }
Пример #8
0
        /// <summary>
        /// Draws the RT add node to queue on the maneuver gizmo
        /// </summary>
        public void Draw()
        {
            if (!this.mShowOverlay)
            {
                return;
            }

            if (this.mMap != null && FlightGlobals.ActiveVessel != null)
            {
                // if we r on local control, skip these part
                if (FlightGlobals.ActiveVessel.HasLocalControl())
                {
                    return;
                }

                // if we've no flightcomputer, go out
                var satellite = RTCore.Instance.Satellites[FlightGlobals.ActiveVessel];
                if (satellite == null || satellite.SignalProcessor.FlightComputer == null)
                {
                    return;
                }
                var flightComputer = satellite.SignalProcessor.FlightComputer;

                PatchedConicSolver pCS = FlightGlobals.ActiveVessel.patchedConicSolver;

                // PatchedConicSolver instantiated? and more than one maneuver node?
                if (pCS != null && pCS.maneuverNodes.Count > 0)
                {
                    // Loop maneuvers
                    for (var i = 0; i < pCS.maneuverNodes.Count; i++)
                    {
                        float        btnWidth = 23.0f;
                        ManeuverNode node     = pCS.maneuverNodes[i];

                        // node has an attached gizmo?
                        if (node.attachedGizmo == null || node.UT < RTUtil.GameTime)
                        {
                            continue;
                        }

                        ManeuverGizmo         gizmo          = node.attachedGizmo;
                        UnityEngine.UI.Button gizmoDeleteBtn = gizmo.deleteBtn;

                        // We are on the right gizmo but no buttons are visible so skip the rest
                        if (!gizmoDeleteBtn.isActiveAndEnabled)
                        {
                            continue;
                        }

                        Vector3 screenCoord = gizmo.camera.WorldToScreenPoint(gizmo.transform.position);
                        //Vector3 screenCenter = new Vector2(Screen.width / 2, Screen.height / 2);

                        //double dist = Math.Sqrt(Math.Pow(screenCenter.x - screenCoord.x, 2.0) + Math.Pow(screenCenter.y - screenCoord.y, 2.0));
                        //double btnDim = 20.0f + (8.0f * ((1.2f / screenCenter.magnitude) * Math.Abs(dist)));
                        //btnDim = 1.0f * gizmoDeleteBtn.transform.lossyScale.x;

                        Rect screenPos = new Rect(screenCoord.x - btnWidth - 5.0f, Screen.height - screenCoord.y - btnWidth, btnWidth, btnWidth);

                        GUIStyle maneuverCtrl      = mManeuverNodeButtonAdd;
                        bool     nodeAlreadyQueued = flightComputer.HasManeuverCommandByNode(node);

                        // switch the button style
                        if (nodeAlreadyQueued)
                        {
                            maneuverCtrl = mManeuverNodeButtonDelete;
                        }
                        GUILayout.BeginArea(screenPos);

                        if (GUILayout.Button("", maneuverCtrl))
                        {
                            if (!nodeAlreadyQueued)
                            {
                                flightComputer.Enqueue(ManeuverCommand.WithNode(i, flightComputer), false, false, true);
                            }
                            else
                            {
                                flightComputer.RemoveManeuverCommandByNode(node);
                            }
                        }
                        GUILayout.EndArea();
                    }
                }
            }
        }
Пример #9
0
    public void ReplaceUI(UnityEngine.CanvasGroup newGameControlsCanvasGroup, UnityEngine.CanvasGroup newEndGameCanvasGroup, TMPro.TextMeshProUGUI newGameResultText, UnityEngine.UI.Button newAttackButton, UnityEngine.UI.Button newSwitchButton, UnityEngine.UI.Button newRestartGameButton)
    {
        var entity = uIEntity;

        if (entity == null)
        {
            entity = SetUI(newGameControlsCanvasGroup, newEndGameCanvasGroup, newGameResultText, newAttackButton, newSwitchButton, newRestartGameButton);
        }
        else
        {
            entity.ReplaceUI(newGameControlsCanvasGroup, newEndGameCanvasGroup, newGameResultText, newAttackButton, newSwitchButton, newRestartGameButton);
        }
    }
Пример #10
0
 /// <summary>
 /// Create AsyncReactiveCommand and bind to button's interactable and onClick and register async action to command.
 /// </summary>
 public static IDisposable BindToOnClick(this UnityEngine.UI.Button button, Func <Unit, IObservable <Unit> > asyncOnClick)
 {
     return(new AsyncReactiveCommand().BindToOnClick(button, asyncOnClick));
 }
 void SetupBinds()
 {
     Button = transform.Find("Button").GetComponent <UnityEngine.UI.Button>();
     Text   = transform.Find("Text").GetComponent <UnityEngine.UI.Text>();
 }
Пример #12
0
 void ClearBinds()
 {
     AudioButton = null;
     Mute        = null;
 }
Пример #13
0
 // for uGUI(from 4.6)
 /// <summary>
 /// Bind ReactiveCommand to button's interactable and onClick.
 /// </summary>
 public static IDisposable BindTo(this IReactiveCommand<Unit> command, UnityEngine.UI.Button button)
 {
     var d1 = command.CanExecute.SubscribeToInteractable(button);
     var d2 = button.OnClickAsObservable().SubscribeWithState(command, (x, c) => c.Execute(x));
     return StableCompositeDisposable.Create(d1, d2);
 }
Пример #14
0
 virtual protected void Awake()
 {
     _button = GetComponent <UnityEngine.UI.Button>();
     _button.onClick.AddListener(() => Click());
 }
Пример #15
0
 void SetupBinds()
 {
     AudioButton = transform.Find("AudioButton").GetComponent <UnityEngine.UI.Button>();
     Mute        = transform.Find("AudioButton/Mute").GetComponent <UnityEngine.UI.Image>();
 }
Пример #16
0
 private void Awake()
 {
     hostButton = GetComponent <UnityEngine.UI.Button>();
     hostButton.onClick.AddListener(HandleClick);
 }
Пример #17
0
        void AddComponents()
        {
            TextContent = GameObject.Find("TextContent").GetComponent <UnityEngine.UI.Text>();
            ButtonClear = GameObject.Find("ButtonClear").GetComponent <UnityEngine.UI.Button>();
            ButtonClear.onClick.AddListener(ButtonClearHandler);
            ButtonReset = GameObject.Find("ButtonReset").GetComponent <UnityEngine.UI.Button>();
            ButtonReset.onClick.AddListener(ResetHandler);
            ButtonSubscribe = GameObject.Find("ButtonSubscribe").GetComponent <UnityEngine.UI.Button>();
            ButtonSubscribe.onClick.AddListener(SubscribeHandler);
            ButtonPublishPost = GameObject.Find("ButtonPublishPost").GetComponent <UnityEngine.UI.Button>();
            ButtonPublishPost.onClick.AddListener(ButtonPublishPostHandler);
            ButtonPublish = GameObject.Find("ButtonPublish").GetComponent <UnityEngine.UI.Button>();
            ButtonPublish.onClick.AddListener(ButtonPublishHandler);

            ButtonFire = GameObject.Find("ButtonFire").GetComponent <UnityEngine.UI.Button>();
            ButtonFire.onClick.AddListener(ButtonFireHandler);
            ButtonWhereNow = GameObject.Find("ButtonWhereNow").GetComponent <UnityEngine.UI.Button>();
            ButtonWhereNow.onClick.AddListener(ButtonWhereNowHandler);
            ButtonHereNow = GameObject.Find("ButtonHereNow").GetComponent <UnityEngine.UI.Button>();
            ButtonHereNow.onClick.AddListener(ButtonHereNowHandler);
            ButtonTime = GameObject.Find("ButtonTime").GetComponent <UnityEngine.UI.Button>();
            ButtonTime.onClick.AddListener(ButtonTimeHandler);
            ButtonHistory = GameObject.Find("ButtonHistory").GetComponent <UnityEngine.UI.Button>();
            ButtonHistory.onClick.AddListener(ButtonHistoryHandler);
            ButtonGetPresenceState = GameObject.Find("ButtonGetPresenceState").GetComponent <UnityEngine.UI.Button>();
            ButtonGetPresenceState.onClick.AddListener(ButtonGetPresenceStateHandler);
            ButtonSetPresenceState = GameObject.Find("ButtonSetPresenceState").GetComponent <UnityEngine.UI.Button>();
            ButtonSetPresenceState.onClick.AddListener(ButtonSetPresenceStateHandler);
            ButtonUnsubscribe = GameObject.Find("ButtonUnsubscribe").GetComponent <UnityEngine.UI.Button>();
            ButtonUnsubscribe.onClick.AddListener(ButtonUnsubscribeHandler);
            ButtonFetch = GameObject.Find("ButtonFetch").GetComponent <UnityEngine.UI.Button>();
            ButtonFetch.onClick.AddListener(ButtonFetchHandler);
            ButtonDeleteHistory = GameObject.Find("ButtonDeleteHistory").GetComponent <UnityEngine.UI.Button>();
            ButtonDeleteHistory.onClick.AddListener(ButtonDeleteHistoryHandler);
            ButtonUnsubscribeAll = GameObject.Find("ButtonUnsubscribeAll").GetComponent <UnityEngine.UI.Button>();
            ButtonUnsubscribeAll.onClick.AddListener(ButtonUnsubscribeAllHandler);
            ButtonCleanUp = GameObject.Find("ButtonCleanUp").GetComponent <UnityEngine.UI.Button>();
            ButtonCleanUp.onClick.AddListener(ButtonCleanUpHandler);
            ButtonReconnect = GameObject.Find("ButtonReconnect").GetComponent <UnityEngine.UI.Button>();
            ButtonReconnect.onClick.AddListener(ButtonReconnectHandler);
            ButtonAddChannelsToChannelGroup = GameObject.Find("ButtonAddChannelsToChannelGroup").GetComponent <UnityEngine.UI.Button>();
            ButtonAddChannelsToChannelGroup.onClick.AddListener(ButtonAddChannelsToChannelGroupHandler);
            ButtonDeleteChannelGroup = GameObject.Find("ButtonDeleteChannelGroup").GetComponent <UnityEngine.UI.Button>();
            ButtonDeleteChannelGroup.onClick.AddListener(ButtonDeleteChannelGroupHandler);
            ButtonRemoveChannelsFromChannelGroup = GameObject.Find("ButtonRemoveChannelsFromChannelGroup").GetComponent <UnityEngine.UI.Button>();
            ButtonRemoveChannelsFromChannelGroup.onClick.AddListener(ButtonRemoveChannelsFromChannelGroupHandler);
            ButtonListChannelsForChannelGroup = GameObject.Find("ButtonListChannelsForChannelGroup").GetComponent <UnityEngine.UI.Button>();
            ButtonListChannelsForChannelGroup.onClick.AddListener(ButtonListChannelsForChannelGroupHandler);
            ButtonAddPushNotificationsOnChannels = GameObject.Find("ButtonAddPushNotificationsOnChannels").GetComponent <UnityEngine.UI.Button>();
            ButtonAddPushNotificationsOnChannels.onClick.AddListener(ButtonAddPushNotificationsOnChannelsHandler);
            ButtonAuditPushChannelProvisions = GameObject.Find("ButtonAuditPushChannelProvisions").GetComponent <UnityEngine.UI.Button>();
            ButtonAuditPushChannelProvisions.onClick.AddListener(ButtonAuditPushChannelProvisionsHandler);
            ButtonRemoveAllPushNotifications = GameObject.Find("ButtonRemoveAllPushNotifications").GetComponent <UnityEngine.UI.Button>();
            ButtonRemoveAllPushNotifications.onClick.AddListener(ButtonRemoveAllPushNotificationsHandler);
            ButtonRemovePushNotificationsFromChannels = GameObject.Find("ButtonRemovePushNotificationsFromChannels").GetComponent <UnityEngine.UI.Button>();
            ButtonRemovePushNotificationsFromChannels.onClick.AddListener(ButtonRemovePushNotificationsFromChannelsHandler);
            ButtonMessageCounts = GameObject.Find("ButtonMessageCounts").GetComponent <UnityEngine.UI.Button>();
            ButtonMessageCounts.onClick.AddListener(ButtonMessageCountsHandler);
            ButtonSignal = GameObject.Find("ButtonSignal").GetComponent <UnityEngine.UI.Button>();
            ButtonSignal.onClick.AddListener(ButtonSignalHandler);
        }
Пример #18
0
 override protected void Awake()
 {
     base.Awake();
     button = GetComponent <UnityEngine.UI.Button>();
     button.onClick.AddListener(Pressed);
 }
Пример #19
0
 /// <summary>
 /// Bind canExecuteSource to button's interactable and onClick and register onClick action to command.
 /// </summary>
 public static IDisposable BindToButtonOnClick(this IObservable <bool> canExecuteSource, UnityEngine.UI.Button button, Action <Unit> onClick, bool initialValue = true)
 {
     return(ToReactiveCommand(canExecuteSource, initialValue).BindToOnClick(button, onClick));
 }
 void ClearBinds()
 {
     Button = null;
     Text   = null;
 }
Пример #21
0
        /// <summary>
        /// Bind AsyncRaectiveCommand to button's interactable and onClick and register async action to command.
        /// </summary>
        public static IDisposable BindToOnClick(this AsyncReactiveCommand <Unit> command, UnityEngine.UI.Button button, Func <Unit, IObservable <Unit> > asyncOnClick)
        {
            var d1 = command.CanExecute.SubscribeToInteractable(button);
            var d2 = button.OnClickAsObservable().SubscribeWithState(command, (x, c) => c.Execute(x));
            var d3 = command.Subscribe(asyncOnClick);

            return(StableCompositeDisposable.Create(d1, d2, d3));
        }
		void Awake() {
			button = GetComponent<UnityEngine.UI.Button>();
			if (button == null) enabled = false;
		}
Пример #23
0
 /// <summary>
 /// Create AsyncReactiveCommand and bind sharedCanExecuteSource source to button's interactable and onClick and register async action to command.
 /// </summary>
 public static IDisposable BindToOnClick(this UnityEngine.UI.Button button, IReactiveProperty <bool> sharedCanExecuteSource, Func <Unit, IObservable <Unit> > asyncOnClick)
 {
     return(sharedCanExecuteSource.ToAsyncReactiveCommand().BindToOnClick(button, asyncOnClick));
 }
 public static IDisposable BindValueToButtonOnClick <T>(this IReactiveProperty <T> toUpdateSource, UnityEngine.UI.Button fromButton, Func <T> onClickValue)
 {
     return(GenericBindings.Bind(fromButton.OnClickAsObservable(), _ => toUpdateSource.Value = onClickValue()).AddTo(fromButton));
 }
        /// <summary>
        /// When loading a game, load the dialogue entry records and resume the conversation.
        /// </summary>
        public override void OnApplyPersistentData()
        {
            if (DontLoadInThisScene())
            {
                Debug.Log("OnApplyPersistentData Dont Load in this scene: " + SceneManager.GetActiveScene().buildIndex);
            }
            if (DontLoadInThisScene())
            {
                return;
            }
            records.Clear();
            if (!DialogueLua.DoesVariableExist(currentDialogueEntryRecords))
            {
                return;
            }
            StopAllCoroutines();

            // Load dialogue entry records:
            var s = DialogueLua.GetVariable(currentDialogueEntryRecords).AsString;

            if (Debug.isDebugBuild)
            {
                Debug.Log("TextlineDialogueUI.OnApplyPersistentData: Restoring current conversation from " + currentDialogueEntryRecords + ": " + s);
            }
            var ints       = s.Split(';');
            var numRecords = Tools.StringToInt(ints[0]);

            for (int i = 0; i < numRecords; i++)
            {
                var conversationID = Tools.StringToInt(ints[1 + i * 2]);
                var entryID        = Tools.StringToInt(ints[2 + i * 2]);
                records.Add(new DialogueEntryRecord(conversationID, entryID));
            }

            // If we have records, resume the conversation:
            if (records.Count == 0)
            {
                return;
            }
            var lastRecord = records[records.Count - 1];

            if (lastRecord.conversationID >= 0 && lastRecord.entryID > 0)
            {
                UnityEngine.UI.Button lastContinueButton = null;
                try
                {
                    // Resume conversation:
                    //if (dontRepeatLastSequence) isLoadingGame = true;
                    isLoadingGame = true;
                    cellDataList.Clear();
                    var conversation        = DialogueManager.MasterDatabase.GetConversation(lastRecord.conversationID);
                    var actorName           = DialogueLua.GetVariable(currentConversationActor).AsString;
                    var conversantName      = DialogueLua.GetVariable(currentConversationConversant).AsString;
                    var actor               = GameObject.Find(actorName);
                    var conversant          = GameObject.Find(conversantName);
                    var actorTransform      = (actor != null) ? actor.transform : null;
                    var conversantTransform = (conversant != null) ? conversant.transform : null;
                    if (Debug.isDebugBuild)
                    {
                        Debug.Log("Resuming '" + conversation.Title + "' at entry " + lastRecord.entryID);
                    }
                    DialogueManager.StopConversation();
                    //Open();
                    //var conversationModel = new ConversationModel(DialogueManager.masterDatabase, conversation.Title, actorTransform, conversantTransform, true, DialogueManager.isDialogueEntryValid);
                    var lastEntry        = DialogueManager.MasterDatabase.GetDialogueEntry(lastRecord.conversationID, lastRecord.entryID);
                    var originalSequence = lastEntry.Sequence; // Handle last entry's sequence differently if end entry.
                    npcPreDelaySettings.CopyTo(npcPreDelaySettingsCopy);
                    pcPreDelaySettings.CopyTo(pcPreDelaySettingsCopy);
                    npcPreDelaySettings.basedOnTextLength = false;
                    npcPreDelaySettings.additionalSeconds = 0;
                    pcPreDelaySettings.basedOnTextLength  = false;
                    pcPreDelaySettings.additionalSeconds  = 0;
                    var isEndEntry = lastEntry.Sequence.Contains("WaitForMessage(Forever)") || lastEntry.outgoingLinks.Count == 0;
                    if (isEndEntry)
                    {
                        if (!lastEntry.Sequence.Contains("WaitForMessage(Forever)"))
                        {
                            lastEntry.Sequence = "WaitForMessage(Forever); " + lastEntry.Sequence;
                        }
                    }
                    else if (dontRepeatLastSequence)
                    {
                        lastEntry.Sequence = "Continue()";
                    }
                    else
                    {
                        lastEntry.Sequence = "Continue()@0.1";
                    }
                    skipNextRecord = true;
                    isInPreDelay   = false;
                    Open();
                    //DialogueManager.StartConversation(conversation.Title, actorTransform, conversantTransform, lastRecord.entryID);
                    var conversationModel = new ConversationModel(DialogueManager.masterDatabase, conversation.Title, actorTransform, conversantTransform, true, null, lastRecord.entryID);

                    lastContinueButton = continueButton;
                    npcPreDelaySettingsCopy.CopyTo(npcPreDelaySettings);
                    pcPreDelaySettingsCopy.CopyTo(pcPreDelaySettings);

                    // Populate UI with previous records:
                    var lastInstance = (instantiatedMessages.Count > 0) ? instantiatedMessages[instantiatedMessages.Count - 1] : null;
                    instantiatedMessages.Remove(lastInstance);
                    DestroyInstantiatedMessages();
                    for (int i = 0; i < records.Count - 1; i++)
                    {
                        var entry         = DialogueManager.MasterDatabase.GetDialogueEntry(records[i].conversationID, records[i].entryID);
                        var speakerInfo   = conversationModel.GetCharacterInfo(entry.ActorID);
                        var listenerInfo  = conversationModel.GetCharacterInfo(entry.ConversantID);
                        var formattedText = FormattedText.Parse(entry.currentDialogueText);
                        var subtitle      = new Subtitle(speakerInfo, listenerInfo, formattedText, "None()", entry.ResponseMenuSequence, entry);
                        AddMessage(subtitle);
                    }
                    if (lastInstance != null)
                    {
                        instantiatedMessages.Add(lastInstance);
                        lastInstance.transform.SetAsLastSibling();
                    }

                    // Start conversation:
                    skipNextRecord = true;
                    isInPreDelay   = false;
                    DialogueManager.StartConversation(conversation.Title, actorTransform, conversantTransform, lastRecord.entryID);
                    lastEntry.Sequence = originalSequence;
                    npcPreDelaySettingsCopy.CopyTo(npcPreDelaySettings);
                    pcPreDelaySettingsCopy.CopyTo(pcPreDelaySettings);
                }
                finally
                {
                    StartCoroutine(SetIsLoadingGame(false));
                    enhancedScroller.ReloadData();
                    ScrollToBottom();
                    continueButton = lastContinueButton;
                    if (shouldShowContinueButton && lastContinueButton != null)
                    {
                        lastContinueButton.gameObject.SetActive(true);
                    }
                }
            }
            ScrollToBottom();
        }
Пример #26
0
 private void OnValidate()
 {
     text         = text ?? GetComponent("Body") as UnityEngine.UI.Text;
     choiceButton = choiceButton ?? GetComponent("ContinueBtn") as UnityEngine.UI.Button;
 }
Пример #27
0
		void Awake()
		{
			this.EventTrigger = GetComponent<EventTrigger>();
			this.Button = GetComponent<UnityEngine.UI.Button>();
		}
Пример #28
0
        public void DrawLayer(Layer layer, GameObject parent)
        {
            UnityEngine.UI.Button button = PSDImportUtility.LoadAndInstant <UnityEngine.UI.Button>(PSDImporterConst.ASSET_PATH_BUTTON, layer.name, parent);

            if (layer.layers != null)
            {
                for (int imageIndex = 0; imageIndex < layer.layers.Length; imageIndex++)
                {
                    PSImage image     = layer.layers[imageIndex].image;
                    string  lowerName = image.name.ToLower();
                    if (image.imageType != ImageType.Label && image.imageType != ImageType.Texture)
                    {
                        if (image.imageSource == ImageSource.Custom || image.imageSource == ImageSource.Common)
                        {
                            string assetPath = PSDImportUtility.baseDirectory + image.name + PSDImporterConst.PNG_SUFFIX;
                            Sprite sprite    = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Sprite)) as Sprite;

                            if (image.name.ToLower().Contains("normal"))
                            {
                                button.image.sprite = sprite;
                                RectTransform rectTransform = button.GetComponent <RectTransform>();
                                rectTransform.sizeDelta        = new Vector2(image.size.width, image.size.height);
                                rectTransform.anchoredPosition = new Vector2(image.position.x, image.position.y);

                                adjustButtonBG(image.imageType, button);
                            }
                            else if (image.name.ToLower().Contains("pressed"))
                            {
                                button.transition = UnityEngine.UI.Selectable.Transition.SpriteSwap;
                                UnityEngine.UI.SpriteState state = button.spriteState;
                                state.pressedSprite = sprite;
                                button.spriteState  = state;
                            }
                            else if (image.name.ToLower().Contains("disabled"))
                            {
                                button.transition = UnityEngine.UI.Selectable.Transition.SpriteSwap;
                                UnityEngine.UI.SpriteState state = button.spriteState;
                                state.disabledSprite = sprite;
                                button.spriteState   = state;
                            }
                            else if (image.name.ToLower().Contains("highlighted"))
                            {
                                button.transition = UnityEngine.UI.Selectable.Transition.SpriteSwap;
                                UnityEngine.UI.SpriteState state = button.spriteState;
                                state.highlightedSprite = sprite;
                                button.spriteState      = state;
                            }
                        }
                        else if (image.imageSource == ImageSource.Global)
                        {
                            SpriteImport.SetGlobalImage(button.image, image);
                        }
                    }
                    else
                    {
                        //ctrl.DrawImage(image, button.gameObject);
                        ctrl.DrawLayer(layer.layers[imageIndex], button.gameObject);
                    }
                }
            }
        }
Пример #29
0
 void Start()
 {
     Button = GetComponent<UnityEngine.UI.Button>();
 }
Пример #30
0
    public GameEntity SetUI(UnityEngine.CanvasGroup newGameControlsCanvasGroup, UnityEngine.CanvasGroup newEndGameCanvasGroup, TMPro.TextMeshProUGUI newGameResultText, UnityEngine.UI.Button newAttackButton, UnityEngine.UI.Button newSwitchButton, UnityEngine.UI.Button newRestartGameButton)
    {
        if (hasUI)
        {
            throw new Entitas.EntitasException("Could not set UI!\n" + this + " already has an entity with UIComponent!",
                                               "You should check if the context already has a uIEntity before setting it or use context.ReplaceUI().");
        }
        var entity = CreateEntity();

        entity.AddUI(newGameControlsCanvasGroup, newEndGameCanvasGroup, newGameResultText, newAttackButton, newSwitchButton, newRestartGameButton);
        return(entity);
    }