Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Need two components to work together, with only one actually doing the 'work'?
- //E.g. two audio scripts that only want to play 1 sound on collision.
- //Just use the following Pseudo Code
- //OnCollision:
- //audio.OnCooperative(other.audio, () => audio.PlaySound("Bazinga!"));
- using UnityEngine;
- using System;
- using System.Collections.Generic;
- public static class Helper
- {
- /*public static int Counter = 0;
- public static Dictionary<Component, int> coop = new Dictionary<Component, int>();
- public static void OnCooperative(this Component first, Component second, Action action)
- {
- if (!coop.ContainsKey(first)) coop[first] = Counter++;
- if (!coop.ContainsKey(second)) coop[second] = Counter++;
- if (coop[first] > coop[second]) action();
- }*/
- public static void OnCooperative(this Component first, Component second, Action action)
- {
- if (first.GetInstanceID() > second.GetInstanceID()) action();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement