Exemplo n.º 1
0
        public void Internal_Rollback(bool full)
        {
            DestroyHBCameras();

            FixBoundsRadius = 50.0f;
            Curvature       = 5.0f;
            Flatten         = 0.0f;
            HorizonXOffset  = 0.0f;
            HorizonYOffset  = 0.0f;
            HorizonZOffset  = 0.0f;

            AttachToCamera  = false;
            m_appliedRadius = 0.0f;

            Material[] materials = Materials;
            if (full)
            {
                HBUtils.Find(out Materials, out m_rendererGroups, new GameObject[0]);
            }
            else
            {
                HBUtils.Find(out Materials, out m_rendererGroups, ExcludeGameObjects);
            }
            HBUtils.HorizonBend(new HBSettings(BendingMode._HB_OFF));
            TryRollbackDefaultMaterial();
            ReplaceUIMaterials(materials, true, full);
            RendererGroupsIterate(renderer =>
            {
                if (renderer == null)
                {
                    return;
                }

                HBFixBounds fixBounds = renderer.GetComponent <HBFixBounds>();
                if (fixBounds != null)
                {
                    if (full || !fixBounds.Lock)
                    {
                        fixBounds.Rollback();
                        DestroyImmediate(fixBounds);
                    }
                }
            });

            HBUtils.ReplaceShaders(Materials, HBShaders, true);

            m_rendererGroups.Clear();

            if (LockMaterials)
            {
                Materials = materials;
            }
            else
            {
                Materials = new Material[0];
            }
        }
Exemplo n.º 2
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();
        }