Exemplo n.º 1
0
        public void Internal_Apply()
        {
            m_rendererGroups.Clear();

            if (m_defaultMaterial == null)
            {
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                m_defaultMaterial = cube.GetComponent <Renderer>().sharedMaterial;
                DestroyImmediate(cube);
            }

            if (m_defaultParticle == null)
            {
                GameObject particles = new GameObject();
                particles.AddComponent <ParticleSystem>();
                m_defaultParticle = particles.GetComponent <Renderer>().sharedMaterial;
                DestroyImmediate(particles);
            }


            m_appliedRadius = FixBoundsRadius;
            Material[] materials;

            EditorUtility.DisplayProgressBar("Horizon Bend", "Searching for materials", 0.1f);
            HBUtils.Find(out materials, out m_rendererGroups, ExcludeGameObjects);
            if (!LockMaterials)
            {
                Materials = materials;
            }

            EditorUtility.DisplayProgressBar("Horizon Bend", "Replacing default materials", 0.2f);
            Materials = ReplaceUIMaterials(Materials, false, false);
            TryRelpaceDefaultMaterials();

            EditorUtility.DisplayProgressBar("Horizon Bend", "Replacing shaders", 0.3f);
            HBUtils.ReplaceShaders(Materials, HBShaders, false);

            EditorUtility.DisplayProgressBar("Horizon Bend", "Cleaning materials", 0.4f);
            Materials = HBUtils.Trim(Materials, m_rendererGroups, CustomShaders);
            CreateHBCameras();

            EditorUtility.DisplayProgressBar("Horizon Bend", "Fixing Bounds", 0.5f);
            CreateHBFixBounds();
            FixBounds();

            EditorUtility.DisplayProgressBar("Horizon Bend", "Completed", 1.0f);

            Transform fakeCameraTransform = null;
            bool      attachToCamera      = true;

            if (!AttachToCamera)
            {
                fakeCameraTransform = transform;
                attachToCamera      = false;
            }

            HBUtils.HorizonBend(new HBSettings(BendingMode, Curvature * CURVATURE_FACTOR, Flatten, HorizonXOffset, HorizonYOffset, HorizonZOffset, attachToCamera), fakeCameraTransform);
            HBUtils.HBMode(BendingMode);

            EditorUtility.ClearProgressBar();
        }