Ejemplo n.º 1
0
    static void OnServoWindowCreated(int uid, int windowIndex, int widthPixels, int heightPixels, int formatNative)
    {
        TextureFormat format = ServoUnityTextureUtils.GetTextureFormatFromNativeTextureFormat(formatNative);

        if (widthPixels == 0 || heightPixels == 0 || format == (TextureFormat)0)
        {
            Debug.LogError("OnServoWindowCreated got invalid format.");
            return;
        }

        // If we initiated the creation of the new window, this find operation will succeed. But
        // if Servo initiated the creation, then there isn't yet a Unity object backing it, so
        // we'll need to create one.
        ServoUnityWindow window = ServoUnityWindow.FindWindowWithUID(uid);

        if (window == null)
        {
            ServoUnityController suc = FindObjectOfType <ServoUnityController>(); // Create it on the same gameobject holding the ServoUnityController.
            if (!suc)
            {
                Debug.LogError("ServoUnityController.OnServoWindowCreated: Couldn't find a ServoUnityController.");
                return;
            }
            window = ServoUnityWindow.CreateNewInParent(suc.transform.parent.gameObject);
        }

        window.WasCreated(windowIndex, widthPixels, heightPixels, format);
    }
Ejemplo n.º 2
0
    public bool ServoUnityGetWindowTextureFormat(int windowIndex, out int width, out int height, out TextureFormat format,
                                                 out bool mipChain, out bool linear, out IntPtr nativeTexureID)
    {
        int formatNative;

        IntPtr[] nativeTextureIDHandle = new IntPtr[1];
        ServoUnityPlugin_pinvoke.servoUnityGetWindowTextureFormat(windowIndex, out width, out height, out formatNative, out mipChain,
                                                                  out linear, nativeTextureIDHandle);
        nativeTexureID = nativeTextureIDHandle[0];

        format = ServoUnityTextureUtils.GetTextureFormatFromNativeTextureFormat(formatNative);
        if (format == (TextureFormat)0)
        {
            return(false);
        }

        return(true);
    }