Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Assets Game Framework - FREE asset for Levels, Menus, Dialogs, Social, Free Prize, Localisation, IAP, ...++

Discussion in 'Works In Progress - Archive' started by mahewitt, Jan 25, 2016.

  1. mahewitt

    mahewitt

    Joined:
    Mar 19, 2014
    Posts:
    279
    Pro Pooling update #2. Add Pools component for adding per scene pools into Pool Manager (in addition to global Pool Manager pools and stand alone / Pool Manager pools created through the API).

    upload_2018-2-1_19-28-2.png
     
    Last edited: Feb 1, 2018
  2. mahewitt

    mahewitt

    Joined:
    Mar 19, 2014
    Posts:
    279
    Pro Pooling update #3. Updated despawning components.

    DespawnCollision.PNG DespawnCollision2D.PNG DespawnDelay.PNG
     
    Last edited: Feb 1, 2018
  3. mahewitt

    mahewitt

    Joined:
    Mar 19, 2014
    Posts:
    279
    Almost there with a new release now.

    Pro Pooling Update #4: Spawning component

    Spawner.PNG
     
  4. mahewitt

    mahewitt

    Joined:
    Mar 19, 2014
    Posts:
    279
    Pro Pooling Update #5: Game Framework Spawning actions. Below used in a Game Framework collision handler to spawn on a collision:

    upload_2018-2-9_19-29-10.png
     
  5. jim00

    jim00

    Joined:
    Feb 1, 2015
    Posts:
    57
    Hi,
    I'm kinda new to GFW. I try to learn how to use your messaging system. I know how to received GFW message using RunOnMessage but I have trouble understand Submitting Message.

    I have read the code on GFW tutorial and the code in the GameFramework/Scripts/Messaging/ but still don't have a complete picture of how to put all the pieces together.

    Do you mind give me a simple & complete code example for sending to receiving message, please.

    thanks
     
  6. mahewitt

    mahewitt

    Joined:
    Mar 19, 2014
    Posts:
    279
  7. jim00

    jim00

    Joined:
    Feb 1, 2015
    Posts:
    57
    Thanks Mark for your reply,
    yap I have read that Messaging Documentation too. The only thing is that I don't know how to put everything into a complete script to make it to work. I'm a bit of a new here any help is much appreciated.

    thanks.

    btw, I try to register to your forum but for some reason it keep rejecting my registration.
     
  8. jim00

    jim00

    Joined:
    Feb 1, 2015
    Posts:
    57
    After some re-reading, I come to understand of setting up a message but still have trouble on how to submit a message, where do I put the QueueMessage or TriggerMessage or how to use those.

    Gamemanager. Messenger.QueueMessage(new MyCustomMessage());
    Gamemanager. Messenger.TriggerMessage(new MyCustomMessage());


    Thanks.

    p.s. I think there is a typo in the documentation code for messaging, it's Gamemanager.Messanger... or GameManager
     
  9. mahewitt

    mahewitt

    Joined:
    Mar 19, 2014
    Posts:
    279
    Thanks for pointing out the typo - it should be GameManager as you point out. I will update.

    Where to put the calls depends upon what condition you want to send messages on so it could be in Update if based on a condition you are checking every frame, OnCollision if from a collision etc.. TriggerMessage will send a message straight away. QueueMessage will add it to a Queue that will be called nexttime

    Such messages should generally be things that might be of interest to several other components. If you see components polling a particular condition (especially if there are many of them) then consider swapping out with a message as it might well give better performance. If you only want to notify a single other component then you can just add a public variable of the component type to your MonoBehaviour as in such cases that might be quicker.

    Hope that helps? If you have a particular scenario in mind I can perhaps comment further.

    Regards,
    Mark
     
  10. jim00

    jim00

    Joined:
    Feb 1, 2015
    Posts:
    57
    Code (CSharp):
    1.  
    2. //Ok, here are my code, I try to send a message using a modify HealthChangedMessage() by adding a 1 at the end of the method eg. HealthChangedMessage1():
    3.  
    4. using GameFramework.Messaging;
    5.  
    6. namespace GameFramework.GameStructure.Players.Messages
    7. {
    8.     /// <summary>
    9.     /// A message that is generated when the health of the player has is changed.
    10.     /// </summary>
    11.     public class HealthChangedMessage1 : BaseMessage
    12.     {
    13.      
    14.         /// <summary>
    15.         /// The Players new health
    16.         /// </summary>
    17.         public readonly float NewHealth;
    18.  
    19.         /// <summary>
    20.         /// The Players old health
    21.         /// </summary>
    22.         public readonly float OldHealth;
    23.  
    24.         public HealthChangedMessage1(float newHealth, float oldHealth)
    25.         {
    26.             NewHealth = newHealth;
    27.             OldHealth = oldHealth;
    28.         }
    29.  
    30.         /// <summary>
    31.         /// Return a representation of the message
    32.         /// </summary>
    33.         // <returns></returns>
    34.         public override string ToString()
    35.         {
    36.             return string.Format("jim03-New Health {0}, Old Health {1}", NewHealth, OldHealth);
    37.         }
    38.     }
    39. }
    40. -----------------------------------------------------------------------------------
    41. //When I use a trigger, to send using QueueMessage, I got an error of no argument
    42.  
    43. using GameFramework.GameStructure;
    44. using GameFramework.GameStructure.Players.Messages;
    45. using System.Collections;
    46. using System.Collections.Generic;
    47. using UnityEngine;
    48.  
    49. public class EnterCollision : MonoBehaviour {
    50.     void OnTriggerEnter(Collider collider) {
    51.         if (collider.gameObject.tag == "Player")
    52.         {
    53.             GameManager.Messenger.QueueMessage(new HealthChangedMessage1());
    54.             //GameManager.Messenger.TriggerMessage(new HealthChangedMessage1());
    55.             Debug.Log("Collition enter");
    56.         }
    57.     }
    58. }
    59.  
    60. //Error: No argument given for HealthChangedMessage1(float, float)
    61.  
    62. -----------------------------------------------------------------------------------
    63.  
    64. using System.Collections;
    65. using System.Collections.Generic;
    66. using UnityEngine;
    67. using GameFramework.Messaging.Components.AbstractClasses;
    68. using GameFramework.GameStructure.Players.Messages;
    69.  
    70.  
    71. //namespace GameFramework.GameStructure.Players.Components{
    72. public class jimMsg03 : RunOnMessage<HealthChangedMessage1> {
    73.  
    74.     public override bool RunMethod(HealthChangedMessage1 message)        {
    75.             Debug.Log("HealthChangejimMsg03 " + message);
    76.             return true;
    77.         }
    78. }
    79.  
    80.  
     
  11. mahewitt

    mahewitt

    Joined:
    Mar 19, 2014
    Posts:
    279
    Hi. @jim00 The code looks good, except that in line 53 you probably need two parameters into the constructor corresponding to newHealth and oldHealth.

    Mark
     
  12. jim00

    jim00

    Joined:
    Feb 1, 2015
    Posts:
    57
    Do you mind show me the code on how to do this. tkz.


    I had try using :
    Code (CSharp):
    1.  GameManager.Messenger.QueueMessage(new HealthChangedMessage1(newHealth1, oldHealth1));
    //Error: The name 'newHealth1' dose not exist in the current context
    //Error: The name 'oldHealth1' dose not exist in the current context
     
  13. mahewitt

    mahewitt

    Joined:
    Mar 19, 2014
    Posts:
    279
    @jim00 so you will either need to define those variables, or hard code values into the constructor like below e.g.:

    GameManager.Messenger.QueueMessage(new HealthChangedMessage1(0, 1));

    I am assuming here that this is just a test. If you need actual health values then these can be gotten / set from:

    GameManager.Instance.Player.Health


    Which will send out it's own message.
     
  14. jim00

    jim00

    Joined:
    Feb 1, 2015
    Posts:
    57
    Oh, now i understand why we need those 2 parameters. tkx
     
    mahewitt likes this.
  15. mahewitt

    mahewitt

    Joined:
    Mar 19, 2014
    Posts:
    279
    For info v5.0.3 was recently released. The main update is a major overhaul and update to Pro Pooling included in the Extras bundle, otherwise there are several minor improvements and fixes.

    Note: Always take a backup before upgrading.
    See here for a full list of changes

    Game Framework - Free
    Game Framework - Extras Bundle