Exemple #1
0
    // ══════════════════════════════════════════════════════════════ METHODS ════
    /// <summary>
    /// Awake is called when the script instance is being loaded.
    /// </summary>
    void Awake()
    {
        // get the reference to the Highlight script
        m_highlight = GetComponent <AC.Highlight> ();

        // get the SpriteRenderer component
        m_spriteRenderer = GetComponent <SpriteRenderer> ();
    }
 public override void AssignValues(List<ActionParameter> parameters)
 {
     if (whatToHighlight == WhatToHighlight.SceneObject)
     {
         highlightObject = AssignFile <Highlight> (parameters, parameterID, constantID, highlightObject);
     }
     else
     {
         invID = AssignInvItemID (parameters, parameterID, invID);
     }
 }
        public override void OnInspectorGUI()
        {
            Highlight _target = (Highlight)target;

            _target.brightenMaterials = EditorGUILayout.Toggle("Auto-brighten materials?", _target.brightenMaterials);
            _target.affectChildren    = EditorGUILayout.Toggle("Also affect child Renderers?", _target.affectChildren);
            _target.maxHighlight      = EditorGUILayout.Slider("Maximum highlight intensity:", _target.maxHighlight, 1f, 5f);
            _target.fadeTime          = EditorGUILayout.Slider("Transition time (s):", _target.fadeTime, 0f, 5f);

            _target.callEvents = EditorGUILayout.Toggle("Call custom events?", _target.callEvents);
            if (_target.callEvents)
            {
                var serializedObject = new UnityEditor.SerializedObject(_target);

                SerializedProperty onHighlightOn  = serializedObject.FindProperty("onHighlightOn");
                SerializedProperty onHighlightOff = serializedObject.FindProperty("onHighlightOff");

                EditorGUILayout.PropertyField(onHighlightOn, true);
                EditorGUILayout.PropertyField(onHighlightOff, true);
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
Exemple #4
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();
        }
 /**
  * <summary>Unregisters a Highlight, so that it is no longer updated</summary>
  * <param name = "_object">The Highlight to unregister</param>
  */
 public void Unregister(Highlight _object)
 {
     highlights.Remove(_object);
 }
 /**
  * <summary>Registers a Highlight, so that it can be updated</summary>
  * <param name = "_object">The Highlight to register</param>
  */
 public void Register(Highlight _object)
 {
     highlights.Add(_object);
 }
        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 ();
        }