Example #1
0
        /// <summary>
        /// Set a property which will be accessible in Javascript.
        /// For example: Bridge.SetProperty("MyObject", "someValue", "Hello World!");
        /// would be accessible in Javascript as:
        /// MyObject.someValue;
        /// See uWebKitExamples/WebBrowser/UnityPageInfo.cs in examples
        /// </summary>
        public static void SetProperty(string objectName, string propName, string value)
        {
            if (!objects.ContainsKey(objectName))
            {
                AddObject(objectName);
            }

            BridgeObject bo = objects [objectName];

            string v;

            if (bo.Properties.TryGetValue(propName, out v))
            {
                if (value == v)
                {
                    return;
                }
            }
            // save the trip
            // instant here
            bo.Properties [propName] = value;

            // and out to web process
            Command cmd = Command.NewCommand("SETP", objectName, propName, value);

            cmd.Post();
        }
Example #2
0
        /// <summary>
        /// Posts an exit command to the command queue
        /// </summary>
        public void Stop()
        {
#if !UNITY_IPHONE || UNITY_EDITOR
            if (UWKConfig.DebugProcess)
            {
                return;
            }

            Command cmd = Command.NewCommand("EXIT");
            cmd.Post();
#endif
        }
Example #3
0
        /// <summary>
        /// Explicitly add an object (Note: if you just set a property on a non-existant object will be created)
        /// </summary>
        public static BridgeObject AddObject(string objectName)
        {
            if (objects.ContainsKey(objectName))
            {
                Debug.LogWarning("Object " + objectName + " already exists");
                return(objects [objectName]);
            }

            BridgeObject bo = objects [objectName] = new BridgeObject();

            bo.Name = objectName;

            Command cmd = Command.NewCommand("ADDO", objectName);

            cmd.Post();

            return(bo);
        }