Is there a way to see Unity's implementation

I am overriding the Rule tile using Custom rule tile. Before overriding, I want to see what it exactly does by seeing its implementation. However there seems to be no implementation? Is there a way to see the implementation? I am trying to override StartUp Method in this case but I need help in general. Thanks

The class I want to override:

#region Assembly Unity.2D.Tilemap.Extras, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// C:\Users\Asus\Documents\GitHub\islandDefender\Library\ScriptAssemblies\Unity.2D.Tilemap.Extras.dll
#endregion

using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine.Serialization;
using UnityEngine.Tilemaps;

namespace UnityEngine
{
    [HelpURL("https://docs.unity3d.com/Packages/com.unity.2d.tilemap.extras@latest/index.html?subfolder=/manual/RuleTile.html")]
    public class RuleTile : TileBase
    {
        public Sprite m_DefaultSprite;
        public GameObject m_DefaultGameObject;
        public Tile.ColliderType m_DefaultColliderType;
        [HideInInspector]
        public List<TilingRule> m_TilingRules;

        public RuleTile();

        public HashSet<Vector3Int> neighborPositions { get; }
        public int m_RotationCount { get; }
        public virtual Type m_NeighborType { get; }
        public virtual int m_RotationAngle { get; }

        public static float GetPerlinValue(Vector3Int position, float scale, float offset);
        public virtual Matrix4x4 ApplyRandomTransform(TilingRuleOutput.Transform type, Matrix4x4 original, float perlinScale, Vector3Int position);
        public FieldInfo[] GetCustomFields(bool isOverrideInstance);
        public virtual Vector3Int GetMirroredPosition(Vector3Int position, bool mirrorX, bool mirrorY);
        public virtual Vector3Int GetOffsetPosition(Vector3Int position, Vector3Int offset);
        public virtual Vector3Int GetOffsetPositionReverse(Vector3Int position, Vector3Int offset);
        public virtual Vector3Int GetRotatedPosition(Vector3Int position, int rotation);
        public override bool GetTileAnimationData(Vector3Int position, ITilemap tilemap, ref TileAnimationData tileAnimationData);
        public override void GetTileData(Vector3Int position, ITilemap tilemap, ref TileData tileData);
        public override void RefreshTile(Vector3Int position, ITilemap tilemap);
        public virtual bool RuleMatch(int neighbor, TileBase other);
        public bool RuleMatches(TilingRule rule, Vector3Int position, ITilemap tilemap, int angle, bool mirrorX = false);
        public virtual bool RuleMatches(TilingRule rule, Vector3Int position, ITilemap tilemap, ref Matrix4x4 transform);
        public bool RuleMatches(TilingRule rule, Vector3Int position, ITilemap tilemap, bool mirrorX, bool mirrorY);
        public override bool StartUp(Vector3Int position, ITilemap tilemap, GameObject instantiatedGameObject);
        public void UpdateNeighborPositions();

        public class TilingRule : TilingRuleOutput
        {
            public List<int> m_Neighbors;
            public List<Vector3Int> m_NeighborPositions;
            public Transform m_RuleTransform;

            public TilingRule();

            public void ApplyNeighbors(Dictionary<Vector3Int, int> dict);
            public TilingRule Clone();
            public BoundsInt GetBounds();
            public Dictionary<Vector3Int, int> GetNeighbors();
        }
        public class TilingRuleOutput
        {
            public int m_Id;
            public Sprite[] m_Sprites;
            public GameObject m_GameObject;
            [FormerlySerializedAs("m_AnimationSpeed")]
            public float m_MinAnimationSpeed;
            [FormerlySerializedAs("m_AnimationSpeed")]
            public float m_MaxAnimationSpeed;
            public float m_PerlinScale;
            public OutputSprite m_Output;
            public Tile.ColliderType m_ColliderType;
            public Transform m_RandomTransform;

            public TilingRuleOutput();

            public enum Transform
            {
                Fixed = 0,
                Rotated = 1,
                MirrorX = 2,
                MirrorY = 3,
                MirrorXY = 4,
                RotatedMirror = 5
            }
            public enum OutputSprite
            {
                Single = 0,
                Random = 1,
                Animation = 2
            }

            public class Neighbor
            {
                public const int This = 1;
                public const int NotThis = 2;

                public Neighbor();
            }
        }
        public class DontOverride : Attribute
        {
            public DontOverride();
        }
    }
}

You should check Library/PackageCache for the package, there you should find the source code. You can also embed the package, then the source should show up in your editor.

com.unity.2d.tilemap.extras specifically can also be found on GitHub.

2 Likes

______thank you