Inheritance: UnityEngine.ScriptableObject
Exemple #1
0
    //prototype delegate for updating client textures - unneeded now that we're using direct callbacks.
//	public delegate void UpdateClientTexturesHandler();
//	public static event UpdateClientTexturesHandler UpdateClientTextures;

    private void registerClientInstance(SyphonClientTexture tex, SyphonClientObject obj)
    {
        if (!clientInstances.ContainsKey(tex))
        {
            clientInstances.Add(tex, obj);
        }
    }
 public void handleUpdateClientTextureSize(SyphonClientObject client)
 {
     if(client == clientObject){
         //texture resize here- resize your plane, or whatever you want to do. use client.Width and client.Height
         gameObject.SendMessage("UpdateAspectRatio",new Vector2(client.Width, client.Height), SendMessageOptions.DontRequireReceiver);
     }
 }
Exemple #3
0
 public void handleRetireClient(SyphonClientObject client)
 {
     if (client == clientObject)
     {
         //your syphonClient may soon go null as it is either 1) being destroyed from the clients list as there is no more reason to keep it alive or 2) the server has disappeared
     }
 }
Exemple #4
0
 public static void RegisterClientInstance(SyphonClientTexture tex, SyphonClientObject obj)
 {
     if (Syphon.instance != null)
     {
         Syphon.Instance.registerClientInstance(tex, obj);
     }
 }
Exemple #5
0
 public void handleUpdateClientTextureSize(SyphonClientObject client)
 {
     if (client == clientObject)
     {
         //texture resize here- resize your plane, or whatever you want to do. use client.Width and client.Height
     }
 }
Exemple #6
0
    public static void OnRetireServer(string appName, string name, string uuid)
    {
        string realAppName = "";
        string realName    = "";

        //if there are any ACTIVE client singleton objects in use,
        //destroy them immediately.
        //destroy their texture and destroy the pointer to them, and remove them from the SyphonClients list.
        SyphonClientObject result = Syphon.GetSyphonClient(uuid);

        if (result)
        {
            //because the Syphon callback may not have a valid appName and name key in the OnServerRetire Syphon callback,
            //we need to ensure we get the extract those cached names from the uuid/instance.
            realAppName = result.BoundAppName;
            realName    = result.BoundName;

            DestroyClient(result);
        }

//		//now remove the server name
//		//if it doesn't contain the appName key, you shouldn't have to do anything.
        if (Syphon.Servers.ContainsKey(realAppName))
        {
            if (realName == "")
            {
                //if the name is UNNAMED_STRING and it contains the unnamed string, remove the server from the list.
                if (Syphon.Servers[realAppName].ContainsKey(Syphon.UNNAMED_STRING))
                {
                    Syphon.Servers[realAppName].Remove(Syphon.UNNAMED_STRING);

                    //if there are no more objects in the dictionary list for that app, remove the associated appName entry
                    if (Syphon.Servers[realAppName].Count == 0)
                    {
                        Syphon.Servers.Remove(realAppName);
                    }
                }
            }
            //if the name is valid and the server's app dictionary contains the name string, remove the server from the list.
            else if (Syphon.Servers[realAppName].ContainsKey(realName))
            {
                Syphon.Servers[realAppName].Remove(realName);

                //if there are no more entries in the dictionary list for that app, remove the associated appName entry
                if (Syphon.Servers[realAppName].Count == 0)
                {
                    Syphon.Servers.Remove(realAppName);
                }
            }

            //TODO: remove this.
            Instance.UpdateServerNames();
        }

        if (RetireServer != null)
        {
            RetireServer(realAppName, realName);
        }
    }
Exemple #7
0
 public void handleUpdateClientTextureSize(SyphonClientObject client)
 {
     if (client == clientObject)
     {
         //texture resize here- resize your plane, or whatever you want to do. use client.Width and client.Height
         gameObject.SendMessage("UpdateAspectRatio", new Vector2(client.Width, client.Height), SendMessageOptions.DontRequireReceiver);
     }
 }
Exemple #8
0
 //removes the client from the clients list and destroys it.
 public static void DestroyClient(SyphonClientObject destroyObj)
 {
     if (destroyObj != null)
     {
         Syphon.SyphonClients.Remove(destroyObj);
         DestroyImmediate(destroyObj);
         destroyObj = null;
     }
 }
