Beispiel #1
0
    private void OnUseComponentProcess(int oldComponentIndex, UsedComponent usedComponent)
    {
        if (oldComponentIndex >= 0)
        {
            UsedComponent oldComponent = usedComponents[oldComponentIndex];
            oldComponent.Release();
            usedComponents[oldComponentIndex] = usedComponent;
        }

        // Mount mesh.
        if (usedComponent.CommponentCfg == null)
        {
            return;
        }

        if (usedComponent.CommponentCfg.Part.assembleType == AvatarAssetConfig._AssembleType.Mount)
        {
            // Use and save this new usedComponent.
            usedComponent.rootObject = UseMountComponent(usedComponent.CommponentCfg.asset, usedComponent.mountBone, usedComponent.CommponentCfg.Part.mountMarker);

            //// Set usedComponent color with avt color
            //usedComponent.mat.color = avatar.materialColor;
        }
        // Attach mesh.
        else if (usedComponent.CommponentCfg.Part.assembleType == AvatarAssetConfig._AssembleType.Skin)
        {
            // Use and save this new usedComponent.
            usedComponent.rootObject = UseBaseComponent(usedComponent.CommponentCfg.asset);
//			usedComponent.rootObject = UseSkinComponent(usedComponent.CommponentCfg.asset);
        }
    }
Beispiel #2
0
    public UsedComponent GetUsedComponent(int componentId)
    {
        int componentIndex = FindComponent(componentId);

        if (componentIndex >= 0)
        {
            UsedComponent usedComponent = usedComponents[componentIndex];
            return(usedComponent);
        }

        return(null);
    }
Beispiel #3
0
    public void SetActiveComponent(int componentId, bool active)
    {
        int componentIndex = FindComponent(componentId);

        if (componentIndex >= 0)
        {
            UsedComponent usedComponent = usedComponents[componentIndex];

            if (usedComponent.rootObject != null)
            {
                usedComponent.rootObject.SetActive(active);
            }
        }
    }
Beispiel #4
0
    public string GetComponentAssetPath(int componentId)
    {
        int componentIndex = FindComponent(componentId);

        if (componentIndex >= 0)
        {
            UsedComponent usedComponent = usedComponents[componentIndex];
            if (usedComponent.CommponentCfg != null)
            {
                return(PathUtility.Combine(ConfigDatabase.DefaultCfg.AvatarAssetConfig.assetPath, usedComponent.CommponentCfg.asset));
            }
        }

        return("");
    }
Beispiel #5
0
    public bool UseComponent(int componentId, string mountBone)
    {
        // Check if the style is for the avatar
        if (AvatarAssetConfig.IsCommomComponent(componentId) == false && AvatarAssetConfig.ComponentIdToAvatarTypeId(componentId) != avatar.AvatarTypeId)
        {
#if ENABLE_AVATAR_COMPONENT_LOG
            Debug.LogWarning(System.String.Format("This usedComponent {0:X} is not for this avatar {1:X}", componentId, avatar.AvatarTypeId));
#endif
            return(false);
        }

        // Create used usedComponent.
        UsedComponent usdCmp = new UsedComponent(componentId, mountBone);

//		// If avatar object not created, delay use.
//		if (avatar.AvatarObject == null)
//		{
//			dlyUsedList.Add(usdCmp);
//			return true;
//		}

        // Process old usedComponent.
        int oldComponentIdx = FindComponentWithSamePartTypeId(usdCmp.componentId, mountBone);

        if (oldComponentIdx >= 0)
        {
            UsedComponent oldCmp = usedComponents[oldComponentIdx];

            // The same usedComponent and style, do nothing.
            if (oldCmp.componentId == usdCmp.componentId)
            {
                return(true);
            }

            // Need not add the usedCmp here, it will replace the oldComponent after download.
        }
        else
        {
            // Add this usedComponent.
            usedComponents.Add(usdCmp);
        }

        // Download usedComponent and style.
        OnUseComponentProcess(oldComponentIdx, usdCmp);

        return(true);
    }
Beispiel #6
0
    public GameObject CloneComponent(int componentId)
    {
        int componentIndex = FindComponent(componentId);

        if (componentIndex >= 0)
        {
            UsedComponent usedComponent = usedComponents[componentIndex];

            if (usedComponent.rootObject != null)
            {
                GameObject obj = (GameObject)GameObject.Instantiate(usedComponent.rootObject);
                return(obj);
            }
        }

        return(null);
    }
Beispiel #7
0
    public GameObject ExtractComponent(int componentId)
    {
        int componentIndex = FindComponent(componentId);

        if (componentIndex >= 0)
        {
            UsedComponent usedComponent = usedComponents[componentIndex];

            if (usedComponent.rootObject != null)
            {
                GameObject obj = usedComponent.rootObject;
                obj.transform.parent = null;

                usedComponent.rootObject = null;

                return(obj);
            }
        }

        return(null);
    }