Esempio n. 1
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            whatToHighlight = (WhatToHighlight)EditorGUILayout.EnumPopup("What to highlight:", whatToHighlight);

            if (whatToHighlight == WhatToHighlight.SceneObject)
            {
                parameterID = Action.ChooseParameterGUI("Object to highlight:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID      = 0;
                    highlightObject = null;
                }
                else
                {
                    highlightObject = (Highlight)EditorGUILayout.ObjectField("Object to highlight:", highlightObject, typeof(Highlight), true);

                    constantID      = FieldToID <Highlight> (highlightObject, constantID);
                    highlightObject = IDToField <Highlight> (highlightObject, constantID, false);
                }
            }
            else if (whatToHighlight == WhatToHighlight.InventoryItem)
            {
                if (!inventoryManager)
                {
                    inventoryManager = AdvGame.GetReferences().inventoryManager;
                }

                if (inventoryManager)
                {
                    // Create a string List of the field's names (for the PopUp box)
                    List <string> labelList = new List <string>();

                    int i = 0;
                    if (parameterID == -1)
                    {
                        invNumber = -1;
                    }

                    if (inventoryManager.items.Count > 0)
                    {
                        foreach (InvItem _item in inventoryManager.items)
                        {
                            labelList.Add(_item.label);
                            if (_item.id == invID)
                            {
                                invNumber = i;
                            }
                            i++;
                        }

                        if (invNumber == -1)
                        {
                            ACDebug.LogWarning("Previously chosen item no longer exists!");
                            invNumber = 0;
                            invID     = 0;
                        }

                        //
                        parameterID = Action.ChooseParameterGUI("Inventory item:", parameters, parameterID, ParameterType.InventoryItem);
                        if (parameterID >= 0)
                        {
                            invNumber = Mathf.Min(invNumber, inventoryManager.items.Count - 1);
                            invID     = -1;
                        }
                        else
                        {
                            invNumber = EditorGUILayout.Popup("Inventory item:", invNumber, labelList.ToArray());
                            invID     = inventoryManager.items[invNumber].id;
                        }
                        //
                    }

                    else
                    {
                        EditorGUILayout.HelpBox("No inventory items exist!", MessageType.Info);
                        invID     = -1;
                        invNumber = -1;
                    }
                }
            }

            highlightType = (HighlightType)EditorGUILayout.EnumPopup("Highlight type:", highlightType);
            if (highlightType == HighlightType.Enable || highlightType == HighlightType.Disable)
            {
                isInstant = EditorGUILayout.Toggle("Is instant?", isInstant);
            }

            AfterRunningOption();
        }
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            whatToHighlight = (WhatToHighlight) EditorGUILayout.EnumPopup ("What to highlight:", whatToHighlight);

            if (whatToHighlight == WhatToHighlight.SceneObject)
            {
                parameterID = Action.ChooseParameterGUI ("Object to highlight:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID = 0;
                    highlightObject = null;
                }
                else
                {
                    highlightObject = (Highlight) EditorGUILayout.ObjectField ("Object to highlight:", highlightObject, typeof (Highlight), true);

                    constantID = FieldToID <Highlight> (highlightObject, constantID);
                    highlightObject = IDToField <Highlight> (highlightObject, constantID, false);
                }
            }
            else if (whatToHighlight == WhatToHighlight.InventoryItem)
            {
                if (!inventoryManager)
                {
                    inventoryManager = AdvGame.GetReferences ().inventoryManager;
                }

                if (inventoryManager)
                {
                    // Create a string List of the field's names (for the PopUp box)
                    List<string> labelList = new List<string>();

                    int i = 0;
                    if (parameterID == -1)
                    {
                        invNumber = -1;
                    }

                    if (inventoryManager.items.Count > 0)
                    {
                        foreach (InvItem _item in inventoryManager.items)
                        {
                            labelList.Add (_item.label);
                            if (_item.id == invID)
                            {
                                invNumber = i;
                            }
                            i++;
                        }

                        if (invNumber == -1)
                        {
                            ACDebug.LogWarning ("Previously chosen item no longer exists!");
                            invNumber = 0;
                            invID = 0;
                        }

                        //
                        parameterID = Action.ChooseParameterGUI ("Inventory item:", parameters, parameterID, ParameterType.InventoryItem);
                        if (parameterID >= 0)
                        {
                            invNumber = Mathf.Min (invNumber, inventoryManager.items.Count-1);
                            invID = -1;
                        }
                        else
                        {
                            invNumber = EditorGUILayout.Popup ("Inventory item:", invNumber, labelList.ToArray());
                            invID = inventoryManager.items[invNumber].id;
                        }
                        //
                    }

                    else
                    {
                        EditorGUILayout.HelpBox ("No inventory items exist!", MessageType.Info);
                        invID = -1;
                        invNumber = -1;
                    }
                }
            }

            highlightType = (HighlightType) EditorGUILayout.EnumPopup ("Highlight type:", highlightType);
            if (highlightType == HighlightType.Enable || highlightType == HighlightType.Disable)
            {
                isInstant = EditorGUILayout.Toggle ("Is instant?", isInstant);
            }

            AfterRunningOption ();
        }