コード例 #1
0
        public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label = null)
        {
            AssetPointer <Texture2D> pointer = (AssetPointer <Texture2D>)property.Value;
            Texture2D asset     = pointer.GetAsset();
            Texture2D lastAsset = asset;

            asset = EditorGUI.ObjectField(position, property.GUIContent, lastAsset, typeof(Texture2D), false) as Texture2D;

            if (lastAsset == asset)
            {
                return;
            }

            if (asset == null || !InResourcePath(asset))
            {
                property.Value = new AssetPointer <Texture2D>();
                return;
            }
            string path = AssetDatabase.GetAssetPath(asset.GetInstanceID());

            property.Value = new AssetPointer <Texture2D>(path);
        }
コード例 #2
0
        public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label)
        {
            AssetPointer <Chassis> pointer   = (AssetPointer <Chassis>)property.Value;
            GameObject             asset     = pointer.GetAsset()?.gameObject;
            GameObject             lastAsset = asset;

            asset = EditorGUI.ObjectField(position, property.GUIContent, lastAsset, typeof(GameObject), false) as GameObject;

            if (lastAsset == asset)
            {
                return;
            }

            if (asset == null || !InResourcePath(asset) || !HasComponent(asset))
            {
                property.Value = new AssetPointer <Chassis>();
                return;
            }
            string path = AssetDatabase.GetAssetPath(asset.GetInstanceID());

            property.Value = new AssetPointer <Chassis>(path);
        }