Exemple #9
0
    public void drawGUIClientEditor()
    {
        foreach (KeyValuePair <string, string[]> kvp in SyphonTarget.clientAppNames)
        {
            GUI.changed = false;
            int selectIndex = 0;

            //if you're not drawing the one you've selected, the index is 0.
            if (kvp.Key != clientConfirmKey)
            {
                selectIndex = 0;
            }
            //otherwise, the index is whatever the selected index is.
            else
            {
                selectIndex = GUIClientSelectionIndex;
            }

            selectIndex = EditorGUILayout.Popup(kvp.Key, selectIndex, kvp.Value);
            if (GUI.changed)
            {
                //Debug.Log("Selected: " + kvp.Key + " : " +  kvp.Value[GUIClientSelectionIndex] + "!");
                GUIClientSelectionIndex = selectIndex;
                showClientConfirmState  = true;
                clientConfirmKey        = kvp.Key;
                clientConfirmValue      = kvp.Value[GUIClientSelectionIndex];
                selectedClientObj       = Syphon.GetSyphonClient(clientConfirmKey, clientConfirmValue);
            }
        }

        if (showClientConfirmState && selectedClientObj != null)
        {
            SyphonClientObject destroyObj = null;

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            GUILayout.Label("App: " + selectedClientObj.AttachedServer.SyphonServerDescriptionAppName + "\nName: " +
                            selectedClientObj.AttachedServer.SyphonServerDescriptionName);
            if (GUILayout.Button("remove client"))
            {
                destroyObj = selectedClientObj;
            }
            GUILayout.EndVertical();
            GUILayout.Label(new GUIContent("", selectedClientObj.AttachedTexture, "App: " +
                                           selectedClientObj.AttachedServer.SyphonServerDescriptionAppName + "\nName: "
                                           + selectedClientObj.AttachedServer.SyphonServerDescriptionName), GUILayout.MaxWidth(150), GUILayout.MaxHeight(128));
            GUILayout.EndHorizontal();

            if (destroyObj != null)
            {
                Syphon.DestroyClient(destroyObj);
                showClientConfirmState  = false;
                GUIClientSelectionIndex = 0;
            }
        }
    }
Exemple #10
0
 void Start()
 {
     clientObject = Syphon.GetSyphonClient(clientAppName, clientName);
     //if the client object exists,
     if (clientObject != null)
     {
         //if the texture has been initialized, apply its texture to something.
         ApplyTexture();
     }
 }
Exemple #11
0
 public void handleUpdateClientTextureSize(SyphonClientObject client)
 {
     if (client == clientObject)
     {
         //the client has a valid texture size, which means the texture is valid, so apply it to the object.
         ApplyTexture();
         //texture resize here- resize your plane, or whatever you want to do. use client.Width and client.Height
         gameObject.SendMessage("UpdateAspectRatio", new Vector2(client.Width, client.Height), SendMessageOptions.DontRequireReceiver);
     }
 }
Exemple #12
0
 //removes the client from the clients list and destroys it.
 public static void DestroyClient(SyphonClientObject destroyObj)
 {
     if (destroyObj != null)
     {
         Syphon.UnsortedClients.Remove(destroyObj);
         DestroyImmediate(destroyObj);
         destroyObj = null;
         Syphon.Instance.UpdateClientNames();
     }
 }
