Inheritance: MonoBehaviour
Beispiel #1
0
 /// <summary>
 /// Metodo che viene richiamato una volta allo start dello script (al primo frame).
 /// </summary>
 void Start()
 {
     // Disattiva il colorPicker
     colorPicker.SetActive(false);
     // Corrisponde al bottone.
     button = GetComponent <InteractionButton>();
 }
 /// <summary>
 /// Metodo richiamato una volta nel primo frame.
 /// </summary>
 void Start()
 {
     buttonSalva        = buttonSalva.GetComponent <InteractionButton>();
     buttonSalvaConNome = buttonSalvaConNome.GetComponent <InteractionButton>();
     // Aggiungo un ascoltatore che ascolta gli eventi generati dal bottone "Si".
     saveFromUI.onClick.AddListener(Salva);
 }
Beispiel #3
0
        public void Navigation(string sectionName)
        {
            InteractionButton.Click();

            Driver.ScrollTo(InteractionSideBarMenu(sectionName));
            InteractionSideBarMenu(sectionName).Click();
        }
 private void findButton()
 {
     if (button == null)
     {
         button = GetComponent <InteractionButton>();
     }
 }
Beispiel #5
0
 private void OnValidate()
 {
     if (button == null)
     {
         button = GetComponent <InteractionButton>();
     }
 }
Beispiel #6
0
    // Update is called once per frame
    void Update()
    {
        interactionBehaviour1          = submitButton.GetComponent <InteractionButton>();
        interactionBehaviour1.OnPress += Submit;
        float sliderVal  = leapSlider.HorizontalSliderValue;
        float cigarettes = CalculateCigarettes(sliderVal);

        //foggingMat.SetFloat("_Density", densityCalc(sliderVal));
        if (sliderVal >= 10)
        {
            fogger.SetActive(true);
            system.Emit(new ParticleSystem.EmitParams()
            {
                position = UnityEngine.Random.onUnitSphere, startColor = Color.black, startSize = (sliderVal / 200f)
            }, 1);;
        }

        cigaretteAmount.text    = cigarettes.ToString() + " Cigarettes Per Week";
        mortalityReduction.text = lifeSpan(sliderVal, sliderVal) + " Months that could be gained if adhering to WHO standards";
        if (submit)
        {
            foreach (GameObject objecttoHide in objectsToHide)
            {
                objecttoHide.SetActive(false);
            }
            chosenValue.text     = cigarettes.ToString() + " Cigarettes Per Week";
            actualValue.text     = CalculateCigarettes(pm2) + " Cigarettes Per Week";
            actualReduction.text = lifeSpan(pm10, pm2) + " Months that could be gained \n if adhering to WHO standards";
            foreach (GameObject objecttoshow in objectsToShow)
            {
                objecttoshow.SetActive(true);
            }
            submit = false;
        }
    }
Beispiel #7
0
    public static GameObject generateInteraction(InteractionButton interaction)
    {
        GameObject worldUI     = GameObject.Find("WORLD_UI");
        GameObject instanciate = Instantiate(interaction.gameObject) as GameObject;

        instanciate.transform.SetParent(worldUI.transform);
        return(instanciate);
    }
    public override void Initialize()
    {
        base.Initialize();
        audioSource = GetComponent <AudioSource>();
        btnPlay     = GetComponentInChildren <InteractionButton>();

        btnPlay.OnContactEnd += ToggleAudio;
    }
    public override void OnInspectorGUI()
    {
        int beforeCount = script.createdInteractions.Length;

        serializedObject.Update();

        SerializedProperty activateDialogProp = serializedObject.FindProperty("activateDialog");

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(activateDialogProp, new GUIContent("Activate dialog:"));
        if (activateDialogProp.boolValue == true)
        {
            EditorGUILayout.PropertyField(serializedObject.FindProperty("linkedDialog"), GUIContent.none);
        }
        EditorGUILayout.EndHorizontal();

        SerializedProperty requireItemProp = serializedObject.FindProperty("requireItem");

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(requireItemProp, new GUIContent("Require item:"));
        if (requireItemProp.boolValue == true)
        {
            EditorGUILayout.PropertyField(serializedObject.FindProperty("itemName"), GUIContent.none);
        }
        EditorGUILayout.EndHorizontal();

        DrawPropertiesExcluding(serializedObject, "m_Script", "activateDialog", "linkedDialog", "requireItem", "itemName");
        serializedObject.ApplyModifiedProperties();

        int afterCount = script.createdInteractions.Length;

        if (beforeCount != afterCount)
        {
            return;
        }

        for (int i = 0; i < script.createdInteractions.Length; i++)
        {
            InteractionButton interaction = script.createdInteractions [i];
            if (interaction == null)
            {
                EditorGUILayout.LabelField("Null...");
            }
            else
            {
                EditorGUILayout.LabelField(interaction.name);
                EditorGUI.indentLevel++;
                FindEditorForInteraction(interaction).OnInspectorGUI();
                EditorGUI.indentLevel--;
            }
        }

        if (GUILayout.Button("Refresh Interactions"))
        {
            script.createdInteractions = script.transform.GetComponentsInChildren <InteractionButton> ();
            serializedObject.ApplyModifiedProperties();
        }
    }
