Exemple #1
0
        public Vector3 c, s;    // Center, Size

        /// <summary>
        /// Creates serializable BoxCollider from Unity component
        /// </summary>
        /// <param name="injector"></param>
        /// <param name="component"></param>
        public BoxColliderSerializable(Injector injector, Component component) : base(injector, component)
        {
            BoxCollider boxcollider = (BoxCollider)component;

            this.c = CompressionUtility.Compress(component.gameObject, boxcollider.center);
            this.s = CompressionUtility.Compress(component.gameObject, boxcollider.size);
        }
        public float r;     // Radius

        /// <summary>
        /// Creates serializable SphereCollider from Unity component
        /// </summary>
        /// <param name="injector"></param>
        /// <param name="component"></param>
        public SphereColliderSerializable(Injector injector, Component component) : base(injector, component)
        {
            SphereCollider spherecollider = (SphereCollider)component;

            this.c = CompressionUtility.Compress(component.gameObject, spherecollider.center);
            this.r = CompressionUtility.Compress(component.gameObject, spherecollider.radius);
        }
Exemple #3
0
        public string t;        // Tags

        /// <summary>
        /// Creates serializable Transform from Unity component
        /// </summary>
        /// <param name="injector"></param>
        /// <param name="component"></param>
        public TransformSerializable(Injector injector, Component component) : base(injector, component)
        {
            Transform transform = (Transform)component;

            this.p = CompressionUtility.Compress(component.gameObject, transform.localPosition);
            this.s = CompressionUtility.Compress(component.gameObject, transform.localScale);
            this.r = transform.localRotation;
            this.t = transform.tag;
        }
Exemple #4
0
        public int[] t;         // Triangles

        /// <summary>
        /// Creates serializable Mesh from Unity resource
        /// </summary>
        /// <param name="injector"></param>
        /// <param name="resource"></param>
        public MeshSerializable(Injector injector, UnityEngine.Object resource) : base(injector, resource)
        {
            Mesh mesh = (Mesh)resource;

            this.v = CompressionUtility.Compress(this.injector.configuration.gameObject, mesh.vertices);
            this.n = CompressionUtility.Compress(this.injector.configuration.gameObject, mesh.normals);
            this.u = CompressionUtility.Compress(this.injector.configuration.gameObject, mesh.uv);
            this.t = mesh.triangles;
        }
        public float i, b;      // Intensity, BounceIntensity

        /// <summary>
        /// Creates serializable Light from Unity component
        /// </summary>
        /// <param name="injector"></param>
        /// <param name="component"></param>
        public LightSerializable(Injector injector, Component component) : base(injector, component)
        {
            Light light = (Light)component;

            this.t = light.type;
            this.c = CompressionUtility.Compress(component.gameObject, light.color);
            this.i = CompressionUtility.Compress(component.gameObject, light.intensity);
            this.b = CompressionUtility.Compress(component.gameObject, light.bounceIntensity);
        }
        public CameraClearFlags c;  // ClearFlags

        /// <summary>
        /// Creates serializable Camera from Unity component
        /// </summary>
        /// <param name="injector"></param>
        /// <param name="component"></param>
        public CameraSerializable(Injector injector, Component component) : base(injector, component)
        {
            Camera camera = (Camera)component;

            this.d = CompressionUtility.Compress(component.gameObject, camera.depth);
            this.n = CompressionUtility.Compress(component.gameObject, camera.nearClipPlane);
            this.f = CompressionUtility.Compress(component.gameObject, camera.farClipPlane);
            this.v = CompressionUtility.Compress(component.gameObject, camera.fieldOfView);
            this.b = CompressionUtility.Compress(component.gameObject, camera.backgroundColor);
            this.c = camera.clearFlags;
        }
        public Color[] p;   // Pixels

        /// <summary>
        /// Creates serializable Texture2D from Unity resource
        /// </summary>
        /// <param name="injector"></param>
        /// <param name="resource"></param>
        public Texture2DSerializable(Injector injector, UnityEngine.Object resource) : base(injector, resource)
        {
            Texture2D texture = (Texture2D)resource;

            this.w = texture.width;
            this.h = texture.height;

            try
            {
                this.p = CompressionUtility.Compress(this.injector.configuration.gameObject, texture.GetPixels());
            }
            catch (Exception) {}
        }
        public string[] k;      // Shader keywords

        /// <summary>
        /// Creates serializable Material from Unity resource
        /// </summary>
        /// <param name="injector"></param>
        /// <param name="resource"></param>
        public MaterialSerializable(Injector injector, UnityEngine.Object resource) : base(injector, resource)
        {
            Material material = (Material)resource;

            // Check if Color attribute exists
            if (material.HasProperty("_Color"))
            {
                this.c = material.color;
            }

            // Save the used Main Texture
            if (!material.HasProperty("_MainTex") || material.mainTexture == null)
            {
                this.t = "null";
            }
            else
            {
                // Get reference or unique name for the material resource
                material.mainTexture.name = injector.resourceStore.GetReferenceName(material.mainTexture);

                // Check if resource is already in ResourceStore
                if (!injector.resourceStore.Contains(material.mainTexture.name))
                {
                    injector.resourceStore.Add(material.mainTexture);
                }

                // Store the Texture name
                this.t = material.mainTexture.name;
            }

            // Check if TextureOffset attribute exists
            if (material.HasProperty("_TextureOffset"))
            {
                this.o = CompressionUtility.Compress(this.injector.configuration.gameObject, material.mainTextureOffset);
            }

            // Check if TextureScale exists
            if (material.HasProperty("_TextureScale"))
            {
                this.s = CompressionUtility.Compress(this.injector.configuration.gameObject, material.mainTextureScale);
            }

            this.n = material.shader.name;
            this.k = material.shaderKeywords;
        }
Exemple #9
0
        public Color cs, ce;        // StartColor, EndColor

        /// <summary>
        /// Creates serializable LineRenderer from Unity component
        /// </summary>
        /// <param name="injector"></param>
        /// <param name="component"></param>
        public LineRendererSerializable(Injector injector, Component component) : base(injector, component)
        {
            LineRenderer lineRenderer = (LineRenderer)component;

            // Save the used Shared Material
            if (lineRenderer.sharedMaterial == null)
            {
                this.m = "null";    // No Material set
            }
            else
            {
                // Get reference or unique name for the material resource
                lineRenderer.sharedMaterial.name = injector.resourceStore.GetReferenceName(lineRenderer.sharedMaterial);

                // Check if resource is already in ResourceStore
                if (!injector.resourceStore.Contains(lineRenderer.sharedMaterial.name))
                {
                    injector.resourceStore.Add(lineRenderer.sharedMaterial);
                }

                // Store the new Material name
                this.m = lineRenderer.sharedMaterial.name;
            }

            this.p = new Vector3[lineRenderer.positionCount];
            lineRenderer.GetPositions(this.p);

            this.p  = CompressionUtility.Compress(component.gameObject, this.p);
            this.w  = CompressionUtility.Compress(component.gameObject, lineRenderer.widthMultiplier);
            this.l  = lineRenderer.loop;
            this.ca = lineRenderer.numCapVertices;
            this.co = lineRenderer.numCornerVertices;
            this.t  = lineRenderer.textureMode;
            this.cs = CompressionUtility.Compress(component.gameObject, lineRenderer.startColor);
            this.ce = CompressionUtility.Compress(component.gameObject, lineRenderer.endColor);
        }