Пример #1
0
        public override void OnInitialize()
        {
            if (!generatedDataContainer)
            {
                generatedDataContainer = ChiselGeneratedComponentManager.FindContainerGameObject(this);
                if (generatedDataContainer != null)
                {
                    generatedDataTransform = generatedDataContainer.transform;
                }
            }

            colliderSettings = new ChiselGeneratedColliderSettings();
            colliderSettings.Reset();

            renderSettings = new ChiselGeneratedRenderSettings();
            renderSettings.Reset();

#if UNITY_EDITOR
            UnityEditor.UnwrapParam defaults;
            UnityEditor.UnwrapParam.SetDefaults(out defaults);
            uvGenerationSettings.angleError       = defaults.angleError;
            uvGenerationSettings.areaError        = defaults.areaError;
            uvGenerationSettings.hardAngle        = defaults.hardAngle;
            uvGenerationSettings.packMarginPixels = defaults.packMargin * 256;
#endif

            initialized = true;
        }
Пример #2
0
        public override void OnInitialize()
        {
            base.OnInitialize();
            if (generated != null &&
                !generated.generatedDataContainer)
            {
                generated.Destroy();
            }

            if (generated == null)
            {
                generated = ChiselGeneratedObjects.Create(gameObject);
            }

            if (colliderSettings == null)
            {
                colliderSettings = new ChiselGeneratedColliderSettings();
                colliderSettings.Reset();
            }

            if (renderSettings == null)
            {
                renderSettings = new ChiselGeneratedRenderSettings();
                renderSettings.Reset();
            }

#if UNITY_EDITOR
            if (uvGenerationSettings == null)
            {
                uvGenerationSettings = new SerializableUnwrapParam();
                UnityEditor.UnwrapParam defaults;
                UnityEditor.UnwrapParam.SetDefaults(out defaults);
                uvGenerationSettings.angleError       = defaults.angleError;
                uvGenerationSettings.areaError        = defaults.areaError;
                uvGenerationSettings.hardAngle        = defaults.hardAngle;
                uvGenerationSettings.packMarginPixels = defaults.packMargin * 256;
            }
#else
            if (generated != null && generated.meshRenderers != null)
            {
                foreach (var renderable in generated.renderables)
                {
                    renderable.meshRenderer.forceRenderingOff = true;
                    renderable.meshRenderer.enabled           = renderable.sharedMesh.vertexCount == 0;
                }
            }
#endif

            // Legacy solution
            if (!IsDefaultModel &&
                name == ChiselGeneratedComponentManager.kGeneratedDefaultModelName)
            {
                IsDefaultModel = true;
            }

            initialized = true;
        }