public void Init()
 {
     Version  = 0;
     Category = EVCCategory.cgAbstract;
     Author   = "";
     Name     = "";
     Remarks  = "";
     xSize    = 0;
     ySize    = 0;
     zSize    = 0;
     IconTex  = new byte[0];
 }
Beispiel #2
0
        public void Init(
            Transform partRoot,
            Transform meshRoot,
            Transform decalRoot,
            Transform effectRoot,
            CreationData creationData)
        {
            _partRoot     = partRoot;
            _meshRoot     = meshRoot;
            _decalRoot    = decalRoot;
            _effectRoot   = effectRoot;
            _creationData = creationData;
            _creationID   = _creationData == null ? -1 : _creationData.m_ObjectID;

            _category = creationData.m_IsoData.m_HeadInfo.Category;

            // bounds
            CalcVoxelsBounds();
            ExtendPartsBounds();
            _bounds.Expand(0.05f);

            // 为机器人矫正 Pivot 并添加碰撞球
            if (_category == EVCCategory.cgRobot)
            {
                var root = transform.GetChild(0);
                root.SetParent(null, true);
                transform.position = boundsCenterInWorld;
                root.SetParent(transform, true);
                _bounds.center = Vector3.zero;

                float max = _bounds.size.x;
                if (_bounds.size.y > max)
                {
                    max = _bounds.size.y;
                }
                if (_bounds.size.z > max)
                {
                    max = _bounds.size.z;
                }

                _robotRadius = Mathf.Clamp(max * 0.5f - 0.08f, 0.1f, 0.3f);
                gameObject.AddComponent <SphereCollider>().radius = _robotRadius;
            }

            // 添加中心物体
            _centerObject = new GameObject("Center Object").transform;
            _centerObject.SetParent(transform, false);
            _centerObject.localPosition    = _bounds.center;
            _centerObject.gameObject.layer = VCConfig.s_ProductLayer;
        }