Sending messages with Unity

Its been ages since I have used CasparCG and back then i used to build custom skins using Livecode. Since then ive mainly been working coding in C# and unity to make games. I have forgotten all of what i used to do in Livecode and dont have any of my old projects. Has anyone here ever tried to make an interface with Unity that can send messages through TCP/IP to casparCG Server?

I don’t know Unity, but if you can send text strings via TCP/IP I see no reason why this should not be possible.

i checked some youtube tutorials of people sending messages through tcp/ip but the were all saying it was converting to byte. havent found any that did like livecode did

ah ha. found this tutorial. maybe this will work

@#$%#$^@#$@# bought a unity asset that claimed it can send messages as string. but then found it converted the string to a byte array. arrrrg. waste of money.

Got it working with StarDust
Took a while to figure it all out so maybe next weekend i will do a tutorial video on how to get it set up

2 Likes

here is my tutorial

2 Likes

You can use event handler to be notify for connection disconnection :wink:

1 Like

I will you create a simple example without the usage of IoC if you want.

1 Like

I was rushing things so haven’t been able to explore as yet. It took me a day to go from 0 to that where i was in making the tutorial

yes thanks. An example would be great.

using StarDust.CasparCG.net.AmcpProtocol;
using StarDust.CasparCG.net.Connection;
using StarDust.CasparCG.net.Device;
using StarDust.CasparCG.net.Models.Media;


// Use to parse data infos
var dataParser = new CasparCGDataParser();
// Use to interpret AMCP commands
var amcpTCPParser = new AmcpTCPParser(new ServerConnection());
var amcpProtocolParser = new AMCPProtocolParser(amcpTCPParser,dataParser);

// Represent a caspar cg server
var device = new CasparDevice(amcpProtocolParser);

// Connection
Console.WriteLine("Connection to local CasparCG");
device.Connect("localhost");

// Guessing first channel
var firstChannel = device.Channels[0];
firstChannel.LoadBG(new CasparPlayingInfoItem { Clipname = "AMB", VideoLayer = 10 });
// or
var ambClip = device.Mediafiles.FirstOrDefault(x => string.Equals(x.Name, "AMB",StringComparison.InvariantCultureIgnoreCase));
if(ambClip != null)
    firstChannel.LoadBG(new CasparPlayingInfoItem(ambClip.Name));
else{
    Console.WriteLine("Can't find AMB clip");
}
Console.WriteLine("AMB clip was loaded");
firstChannel.Play();
Privacy Policy   Terms of Service