Beispiel #10
0
        protected override void Reset()
        {
            base.Reset();

            if (button == null)
            {
                button = GetComponent <InteractionButton>();
            }
        }
Beispiel #11
0
 void OnEnable()
 {
     script = (InteractionButton)target;
     if (script == null)
     {
         return;
     }
     script.Insp_Init();
 }
Beispiel #12
0
    private void InitializeInterationButton(GameObject menuItem, IInteract interaction, Vector2 interactionLocation)
    {
        InteractionButton interactionButton = menuItem.GetComponent <InteractionButton>();

        interactionButton._buttonText.text     = interaction.Name;
        interactionButton._assignedInteraction = interaction;
        interactionButton._targetPos           = interactionLocation;
        interactionButton._uiGod = this;
    }
Beispiel #13
0
    ////////////////////////////////////// 3D GRID //////////////////////////////////////
    private void init3DGrid()
    {
        int totalCount = 0;

        // Init Array
        grid3DArr = new GameObject[(int)volumeAmount3D, (int)rowAmount3D, (int)columnAmount3D];

        // Init Shape
        if (Enable3DGrid == true)
        {
            for (int z = 0; z < volumeAmount3D; z++)
            {
                for (int y = 0; y < rowAmount3D; y++)
                {
                    for (int x = 0; x < columnAmount3D; x++)
                    {
                        Vector3 pos = new Vector3(x, z, y) * spacing3D + positionRelativeObject.transform.position;

                        if (EnableDifferentPrefabs == false)
                        {
                            grid3DArr[z, y, x] = Instantiate(prefab, pos, prefab.transform.localRotation);

                            // Init Default Prefab
                            if (prefab.name == "button_PF")
                            {
                                interactButtonScript = grid3DArr[z, y, x].GetComponentInChildren <InteractionButton>();
                                buttonPressScript    = grid3DArr[z, y, x].GetComponentInChildren <buttonPress>();
                                interactButtonScript.OnPress.AddListener(buttonPressScript.ButtonPressed);
                                interactButtonScript.OnUnpress.AddListener(buttonPressScript.ButtonUnPressed);
                            }
                        }
                        else
                        {
                            grid3DArr[z, y, x] = Instantiate(prefabs3G[totalCount], pos, prefabs3G[totalCount].transform.localRotation);

                            if (scale3G[totalCount] != 0)
                            {
                                grid3DArr[z, y, x].transform.localScale = new Vector3(scale3G[totalCount], scale3G[totalCount], scale3G[totalCount]);
                            }

                            // Init Prefab
                            if (prefabs3G[totalCount].name == "button_PF")
                            {
                                interactButtonScript = grid3DArr[z, y, x].GetComponentInChildren <InteractionButton>();
                                buttonPressScript    = grid3DArr[z, y, x].GetComponentInChildren <buttonPress>();
                                interactButtonScript.OnPress.AddListener(buttonPressScript.ButtonPressed);
                                interactButtonScript.OnUnpress.AddListener(buttonPressScript.ButtonUnPressed);
                            }

                            totalCount++;
                        }
                    }
                }
            }
        }
    }
Beispiel #14
0
    // Update is called once per frame
    void Update()
    {
        interactionBehaviour1          = resetButton.GetComponent <InteractionButton>();
        interactionBehaviour1.OnPress += Submit;

        if (submit)
        {
            SceneManager.LoadScene("MainScreen");
        }
    }
Beispiel #15
0
        /// <summary>
        /// Called on Reset(), OnValidate(), and Awake(). Use this for common runtime
        /// and edit-time state initialization, such as event subscription and
        /// last-chance component searches.
        /// </summary>
        protected virtual void initialize()
        {
            if (button == null)
            {
                button = GetComponent <InteractionButton>();
            }

            onPressAction   = OnPress;
            onUnpressAction = OnUnpress;
        }
    Editor FindEditorForInteraction(InteractionButton interaction)
    {
        Editor currentEditor = null;

        if (!editors.TryGetValue(interaction, out currentEditor))
        {
            currentEditor = CreateEditor(interaction);
            editors.Add(interaction, currentEditor);
        }
        return(currentEditor);
    }
    private void Awake()
    {
        MyLeapSettings leapSettings = FindObjectOfType <MyLeapSettings>();

        if (leapSettings != null)
        {
            delay = leapSettings.settings.btnActivateDelay;
        }

        targetBtn         = GetComponent <InteractionButton>();
        targetBtn.enabled = false;
    }
Beispiel #18
0
        // Start is called before the first frame update
        void Start()
        {
            //Initialisation of the different menu buttons
            cMenu              = GameObject.Find("Palm UI L").GetComponent <CurrentMenu>();
            ButtonCreation     = GameObject.Find("Button Creation").GetComponent <InteractionButton>();     // Button for Creation/Modification/Intersection
            ButtonSelection    = GameObject.Find("Button Selection").GetComponent <InteractionButton>();    // Button for Selection/Erase/Union
            ButtonStatistics   = GameObject.Find("Button Statistics").GetComponent <InteractionButton>();   // Button for Statsistics/Operation/Relative Complement
            ButtonHide_Show    = GameObject.Find("Button Hide/Show").GetComponent <InteractionButton>();    // Button for Hide_Show/Return/Return
            ButtonHelp_Options = GameObject.Find("Button Help/Options").GetComponent <InteractionButton>(); // Button for Help_Options
            ButtonQuit         = GameObject.Find("Button Quit").GetComponent <InteractionButton>();         // Button for Quit

            FrameCounter = 0;
        }
Beispiel #19
0
 public static InteractionComponent_Json ToModel(this InteractionButton component)
 {
     return(new InteractionComponent_Json
     {
         Id = component.Id,
         Disabled = component.Disabled,
         Emoji = component.Emoji?.ToModel(),
         Label = component.Label,
         Style = component.Style,
         Type = 2,
         Url = component.Url
     });
 }
Beispiel #20
0
    // Update is called once per frame
    void Update()
    {
        bool justTouched = false;

        if (Input.touchCount > 0)
        {
            var touch = Input.touches[0];
            if (touch.phase == TouchPhase.Began)
            {
                ray         = Camera.main.ScreenPointToRay(touch.position);
                justTouched = true;
            }
        }
        else if (Input.GetMouseButtonDown(0))
        {
            ray         = Camera.main.ScreenPointToRay(Input.mousePosition);
            justTouched = true;
        }

        if (justTouched)
        {
            RaycastHit hitInfo;
            if (Physics.Raycast(ray, out hitInfo))
            {
                //Debug.Log("hitinfo: " + hitInfo.collider.gameObject.name);

                GameObject targetGameObj = hitInfo.collider.gameObject;
                if (targetGameObj != null)
                {
                    InteractionButton button = null;
                    button = targetGameObj.GetComponent <InteractionButton>();


                    if (targetGameObj.transform.parent != null && button == null)
                    {
                        button = targetGameObj.transform.parent.GetComponent <InteractionButton>();
                    }

                    if (button != null && button.enabled)
                    {
                        if (button.onPressSound != null)
                        {
                            button.onPressSound.Play();
                        }
                        button.OnPress();
                    }
                }
            }
        }
    }
    void Reset()
    {
        if (colorRendererToSet == null)
        {
            colorRendererToSet = GetComponentInChildren <Renderer>();
        }
        if (outlineRendererToSet == null && doOutlineFeedback)
        {
            outlineRendererToSet = GetComponentInChildren <Renderer>();
        }

        if (button == null)
        {
            button = GetComponent <InteractionButton>();
        }
    }
