Ejemplo n.º 1
0
    /// <summary>
    /// Add pooling to that type. Return value is true only when newly added.
    /// </summary>
    public int CreatePool(string sKey, GameObject pPoolingTarget, GameObject _parent, int nInitCreateCount = 1, int nExpandCreateCount = 1)
    {
        parent = _parent;

        int key = CRC32.GetHashForAnsi(sKey);

        GameObject go = null;

        pPoolingTarget.transform.SetParent(parent.transform);
        pPoolingTarget.SetActive(false);

        if (!poolObject.TryGetValue(key, out go))
        {
            poolObject.Add(key, pPoolingTarget);
        }
        else
        {
            poolObject[key] = pPoolingTarget;
        }

        CObjectPool <GameObject> objectPool = null;

        if (!poolList.TryGetValue(key, out objectPool))
        {
            objectPool = new CObjectPool <GameObject>()
            {
                InitializeCreateCount = nInitCreateCount,
                ExpandCreateCount     = nExpandCreateCount,

                OnObjectDestroy = (GameObject v) =>
                {
                    GameObject.Destroy(v);
                },
                OnTake = (GameObject v) =>
                {
                },
                OnRelease = (GameObject v) =>
                {
                    if (v)
                    {
                        v.transform.SetParent(parent.transform);
                        v.SetActive(false);
                    }
                },
                OnCreate = () =>
                {
                    var data = EAFrameUtil.AddChild(parent, poolObject[key]);
                    return(data);
                }
            };

            poolList.Add(key, objectPool);
        }

        return(key);
    }
Ejemplo n.º 2
0
    void CreateSceneLogic()
    {
        EASceneLogic sm = null;

        Type t = null;

        _sceneInfo.TryGetValue(controllerClass, out t);

        sm = (EASceneLogic)EAFrameUtil.AddChild(EAMainFrame.instance.gameObject, t, "gameLogic") as EASceneLogic;

        Debug.Log("EA SceneConfig.CreateSceneLogic - call CreateSceneLogic sm is " + ((sm == null) ? "null" : "valid") + " controller class :" + controllerClass + " frameCount:" + Time.frameCount);
    }
Ejemplo n.º 3
0
    /// <summary>
    ///  skeleton setting
    /// </summary>
    public void SetSkeleton()
    {
        if (transformList.Count <= 0)
        {
            EACharacterInfo characterInfo = transform.GetComponent <EACharacterInfo>();

            if (characterInfo != null)
            {
                Transform[] transforms = characterInfo.Bones;
                string[]    BoneNames  = characterInfo.BoneNames;

                for (int i = 0; i < transforms.Length; ++i)
                {
                    int key = CRC32.GetHashForAnsi(BoneNames[i]);
                    transformList.Add(key, transforms[i]);
                }
            }
            else
            {
                Debug.LogError("SetSkeleton - EACharacterInfo is null : " + gameObject.name);

                Transform[] transforms = transform.GetComponentsInChildren <Transform>();

                for (int i = 0; i < transforms.Length; ++i)
                {
                    int key = CRC32.GetHashForAnsi(transforms[i].name);

                    Transform value = null;

                    if (!transformList.TryGetValue(key, out value))
                    {
                        transformList.Add(key, transforms[i]);
                    }
                }
            }
        }

        Transform mesh = GetTransform("mesh");

        if (mesh != null)
        {
            mesh.transform.parent = null;
            GameObject.Destroy(mesh.gameObject);
        }

        GameObject _mesh = EAFrameUtil.AddChild(gameObject, "mesh");

        if (_mesh != null)
        {
            AddTransform("mesh", _mesh.transform);
        }
    }
Ejemplo n.º 4
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="parts_basic"></param>
    /// <returns></returns>
    private GameObject Attach(SkinnedMeshRenderer parts_basic)
    {
        Transform mesh = GetTransform("mesh");

        GameObject go = EAFrameUtil.AddChild(mesh.gameObject, parts_basic.gameObject);

        if (go != null)
        {
            go.SetActive(true);

            SkinnedMeshRenderer parts = go.GetComponent <SkinnedMeshRenderer>();

            if (parts != null)
            {
                EASKinInfo skinInfo = parts.GetComponent <EASKinInfo>();

                Debug.Assert(skinInfo != null, "SkinInfo not valid : " + parts_basic.gameObject.name);

                if (skinInfo != null)
                {
                    Transform[] bones = new Transform[skinInfo.BoneNames.Length];

                    for (int i = 0; i < skinInfo.BoneNames.Length; i++)
                    {
                        bones[i] = GetTransform(skinInfo.BoneNames[i]);
                    }

                    parts.rootBone = GetTransform(skinInfo.RootboneName);
                    parts.bones    = bones;
                    Bounds b = parts.localBounds;
                    b.center          = Vector3.zero;
                    parts.localBounds = b;
                }
            }
        }

        return(go);
    }