//i don't trust that this doesn't crash unity. need more testing.
//	public SyphonClientTexture(){
//		Syphon.syphonScriptCount++;
//	}
//	~SyphonClientTexture(){
//		Syphon.syphonScriptCount--;
//	}
#endif

	void setupTexture(){
		//when you initialize the client texture, you should TRY to create the syphon client object. 
		//if it needs to exist because the server is available, it will create it. if the server is offline,
		//nothing will happen. this basically initializes a singleton for that particular server appName/name.		
		clientObject = Syphon.CreateClient (clientAppName, clientName);
//		if the client object exists
		if(clientObject != null){
			//only registers it if it doesn't already exist.
			Syphon.RegisterClientInstance(this, clientObject);
		}		
	}
 public static bool Match(SyphonClientObject a, SyphonClientObject b)
 {
     if (a.boundAppName == b.boundAppName && a.boundName == b.boundName)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #15
0
//i don't trust that this doesn't crash unity. need more testing.
//	public SyphonClientTexture(){
//		Syphon.syphonScriptCount++;
//	}
//	~SyphonClientTexture(){
//		Syphon.syphonScriptCount--;
//	}
#endif

    void setupTexture()
    {
        //when you initialize the client texture, you should TRY to create the syphon client object.
        //if it needs to exist because the server is available, it will create it. if the server is offline,
        //nothing will happen. this basically initializes a singleton for that particular server appName/name.
        clientObject = Syphon.CreateClient(clientAppName, clientName);
//		if the client object exists
        if (clientObject != null)
        {
            //only registers it if it doesn't already exist.
            Syphon.RegisterClientInstance(this, clientObject);
        }
    }
    public void handleAnnounceClient(SyphonClientObject client)
    {
        if(!client.MatchesDescription(clientAppName, clientName)){
            return; //if the announced client was not this client, ignore it.
        }

        if(clientObject == null){
            //if the client had been previously destroyed or not initialized, re-init now.
            Start();
        }
        else if(clientObject != null){
            ApplyTexture();
        }
    }
Exemple #17
0
    public void handleAnnounceClient(SyphonClientObject client)
    {
        if (!client.MatchesDescription(clientAppName, clientName))
        {
            return;             //if the announced client was not this client, ignore it.
        }

        if (clientObject == null)
        {
            //if the client had been previously destroyed or not initialized, re-init now.
            Start();
        }
        else if (clientObject != null)
        {
            ApplyTexture();
        }
    }
Exemple #18
0
    public static SyphonClientObject AddClientToSyphonClientsList(string appName, string name, SyphonServerObject server)
    {
        SyphonClientObject result = GetSyphonClient(appName, name);

        // Debug.Log(result.BoundAppName + " " + result.BoundName + " was the result");
        if (result == null)
        {
//			UnityEngine.Debug.Log("DIDNT EXIST: " + appName + "/" +name);
            //if it was null when trying to add a new client, just add a new one and init.
            result = ScriptableObject.CreateInstance <SyphonClientObject>();
            result.DefineSyphonClient(server);
            Syphon.SyphonClients.Add(result);
        }
        else
        {
//			UnityEngine.Debug.Log("EXISTED: " + appName + "/" +name + ". doing nothing.");
        }

        return(result);
    }
Exemple #19
0
    public static void AddClientToUnsortedList(string appName, string name, SyphonServerObject server)
    {
        SyphonClientObject result = GetSyphonClient(appName, name);

        // Debug.Log(result.BoundAppName + " " + result.BoundName + " was the result");
        if (result == null)
        {
//			Debug.Log("DIDNT EXIST: " + appName + "/" +name);
            //if it was null when trying to add a new client, just add a new one and init.
            Syphon.UnsortedClients.Add(ScriptableObject.CreateInstance <SyphonClientObject>());
            Syphon.UnsortedClients[Syphon.UnsortedClients.Count - 1].DefineSyphonClient(server);
            Syphon.UnsortedClients[Syphon.UnsortedClients.Count - 1].InitSyphonClient();
        }
        else
        {
//			Debug.Log("EXISTED: " + appName + "/" +name);
            result.DestroySyphonClient();
            result.DefineSyphonClient(server);
            result.InitSyphonClient();
        }
    }
Exemple #20
0
 private void unregisterClientInstance(SyphonClientTexture tex)
 {
     if (clientInstances.ContainsKey(tex))
     {
         SyphonClientObject obj = clientInstances[tex];
         clientInstances.Remove(tex);
         //iterate through all the syphonClients.
         //if there are no more objects that match the object listed, destroy the bitch.
         bool found = false;
         foreach (KeyValuePair <SyphonClientTexture, SyphonClientObject> kvp in clientInstances)
         {
             //if you find an object registered that matches the syphon client list, dont destroy it yet.
             if (kvp.Value == obj && kvp.Key != tex)
             {
                 found = true;
             }
         }
         if (!found)
         {
             DestroyClient(obj);
         }
     }
 }
    public void DefineSyphonClient(SyphonClientObject client)
    {
        // UnityEngine.Debug.Log("created syphon client: " + boundName + " " +boundAppName);
        //hold on to object reference
        attachedServer = client.attachedServer;
        boundAppName   = client.AttachedServer.SyphonServerDescriptionAppName;
        if (client.AttachedServer.SyphonServerDescriptionName == "")
        {
            boundName = Syphon.UNNAMED_STRING;
        }
        else
        {
            boundName = client.AttachedServer.SyphonServerDescriptionName;
        }

        //initialize the texture
        if (attachedTexture == null)
        {
            attachedTexture            = new RenderTexture(128, 128, 0, RenderTextureFormat.ARGB32);
            attachedTexture.filterMode = FilterMode.Bilinear;
            attachedTexture.wrapMode   = TextureWrapMode.Clamp;
        }
        //TODO: create the syphon client in plugin
    }
 public static bool Match(SyphonClientObject a, SyphonClientObject b)
 {
     if(a.boundAppName == b.boundAppName && a.boundName == b.boundName){
         return true;
     }
     else return false;
 }
Exemple #23
0
    public void DefineSyphonClient(SyphonClientObject client)
    {
        // UnityEngine.Debug.Log("created syphon client: " + boundName + " " +boundAppName);
        //hold on to object reference
        attachedServer = client.attachedServer;
        boundAppName = client.AttachedServer.SyphonServerDescriptionAppName;
        if(client.AttachedServer.SyphonServerDescriptionName == "")
            boundName = Syphon.UNNAMED_STRING;
        else
            boundName = client.AttachedServer.SyphonServerDescriptionName;

        //initialize the texture
        if(attachedTexture == null){
        attachedTexture = new RenderTexture(128, 128, 0, RenderTextureFormat.ARGB32);
        attachedTexture.filterMode = FilterMode.Bilinear;
        attachedTexture.wrapMode = TextureWrapMode.Clamp;
        }
        //TODO: create the syphon client in plugin
    }
	public void handleUpdateClientTextureSize(SyphonClientObject client){
		if(client == clientObject){			
			//the client has a valid texture size, which means the texture is valid, so apply it to the object.
			ApplyTexture();
			//texture resize here- resize your plane, or whatever you want to do. use client.Width and client.Height
			gameObject.SendMessage("UpdateAspectRatio",new Vector2(client.Width, client.Height), SendMessageOptions.DontRequireReceiver);
		}
	}
 //removes the client from the clients list and destroys it.
 public static void DestroyClient(SyphonClientObject destroyObj)
 {
     if(destroyObj != null){
     Syphon.SyphonClients.Remove(destroyObj);
     DestroyImmediate(destroyObj);
     destroyObj = null;
     }
 }
 //prototype delegate for updating client textures - unneeded now that we're using direct callbacks.
 //    public delegate void UpdateClientTexturesHandler();
 //    public static event UpdateClientTexturesHandler UpdateClientTextures;
 private void registerClientInstance(SyphonClientTexture tex, SyphonClientObject obj)
 {
     if(!clientInstances.ContainsKey(tex)){
         clientInstances.Add(tex, obj);
     }
 }
Exemple #27
0
    public void drawGUIClientEditor()
    {
        foreach(KeyValuePair<string,string[]> kvp in SyphonTarget.clientAppNames){
            GUI.changed = false;
            int selectIndex = 0;

            //if you're not drawing the one you've selected, the index is 0.
            if(kvp.Key != clientConfirmKey){
                selectIndex = 0;
            }
            //otherwise, the index is whatever the selected index is.
            else
            selectIndex = GUIClientSelectionIndex;

            selectIndex = EditorGUILayout.Popup(kvp.Key, selectIndex, kvp.Value);
            if(GUI.changed){
                //Debug.Log("Selected: " + kvp.Key + " : " +  kvp.Value[GUIClientSelectionIndex] + "!");
                GUIClientSelectionIndex = selectIndex;
                showClientConfirmState = true;
                clientConfirmKey = kvp.Key;
                clientConfirmValue = kvp.Value[GUIClientSelectionIndex];
                selectedClientObj = Syphon.GetSyphonClient(clientConfirmKey, clientConfirmValue);
            }
        }

        if(showClientConfirmState && selectedClientObj != null){

            SyphonClientObject destroyObj = null;

                GUILayout.BeginHorizontal();
                GUILayout.BeginVertical();
                GUILayout.Label("App: "+ selectedClientObj.AttachedServer.SyphonServerDescriptionAppName + "\nName: " +
                 selectedClientObj.AttachedServer.SyphonServerDescriptionName);
                if(GUILayout.Button("remove client")){
                    destroyObj = selectedClientObj;
                }
                GUILayout.EndVertical();
                GUILayout.Label(new GUIContent("", selectedClientObj.AttachedTexture,"App: "+
                 selectedClientObj.AttachedServer.SyphonServerDescriptionAppName + "\nName: "
                 + selectedClientObj.AttachedServer.SyphonServerDescriptionName), GUILayout.MaxWidth(150), GUILayout.MaxHeight(128));
                GUILayout.EndHorizontal();

            if(destroyObj != null){
                Syphon.DestroyClient(destroyObj);
                showClientConfirmState = false;
                GUIClientSelectionIndex = 0;
            }
        }
    }
 public void handleRetireClient(SyphonClientObject client)
 {
     if(client == clientObject){
         //your syphonClient may soon go null as it is either 1) being destroyed from the clients list or 2) the server has disappeared
     }
 }
 void Start()
 {
     clientObject =  Syphon.GetSyphonClient(clientAppName, clientName);
     //if the client object exists,
     if(clientObject != null){
         //if the texture has been initialized, apply its texture to something.
         ApplyTexture();
     }
 }
 public static void RegisterClientInstance(SyphonClientTexture tex, SyphonClientObject obj)
 {
     if(Syphon.instance != null)
     Syphon.Instance.registerClientInstance(tex, obj);
 }
 public void handleUpdateClientTextureSize(SyphonClientObject client)
 {
     if(client == clientObject){
         //texture resize here- resize your plane, or whatever you want to do. use client.Width and client.Height
     }
 }
 //removes the client from the clients list and destroys it.
 public static void DestroyClient(SyphonClientObject destroyObj)
 {
     if(destroyObj != null){
         Syphon.UnsortedClients.Remove(destroyObj);
         DestroyImmediate(destroyObj);
         destroyObj = null;
         Syphon.Instance.UpdateClientNames();
     }
 }