Example #1
0
    /// <summary>
    /// Fix the instantiated object (in some cases object have wrong position, rotation and scale).
    /// </summary>
    /// <param name="source">Source.</param>
    /// <param name="instance">Instance.</param>
    static public void FixInstantiated(ResNode source, GameObject instance)
    {
        var rectTransform = instance.transform as RectTransform;

        rectTransform.localPosition    = source.GetResPosition();
        rectTransform.localRotation    = source.GetResRotation();
        rectTransform.localScale       = source.GetResScale();
        rectTransform.anchoredPosition = source.GetResAnchoredPosition();
        rectTransform.sizeDelta        = source.GetResSizeDelta();
    }
Example #2
0
 public void OnLoadFinish(Transform CacheParent, ResNode effectPrefabRes)
 {
     AssetBundleManager.SaveMemory(effectPrefabRes);
     prefabResNode = effectPrefabRes;
     stage         = loadingStage.Stage_Finish;
     Init(CacheParent);
     foreach (LightingEffectResHandleInstance instance in m_AllInstanceNode)
     {
         LightingEffectResHandleInstance.FillInstance(currCahceTransform, this, instance);
         if (instance.isCached)
         {
             Quaternion qtn = Quaternion.identity;
             if (prefabResNode != null)
             {
                 qtn = prefabResNode.GetResRotation();
             }
             instance.OnCache(currCahceTransform, currCachePos, qtn);
         }
     }
 }
Example #3
0
    public void CacheInstance(LightingEffectResHandleInstance instance, Transform cacheParent, Vector3 cachePos)
    {
        if (null == instance)
        {
            return;
        }
        if (instance.isCached)
        {
            return;
        }
        currCahceTransform = cacheParent;
        currCachePos       = cachePos;
        Quaternion qtn = Quaternion.identity;

        if (prefabResNode != null)
        {
            qtn = prefabResNode.GetResRotation();
        }
        instance.OnCache(cacheParent, cachePos, qtn);
        m_CacheList.Enqueue(instance);
    }
Example #4
0
        /// <summary>
        /// 添加显示对象
        /// </summary>
        protected TComponent AddItemComponent(TItem newItem)
        {
            if (DefaultItemComponentRes == null)
            {
                return(null);
            }

            TComponent component;

            if (m_ItemComponentsCache.Count > 0)
            {
                component = m_ItemComponentsCache[m_ItemComponentsCache.Count - 1];
                m_ItemComponentsCache.RemoveAt(m_ItemComponentsCache.Count - 1);
            }
            else
            {
                component = DefaultItemComponentRes.InstanceMainRes <TComponent>();
                component.transform.SetParent(Container, false);
                Utilites.FixInstantiated(component.gameObject, DefaultItemComponentRes.GetResPosition(), DefaultItemComponentRes.GetResRotation(), DefaultItemComponentRes.GetResScale(), DefaultItemComponentRes.GetResAnchoredPosition(), DefaultItemComponentRes.GetResSizeDelta());
            }

            component.transform.SetAsLastSibling();
            component.gameObject.SetActive(true);
            m_ItemComponent.Add(component);

            newItem.ClearPopupMenuAction = OnClickAction;

            component.onEnter.AddListener(OnEnterAction);
            component.onExit.AddListener(OnExitAction);

            SetData(component, newItem);
            return(component);
        }