Beispiel #22
0
    ////////////////////////////////////// CIRCLE //////////////////////////////////////
    private void initCircle()
    {
        // Init Array
        circleArr = new GameObject[numberOfObjects];

        // Init Shape
        for (int i = 0; i < numberOfObjects; i++)
        {
            // Math for circle shape
            float   angle = i * Mathf.PI * 2 / numberOfObjects;
            Vector3 pos   = new Vector3(Mathf.Cos(angle), 0, Mathf.Sin(angle)) * radius + positionRelativeObject.transform.position;

            if (EnableDifferentPrefabs == false)
            {
                circleArr[i] = Instantiate(prefab, pos, prefab.transform.localRotation);

                // Init Default Prefab
                if (prefab.name == "button_PF")
                {
                    interactButtonScript = circleArr[i].GetComponentInChildren <InteractionButton>();
                    buttonPressScript    = circleArr[i].GetComponentInChildren <buttonPress>();

                    interactButtonScript.OnPress.AddListener(buttonPressScript.ButtonPressed);
                    interactButtonScript.OnUnpress.AddListener(buttonPressScript.ButtonUnPressed);
                }
            }
            else
            {
                circleArr[i] = Instantiate(prefabsC[i], pos, prefabsC[i].transform.localRotation);

                if (scaleC[i] != 0)
                {
                    circleArr[i].transform.localScale = new Vector3(scaleC[i], scaleC[i], scaleC[i]);
                }

                //Init Prefab
                if (prefabsC[i].name == "button_PF")
                {
                    interactButtonScript = circleArr[i].GetComponentInChildren <InteractionButton>();
                    buttonPressScript    = circleArr[i].GetComponentInChildren <buttonPress>();

                    interactButtonScript.OnPress.AddListener(buttonPressScript.ButtonPressed);
                    interactButtonScript.OnUnpress.AddListener(buttonPressScript.ButtonUnPressed);
                }
            }
        }
    }
Beispiel #23
0
    public void Task4()
    {
        InteractionButton T4InteractionButton = (InteractionButton)T4.GetComponent(typeof(InteractionButton));

        T4InteractionButton.controlEnabled = false;
        T4.transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().materials[0].color = Color.grey;
        t4.interactable = false;

        iftask3 = false;
        iftask4 = true;
        Bag.SetActive(true);

        TaskNum.text = "Task 4  Rotate 旋转";
        Taskc.text   = "\n\n请将红色背包旋转180度,使它背向您\n\n旋转成功时,您将听到提示音";
        Taske.text   = "\nPlease rotate the red bag 180 degrees, making the bag back to you.\n\nIf successful, you will hear a sound";
        AudioSource.PlayClipAtPoint(clip, transform.position);
    }
Beispiel #24
0
    public void Task6()
    {
        iftask5 = false;
        iftask6 = true;
        Bag.SetActive(true);

        InteractionButton T6InteractionButton = (InteractionButton)T6.GetComponent(typeof(InteractionButton));

        T6InteractionButton.controlEnabled = false;
        T6.transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().materials[0].color = Color.grey;
        t6.interactable = false;

        TaskNum.text = "Task 6  Close product details 关闭商品详情";
        Taskc.text   = "\n请关闭商品详情页面";
        Taske.text   = "\n\nPlease close product details";
        AudioSource.PlayClipAtPoint(clip, transform.position);
    }
Beispiel #25
0
    public void Task7()
    {
        InteractionButton T7InteractionButton = (InteractionButton)T7.GetComponent(typeof(InteractionButton));

        T7InteractionButton.controlEnabled = false;
        T7.transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().materials[0].color = Color.grey;
        t7.interactable = false;

        iftask6 = false;
        iftask7 = true;
        Bag.SetActive(true);

        TaskNum.text = "Task 7  Change color 改变颜色";
        Taskc.text   = "\n\n请依次改变背包的颜色为红,蓝,绿\n\n选择成功时,您将听到提示音";
        Taske.text   = "\nPlease change the color of bag \nin the order of RED, BLUE and GREEN.\n\nIf successful, you will hear a button sound";
        AudioSource.PlayClipAtPoint(clip, transform.position);
    }
