示例#1
0
        /// <summary>Applies the given particle system gameObject to this particles tag.
        /// Essentially makes it get laid out by the UI.
        /// Usually you'd use the path=".." attribute (or anElement["path"]) rather than calling this directly.</summary>
        public void ApplySystem(GameObject gameObject)
        {
            if (BatchProperty == null)
            {
                // Create the BP now:
                BatchProperty = new DisplayableProperty(RenderData);

                // It's always isolated (as the particle system is on a layer of it's own):
                BatchProperty.Isolate();
            }

            // Get the material:
            ParticleSystemRenderer partRenderer = gameObject.GetComponent <ParticleSystemRenderer>();

            if (partRenderer == null)
            {
                Debug.LogError("The gameObject '" + gameObject.name + "' wasn't a particle system on a <particles> tag (it has no ParticleSystemRenderer)");
                return;
            }

            // Apply:
            Particles = gameObject;

            // Apply material:
            ParticleMaterial = partRenderer.material;

            // Get the transform:
            Transform transform = gameObject.transform;

            ParticleTransform = transform;

            // PowerUI layer, unless we're on a WorldUI:
            if (htmlDocument.worldUI == null)
            {
                // Update the layer:
                gameObject.layer = UI.Layer;
            }

            // parent to GUINode:
            transform.parent = rootGameObject.transform;

            // Zero local position:
            ParticleTransform.localPosition = Vector3.zero;

            // Update scale/rotation:
            Relocate();

            // Request a layout:
            htmlDocument.RequestLayout();
        }