コード例 #1
0
ファイル: FollowSortingMap.cs プロジェクト: IJkeB/Ekster1
 public void UpdateSortingMap()
 {
     if (KickStarter.sceneSettings != null && KickStarter.sceneSettings.sortingMap != null)
     {
         sortingMap = KickStarter.sceneSettings.sortingMap;
         SetOriginalDepth();
         sortingMap.UpdateSimilarFollowers(this);
     }
     else
     {
         Debug.Log(this.gameObject.name + " cannot find sorting map to follow!");
     }
 }
コード例 #2
0
 /**
  * Tells the scene's SortingMap to account for this particular instance of FollowSortingMap.
  */
 public void UpdateSortingMap()
 {
     if (followSortingMap && KickStarter.sceneSettings != null && KickStarter.sceneSettings.sortingMap != null)
     {
         sortingMap = KickStarter.sceneSettings.sortingMap;
         SetOriginalDepth();
         sortingMap.UpdateSimilarFollowers(this);
     }
     else if (!followSortingMap && customSortingMap != null)
     {
         sortingMap = customSortingMap;
         SetOriginalDepth();
         sortingMap.UpdateSimilarFollowers(this);
     }
 }
コード例 #3
0
 /**
  * Tells the scene's SortingMap to account for this particular instance of FollowSortingMap.
  */
 public void UpdateSortingMap()
 {
     if (KickStarter.sceneSettings != null && KickStarter.sceneSettings.sortingMap != null)
     {
         sortingMap = KickStarter.sceneSettings.sortingMap;
         SetOriginalDepth ();
         sortingMap.UpdateSimilarFollowers (this);
     }
     else
     {
         Debug.Log (this.gameObject.name + " cannot find Sorting Map to follow!");
     }
 }
コード例 #4
0
        private void UpdateRenderers()
        {
                        #if UNITY_EDITOR
            if (!Application.isPlaying && livePreview)
            {
                UpdateSortingMap();
            }
                        #endif

            if (lockSorting || sortingMap == null || _renderer == null)
            {
                return;
            }

                        #if UNITY_EDITOR
            if (!Application.isPlaying && !livePreview && sortingMap != null && sortingMap.affectScale)
            {
                if (GetComponentInParent <Char>() != null && GetComponentInParent <Char>().spriteChild != null)
                {
                    GetComponentInParent <Char>().transform.localScale = Vector3.one;
                    return;
                }
            }
                        #endif

            sortingMap.UpdateSimilarFollowers(this);

            if (sortingMap.sortingAreas.Count > 0)
            {
                // Set initial value as below the last line
                if (sortingMap.mapType == SortingMapType.OrderInLayer)
                {
                    sortingOrder       = sortingMap.sortingAreas [sortingMap.sortingAreas.Count - 1].order;
                    sortingOrderString = sortingOrder.ToString();
                }
                else if (sortingMap.mapType == SortingMapType.SortingLayer)
                {
                    sortingLayer = sortingMap.sortingAreas [sortingMap.sortingAreas.Count - 1].layer;
                }

                for (int i = 0; i < sortingMap.sortingAreas.Count; i++)
                {
                    // Determine angle between SortingMap's normal and relative position - if <90, must be "behind" the plane
                    if (Vector3.Angle(sortingMap.transform.forward, sortingMap.GetAreaPosition(i) - transform.position) < 90f)
                    {
                        if (sortingMap.mapType == SortingMapType.OrderInLayer)
                        {
                            sortingOrder       = sortingMap.sortingAreas [i].order;
                            sortingOrderString = sortingOrder.ToString();
                        }
                        else if (sortingMap.mapType == SortingMapType.SortingLayer)
                        {
                            sortingLayer = sortingMap.sortingAreas [i].layer;
                        }
                        break;
                    }
                }
            }

                        #if UNITY_EDITOR
            if (!Application.isPlaying && livePreview && GetComponentInParent <Char>() != null && GetComponentInParent <Char>().spriteChild != null && sortingMap != null)
            {
                float localScale = GetLocalScale();
                if (localScale != 0f)
                {
                    GetComponentInParent <Char>().transform.localScale = Vector3.one * localScale;
                }
            }
                        #endif

            if (!affectChildren)
            {
                if (sortingMap.mapType == SortingMapType.OrderInLayer)
                {
                    _renderer.sortingOrder = sortingOrder;

                    if (offsetOriginal && offsets.Count > 0)
                    {
                        _renderer.sortingOrder += offsets[0];
                    }
                }
                else if (sortingMap.mapType == SortingMapType.SortingLayer)
                {
                    _renderer.sortingLayerName = sortingLayer;

                    if (offsetOriginal && offsets.Count > 0)
                    {
                        _renderer.sortingOrder = offsets[0];
                    }
                    else
                    {
                        _renderer.sortingOrder = 0;
                    }
                }

                return;
            }

            for (int i = 0; i < renderers.Length; i++)
            {
                if (sortingMap.mapType == SortingMapType.OrderInLayer)
                {
                    renderers[i].sortingOrder = sortingOrder;

                    if (offsetOriginal && offsets.Count > i)
                    {
                        renderers[i].sortingOrder += offsets[i];
                    }
                }
                else if (sortingMap.mapType == SortingMapType.SortingLayer)
                {
                    renderers[i].sortingLayerName = sortingLayer;

                    if (offsetOriginal && offsets.Count > i)
                    {
                        renderers[i].sortingOrder = offsets[i];
                    }
                    else
                    {
                        renderers[i].sortingOrder = 0;
                    }
                }
            }
        }