Beispiel #26
0
    public void Task1()
    {
        InteractionButton T1InteractionButton = (InteractionButton)T1.GetComponent(typeof(InteractionButton));

        T1InteractionButton.controlEnabled = false;
        T1.transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().materials[0].color = Color.grey;
        t1.interactable = false;

        biaoqian.SetActive(false);
        iftask1 = true;
        Bag.SetActive(true);

        TaskNum.text = "Task 1  Grab 抓取";
        Taskc.text   = "\n请抓取红色背包\n\n抓取成功时,背包将跟随您移动";
        Taske.text   = "\nPlease grab the red bag.\n\nIf successful, the bag will follow you.";
        AudioSource.PlayClipAtPoint(clip, transform.position);
    }
    // Use this for initialization
    void Start()
    {
        intMetal = sliderMetal.GetComponent <InteractionSlider>();
        intWood  = sliderWood.GetComponent <InteractionSlider>();
        intBrick = sliderBrick.GetComponent <InteractionSlider>();
        intWater = sliderWater.GetComponent <InteractionSlider>();
        intSkin  = sliderSkin.GetComponent <InteractionSlider>();

        intButtonNext = nextButton.GetComponent <InteractionButton>();

        // Initial setup for which blocks should be shown
        metalBlock.SetActive(true);
        woodBlock.SetActive(false);
        brickBlock.SetActive(false);
        waterBlock.SetActive(false);
        skinBlock.SetActive(false);
    }
Beispiel #28
0
    public override void Open()
    {
        if (spawnedButtons.Count > 0)
        {
            for (int i = spawnedButtons.Count - 1; i >= 0; i--)
            {
                Destroy(spawnedButtons[i]);
            }
        }
        spawnedButtons.Clear();

        IInteractable[] interactions = target.GetComponents <IInteractable>();
        for (int i = 0; i < interactions.Length; i++)
        {
            if (!interactions[i].IsEnabled())
            {
                continue;
            }
            InteractionButton interactionButton = Instantiate(interactionButtonPrefab, transform);
            spawnedButtons.Add(interactionButton.gameObject);
            string interactionName = interactions[i].GetName();
            int    index           = i;
            interactionButton.button.onClick.AddListener(() =>
            {
                InteractionSystem.SendInteraction(interactions[index]);
                Close();
            });

            interactionButton.text.enabled = interactions[i].GetIcon() == null;
            interactionButton.icon.enabled = interactions[i].GetIcon();

            interactionButton.text.SetText(interactions[i].GetName());
            interactionButton.icon.sprite = interactions[i].GetIcon();

            interactionButton.info = interactions[i].GetName();
        }

        gameObject.SetActive(true);
        float duration = .5f;

        open = true;
        tweener.Kill();
        canvasGroup.alpha = 1;
        tweener           = DOTween.To(x => SetRadius(x), 0f, openRadius, duration).SetEase(Ease.OutElastic);
    }
    private void PopulateListInteraction(Node node, int nodeIndex)
    {
        listInteractions = node.GetListInteractions();

        for (int i = 0; i < listInteractions.Count; i++)
        {
            GameObject        newObject = Instantiate(buttonsPrefabs[1], panelInteraction.transform);
            InteractionButton pointer   = newObject.GetComponent <InteractionButton>();

            pointer.SetController(this);
            pointer.SetParentNode(listNodes[i]);
            pointer.SetParentIndex(nodeIndex);
            pointer.SetInteraction(listInteractions[i]);
            pointer.SetIndex(i);

            interactionButtonList.Add(newObject);
        }
    }
Beispiel #30
0
    void Awake()
    {
        txtMessage = GetComponentInChildren <TextMeshPro>();
        txtMessage.SetText(message);

        interactionButton = GetComponentInParent <InteractionButton>();

        //Set button events that this tooltip is child
        if (interactionButton != null)
        {
            interactionButton.OnPrimaryHoverBegin += ShowTooltip;

            interactionButton.OnContactBegin    += HideTooltip;
            interactionButton.OnPrimaryHoverEnd += HideTooltip;
        }

        gameObject.SetActive(false);
    }
	public void AddDialogueOption (InteractionButton dialogueOption) {
		dialogueOptions.Add(dialogueOption);
	}
	public void RemoveDialogueOption (InteractionButton dialogueOption) {
		dialogueOptions.Remove(dialogueOption);
	}