【Unity学习心得】如何制作俯视角射击游戏

news2024/9/20 5:54:15

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

文章目录

  • 前言
  • 一、导入素材
  • 二、制作流程
    • 1.制作地图
    • 2.实现人物动画和移动脚本
    • 3.制作单例模式和对象池
    • 4.制作手枪pistol和子弹bullet和子弹壳bulletShell
    • 5.制作散弹枪shotgun
  • 总结


前言

俯视角射击游戏类似元气骑士那种,懂的都懂好吧。

本节课我们将要实现:制作地图,实现人物动画和移动脚本,制作单例模式和对象池,制作手枪pistol和子弹bullet和子弹壳bulletShell,制作散弹枪shotgun。


一、导入素材

素材链接: 、

https://o-lobster.itch.io/simple-dungeon-crawler-16x16-pixel-pack https://humanisred.itch.io/weapons-and-bullets-pixel-art-asset

二、制作流程

1.制作地图

        还是要用我们的老朋友Tilemap来做这种像素地图:

可以看到,我们创建了三个层级的Grid,记得在Sorting Layer分别给它们排好选择顺序,除了Ground的那一层以外其它记得要给 tilemap Collider2D和Composite Collider2D,Rigibody2D记得设置成静态,这些后面都要用到的。 

2.实现人物动画和移动脚本

绘制完简单地图后,我们就要开始导入人物素材了。公式化三件套:Sprite Renderer,Rb2D设置为Kinematic被动检测碰撞,别忘了锁Z轴旋转,Animator自己根据素材创建Idle,Walk

接下来创建PlayerController.cs给Player对象 

代码如下:

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : SingletonMono<PlayerController>
{
    public float speed = 3f;
    public bool enabledInput = true;
    private Rigidbody2D rb2d;
    private Animator anim;
    private Camera mainCamera;
    private Vector2 input;
    private Vector2 mousePosition;

    private new void Awake()
    {
        rb2d = GetComponent<Rigidbody2D>();
        anim = GetComponent<Animator>();
	    mainCamera = Camera.main;
    }

    void Update()
    {
	if (enabledInput)
	{
        mousePosition = mainCamera.ScreenToWorldPoint(Input.mousePosition);
	    input.x = Input.GetAxisRaw("Horizontal");
	    input.y = Input.GetAxisRaw("Vertical");
	    rb2d.velocity = input.normalized * speed;

	    if(input != Vector2.zero)
	    {
		    anim.SetBool("isMoving", true);
	    }
	    else
	    {
		    anim.SetBool("isMoving", false);
	    }

	    if(mousePosition.x >= transform.position.x)
	    {
		transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, 0f));
	    }
	    else
	    {
		transform.rotation = Quaternion.Euler(new Vector3(0f, 180f, 0f));
	    }
	}
    }

}

这些大伙都应该懂了就获取X和Y上的Input,方向化后经典给rb2d设置velocity,然后根据鼠标位置判断玩家是否要沿Y轴翻转。

顺便给camera搞个cinemachine,让相机跟随玩家移动:

至此,我们实现了实现人物动画和移动脚本,接下来该开始制作单例模式和对象池模式了。

3.实现单例模式和对象池模式

单例模式大伙肯定也懂的,但这几天重温C#知识我突然就想用泛型<T>来做个泛型单例类,让所有MONOBehaviour的类都能继承:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SingletonMono<T> : MonoBehaviour where T : MonoBehaviour
{
    public static T _instance;
    public static T Instance
    {
	get
	{
	    if(_instance == null)
	    {
		GameObject gameObject = new GameObject();
		_instance = gameObject.AddComponent<T>();
		DontDestroyOnLoad(gameObject);
	    }
	    return _instance;
	}
    }

    public void Awake()
    {
	if (_instance == null)
	{
	    _instance = (gameObject as T);
	    DontDestroyOnLoad(gameObject);
	    return;
	}
	if (this != _instance)
	{
	    DestroyImmediate(gameObject);
	    return;
	}
    }
}

单例模式随便完成咯,接下来开始做对象池模式,很多人对对象池的编写还是比较陌生的,这里先写出主要思想:

在Unity中,实时创建(GameObject.Instantiate())和销毁游戏对象(GameObject.Destory ())会造成相当大的开销。

对于一些简单的,可以复用的物体,我们可以考虑用Enable/Disable来代替创建与销毁,这是因为Enable/Disable对性能的消耗搞更小。

我们可以采用对象池的思想实现这个功能。

所谓对象池,就是把所有相同的对象放在一个池子中,每当要使用到一个对象时,就从池子中找找看有没有之前创建过但现在空闲的物体可以直接拿来用,如果没有的话我们再创建物体并扔进池子里。

想要销毁一个物体,我们只需要标记其“空闲”即可,并不会直接销毁它。

 理解过后我们就可以编写一个脚本ObjectPool.cs

using System.Collections.Generic;
using UnityEngine;

public class ObjectPool : SingletonMono<ObjectPool>
{
    private Dictionary<string, Queue<GameObject>> objectPool = new Dictionary<string, Queue<GameObject>>();
    private GameObject pool;

    private new void Awake()
    {
        objectPool = new Dictionary<string, Queue<GameObject>>();
    }

//从对象池中获取对象
    public GameObject GetObject(GameObject prefab)
    {
        GameObject gameObject;
//先从name判断是否存在对应的键值或者队列的内容数量为0
        if (!objectPool.ContainsKey(prefab.name) || objectPool[prefab.name].Count == 0)
        {
//如果没有就新建从Object Pool -> Child Pool -> Prefab
            gameObject = GameObject.Instantiate(prefab);
            PushObject(gameObject);
            if (pool == null)
                pool = new GameObject("ObjectPool");
            GameObject childPool = GameObject.Find(prefab.name + "Pool");
            if (!childPool)
            {
                childPool = new GameObject(prefab.name + "Pool");
                childPool.transform.SetParent(pool.transform);
            }
            gameObject.transform.SetParent(childPool.transform);
        }
        gameObject = objectPool[prefab.name].Dequeue();
        gameObject.SetActive(true); //可视化
        return gameObject;
    }
//从对象池中取出对象
    public void PushObject(GameObject prefab)
    {
//要保证名字和objectPool的名字相等,因此我们要用空的字符串取代Unity新建游戏对象会有个"(Clone)"
        string name = prefab.name.Replace("(Clone)", string.Empty);
        if (!objectPool.ContainsKey(name))
            objectPool.Add(name, new Queue<GameObject>());
        objectPool[name].Enqueue(prefab); //创建该prefab名字的队列并让prefab入栈
        prefab.SetActive(false);//默认为不可见
    }
}

4.制作手枪pistol和子弹bullet和子弹壳bulletShell

终于来到了重点制作这些东西,当一些事物存在共性的时候我们会想使用抽象类来减少代码的耦合度,同样这些手枪火箭筒啥的都输入枪,我们可以创建一个Gun的Prefab,让这些枪都成为Gun的Varient。

其中muzzle是子弹发射位置,bulletshell是生成弹壳的位置。

我们Varient第一个目标是pistol手枪,如图我们给它sprite和animator

制作两个动画并连接即可

别忘了动态调整muzzle和bulletshell的位置

回到脚本当中,新建一个基类脚本Gun.cs,我们打算让所有的枪械类都继承这个脚本:

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Gun : MonoBehaviour
{
    public GameObject bulletPrefab;
    public GameObject bulletShellPrefab;
    public float interval = 0.5f;
    protected Animator animator;
    protected Camera mainCamera;
    protected Transform muzzleTrans;
    protected Transform bulletShellTrans;
    protected float flipY;
    protected Vector2 mousePos;
    protected Vector2 direction;
    private float timer;

    protected virtual void Start()
    {
	animator = GetComponent<Animator>();
	mainCamera = Camera.main;
	muzzleTrans = transform.Find("Muzzle"); ;
	bulletShellTrans = transform.Find("BulletShell");
	flipY = transform.localScale.y;
    }

    protected virtual void Update()
    {
	mousePos = mainCamera.ScreenToWorldPoint(Input.mousePosition);
	if(mousePos.x >= transform.position.x)
	{
	    transform.localScale = new Vector3(transform.localScale.x, flipY, 1);
	}
	else
	{
	    transform.localScale = new Vector3(transform.localScale.x, -flipY, 1);
	}
	Shoot();
    }

//控制枪械发射间隔
    protected virtual void Shoot()
    {
	direction = (mousePos - new Vector2(transform.position.x, transform.position.y)).normalized;
	transform.right = direction;
	if (timer != 0)
	{
	    timer -= Time.deltaTime;
	    if (timer < 0)
		timer = 0;
	}
	if (Input.GetKeyDown(KeyCode.Mouse0)) //按下鼠标左键
	{
	    if(timer == 0)
	    {
		timer = interval;
		Fire();
	    }
	}
    }
//控制开火
    protected virtual void Fire()
    {
	animator.SetTrigger("Shoot");
//生成子弹预制体
	GameObject bullet = ObjectPool.Instance.GetObject(bulletPrefab);
	bullet.transform.position = muzzleTrans.position;
//发射子弹角度偏差
	float angle = UnityEngine.Random.Range(-5f, 5f);
	bullet.GetComponent<Bullet>().SetSpeed(Quaternion.AngleAxis(angle , Vector3.forward) * direction);
//生成子弹壳预制体
	GameObject bulletShell = ObjectPool.Instance.GetObject(bulletShellPrefab);
	bulletShell.transform.position = bulletShellTrans.position;
	bulletShell.transform.rotation = bulletShellTrans.rotation;
    }
}

然后我们再给pistol添加同名脚本:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Pistol : Gun 
{
   
}

 写到这里我们注意到还要接着制作子弹Bullet和子弹壳BulletShell的预制体:

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bullet : MonoBehaviour
{
    public float bulletSpeed = 15f;
    public GameObject explosionPrefab;
    private Rigidbody2D rb2d;

    private void Awake()
    {
	rb2d = GetComponent<Rigidbody2D>();
    }
//在这里,我们用通过给子弹的rb2d设置速度velocity控制其移动速度和方向
    public void SetSpeed(Vector2 direction)
    {
	rb2d.velocity = bulletSpeed * direction;
    }
//最后当子弹碰到墙壁时对象池回收该对象并生成爆炸对象
    private void OnTriggerEnter2D(Collider2D other)
    {
	if (other.gameObject.layer == LayerMask.NameToLayer("Wall"))
	{
	    GameObject exp = ObjectPool.Instance.GetObject(explosionPrefab);
	    exp.transform.position = transform.position;
	    ObjectPool.Instance.PushObject(gameObject);
	}
    }

}

新建一个bullet的prefab

新建一个Explosion的prefab

 

给它制作一个爆炸的动画

在它的同名脚本中回收爆炸游戏对象:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Explosion : MonoBehaviour
{
    private Animator anim;
    private AnimatorStateInfo info;

    private void OnEnable()
    {
	anim = GetComponent<Animator>();
    }

    private void Update()
    {
	info = anim.GetCurrentAnimatorStateInfo(0);
	if(info.normalizedTime >= 1)
	{
	    ObjectPool.Instance.PushObject(gameObject);
	}
    }

}

 同样的操作也给bulletshell

同名脚本中:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BulletShell : MonoBehaviour
{
    public float speed;
    public float stopTime = 0.5f;
    public float fadeSpeed = 0.01f;
    private Rigidbody2D rb2d;
    private SpriteRenderer sprite;

    void Awake()
    {
        rb2d = GetComponent<Rigidbody2D>();
        sprite = GetComponent<SpriteRenderer>();
    }

    private void OnEnable()
    {
        float angel = Random.Range(-30f, 30f);
        rb2d.velocity = Quaternion.AngleAxis(angel, Vector3.forward) * Vector3.up * speed;

        sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.b, 1);
        rb2d.gravityScale = 3;

        StartCoroutine(Stop());
    }

    private IEnumerator Stop()
    {
        yield return new WaitForSeconds(stopTime);
        rb2d.velocity = Vector2.zero;
        rb2d.gravityScale = 0;
//通过spriterenderer的透明度来渐变颜色淡出直到0
        while (sprite.color.a > 0)
        {
            sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.g, sprite.color.a - fadeSpeed);
            yield return new WaitForFixedUpdate();
        }
//然后回收该游戏对象
        ObjectPool.Instance.PushObject(gameObject);
    }
}

5.制作散弹枪shotgun

有了前车之鉴,我们就可以照着葫芦画瓢。还是老配方先生成varient:

别忘了调整muzzle和bulletshell的位置。

创建同名脚本:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ShotGun : Gun
{
    public int bulletNum = 3;
    public float bulletAngle = 15f;
//我们只需要重写fire脚本
    protected override void Fire()
    {
	animator.SetTrigger("Shoot");
	int med = bulletNum / 2;
	for (int i = 0; i < bulletNum; i++)
	{
	    GameObject bullet = ObjectPool.Instance.GetObject(bulletPrefab);
	    bullet.transform.position = muzzleTrans.position;
	    if (bulletNum % 2 == 1)
	    {
//这段代码的意思是如果有奇数个bulletnum那给这个bulletshell设置的角度应该是bulletAngle * (i - //med)
		bullet.GetComponent<Bullet>().SetSpeed(Quaternion.AngleAxis(bulletAngle * (i - med), Vector3.forward) * direction);
	    }
	    else if(bulletNum % 2 == 0)
	    {
//这段代码的意思是如果有偶数个bulletnum那给这个bulletshell设置的角度应该是bulletAngle * (i - //med) + bulletAngle / 2f
		bullet.GetComponent<Bullet>().SetSpeed(Quaternion.AngleAxis(bulletAngle * (i - med) + bulletAngle / 2f, Vector3.forward) * direction);
	    }
	}
	GameObject shell = ObjectPool.Instance.GetObject(bulletShellPrefab);
	shell.transform.position = bulletShellTrans.transform.position;
	shell.transform.rotation = bulletShellTrans.transform.rotation;
    }
}

可以看到奇数个子弹:

偶数个子弹:你看是不是还要再加偏转角的一半即bulletAngle / 2

最后我们还想要根据键盘的Q和E键切换武器,回到playerController.cs当中:

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : SingletonMono<PlayerController>
{
    public float speed = 3f;
    public bool enabledInput = true;
    public GameObject[] guns;
    private int currentGun;
    private Rigidbody2D rb2d;
    private Animator anim;
    private Camera mainCamera;
    private Vector2 input;
    private Vector2 mousePosition;

    private new void Awake()
    {
        rb2d = GetComponent<Rigidbody2D>();
        anim = GetComponent<Animator>();
	mainCamera = Camera.main;
	guns[0].SetActive(true);
    }

    void Update()
    {
	if (enabledInput)
	{
	    SwitchGun();
	    mousePosition = mainCamera.ScreenToWorldPoint(Input.mousePosition);
	    input.x = Input.GetAxisRaw("Horizontal");
	    input.y = Input.GetAxisRaw("Vertical");
	    rb2d.velocity = input.normalized * speed;

	    if(input != Vector2.zero)
	    {
		anim.SetBool("isMoving", true);
	    }
	    else
	    {
		anim.SetBool("isMoving", false);
	    }

	    if(mousePosition.x >= transform.position.x)
	    {
		transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, 0f));
	    }
	    else
	    {
		transform.rotation = Quaternion.Euler(new Vector3(0f, 180f, 0f));
	    }
	}
    }
//切换武器
    private void SwitchGun()
    {
	if (Input.GetKeyDown(KeyCode.Q))
	{
	    guns[currentGun].SetActive(false);
	    if(--currentGun < 0)
	    {
		currentGun = guns.Length - 1;
	    }
	    guns[currentGun].SetActive(true);
	}
	else if (Input.GetKeyDown(KeyCode.E))
	{
	    guns[currentGun].SetActive(false);
	    if (++currentGun > guns.Length - 1)
	    {
		currentGun = 0;
	    }
	    guns[currentGun].SetActive(true);
	}
    }
}

给这两个武器添加上去(其它三个是下一期要讲的先别在意):


总结

最后的效果如图所示:

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2136384.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

AIDA64 Extreme(硬件检测工具)v7.20绿色不需要安装版,供大家学习研究参考

一款综合性的系统硬件检测工具,号称最权威的电脑硬件检测,监控与测试软件,这款专业的硬件检测大师也是每位高手玩家,菜鸟用户必备的硬件检测利器.AIDA64不仅提供诸如协助超频,硬件侦错,压力测试和传感器监测等多种功能,而且还可以对处理器,系统内存和磁盘驱动器性能进行全面评估…

家具行业短视频矩阵获客,轻松实现百万曝光!

当前家具行业的营销正面临一个新阶段&#xff0c;但同时也遭遇了增长的瓶颈&#xff0c;主要问题在于营销策略过于雷同&#xff0c;这导致产品难以在市场中获得足够关注&#xff0c;从而在品牌和消费者之间形成了隔阂。 同时在这样一个信息爆炸的时代&#xff0c;就算是最优秀…

pandas 生成excel多级表头

使用pandas导出excel 表格时类似这种 其中含有多级表头的情况也就是涉及到表头需要合并单元格&#xff08;横向及纵向&#xff09; 1、表头设置 columns [("xx公司路产月报表","序号","序号"),("xx公司路产月报表","单位"…

【树形dp】P2014 [CTSC1997] 选课 题解

题目描述 在大学里每个学生&#xff0c;为了达到一定的学分&#xff0c;必须从很多课程里选择一些课程来学习&#xff0c;在课程里有些课程必须在某些课程之前学习&#xff0c;如高等数学总是在其它课程之前学习。现在有 N ( 1 ≤ N ≤ 300 ) N(1\leq N \leq 300) N(1≤N≤30…

Leetcode 每日一题:Longest Increasing Path in a Matrix

写在前面&#xff1a; 今天我们继续看一道 图论和遍历 相关的题目。这道题目的背景是在一个矩阵当中找寻最长的递增数列长度。思路上非常好想&#xff0c;绝对和 DFS 相关&#xff0c;但是题目的优化要求非常高&#xff0c;对于语言和内存特性的考察特别丰富&#xff0c;如果是…

【Python报错已解决】ERROR: No matching distribution found for PIL

&#x1f3ac; 鸽芷咕&#xff1a;个人主页 &#x1f525; 个人专栏: 《C干货基地》《粉丝福利》 ⛺️生活的理想&#xff0c;就是为了理想的生活! 文章目录 前言一、问题描述1.1 报错示例1.2 报错分析1.3 解决思路 二、解决方法2.1 方法一&#xff1a;安装Pillow2.2 步骤二&a…

CentOS安装Hadoop系列

安装Hadoop 1、安装SDK 2、Wget下载安装包到指定目录 3、选择hadoop的配置模式&#xff0c;单机模式&#xff0c;伪集群模式&#xff0c;集群模式 1、查找APACHE下载官网&#xff0c;搜索hadoop,进入目录&#xff0c;找到common目录&#xff0c;下载对应版本 国内&#xff0c;…

uniapp 原生插件开发 UI

前言&#xff1a; 在集成某些特定 原生SDK的时候&#xff0c;它本身是带UI控件的。当我们使用 uniapp 开发app的时候实是 可以使使用 nvue 页面&#xff0c;以 weex 的方式嵌入原生的UI控件。 我这边的场景是 接入连连app的支付&#xff0c;它有个自己的密码键盘 控件是原生的页…

好用的电脑录屏软件有哪些?推荐4款专业工具。

不同系统的电脑上面带有的录屏功能不一样&#xff0c;比如win10上面有Xbox game bar,Mac系统则用的是QuickTime Player&#xff0c;或者是使用快捷键“CommandShift5”。但更方便的&#xff0c;我自己认为是使用一些专业的录屏软件&#xff0c;他门的录制模式多&#xff0c;兼容…

python将这多个sheet页的数据合并在一起

有如下数据&#xff0c;需要将excel多个sheet页中的数据&#xff0c;合并在一起。 数据样例&#xff1a;&#x1f447; import pandas as pd import os# 读Excel文件 file_path D:/project/Excelimport/簿4.xlsx# 创建空的DataFrame用于存储合并后的数据 all_data pd.Data…

软件项目管理

1. 软件项目管理概述 1.1 软件项目管理 软件项目管理的提出是在20世纪70年代中期&#xff0c;当时美国国防部专门研究了软件开发不能按时提交、预算超支和质量达不到用户要求的原因&#xff0c;发现70%的项目是因为管理不善引起的&#xff0c;而非技术原因。 软件项目管理和…

9月17–20日Sui新加坡参会指南,期待与您相聚

&#x1f4e7;叮&#xff0c;您有一份Sui新加坡参会指南待领取&#xff5e; 随着新加坡Token2049大会的临近&#xff0c;我们为即将前往新加坡参会的朋友们准备了一份指南&#xff0c;帮助你快速了解Sui团队的活动安排&#xff0c;并与Sui团队来个线下面对面的交流。 9月17日…

解码消费医疗机构:如何通过全场景AI运营实现营销破局?

在当今的医美市场中&#xff0c;“流量困境”已成为众多消费医疗机构面临的严峻挑战。传播日益碎片化&#xff0c;各大机构对流量争夺也愈演愈烈&#xff0c;不少机构面临着新客获取难、老客户留存转化难、运营成本高昂等困境。 那么&#xff0c;面对这一挑战&#xff0c;消费…

Leetcode面试经典150题-79.搜索单词

题目比较简单&#xff0c;回溯最基础的题&#xff0c;记得除非覆盖&#xff0c;否则一定要恢复现场就行 解法都在代码里&#xff0c;不懂就留言或者私信 class Solution {public boolean exist(char[][] board, String word) {int m board.length; int n board[0].length;i…

Baumer工业相机堡盟工业相机如何通过BGAPI SDK设置相机的图像剪切(ROI)功能(C语言)

Baumer工业相机堡盟工业相机如何通过BGAPI SDK设置相机的图像剪切&#xff08;ROI&#xff09;功能&#xff08;C语言&#xff09; Baumer工业相机Baumer工业相机的图像剪切&#xff08;ROI&#xff09;功能的技术背景CameraExplorer如何使用图像剪切&#xff08;ROI&#xff0…

公司搬迁至外地:选择新办资质还是迁移资质?

当企业面临搬迁&#xff0c;尤其是跨区域搬迁时&#xff0c;资质管理成为企业运营策略中的一个关键议题。企业需要在新办资质和迁移资质之间做出选择&#xff0c;这关系到企业的合规性、市场竞争力和业务连续性。本文将探讨这两种选择的考量因素&#xff0c;以及如何根据企业的…

cityengine修改纹理创建模型

数据准备 1、建筑shp面数据 2、安装好cityengine软件 3、Arcgis(非必要) 效果 1、新建工程 路径不要放C盘下 2、复制规则文件和纹理 安装软件后,这些素材在电脑上能找到,默认位置是:C:\Users{计算机名}\Documents\CityEngine\Default Workspace\ESRI.lib,如果找不到…

售后质保卡小程序系统开发制作方案

售后质保卡小程序系统作为一种数字化解决方案&#xff0c;通过微信小程序&#xff0c;为顾客提供更加便捷、高效、环保的质保服务体验。售后质保卡系统是集质保信息查询、报修申请、服务进度跟踪、顾客反馈等功能于一体的质保卡小程序。 目标顾客 1. 终端顾客&#xff1a;直接…

昇思MindSpore AI框架MindFormers实践3:ChatGLM3-6B对一段文字进行提取

MindSpore和MindFormers安装参见&#xff1a;昇思AI框架实践1:安装MindSpoe和MindFormers_miniconda 安装mindspore-CSDN博客 使用了MindSpore2.2和MindFormers1.0 支持的模型&#xff1a; KeyError: "model must be in odict_keys([gpt2, gpt2_lora, gpt2_xl, gpt2_xl…

Linux:开源世界的璀璨明珠

一、Linux 概述 Linux 是一种自由和开放源代码的类 Unix 操作系统&#xff0c;诞生于 1991 年&#xff0c;由芬兰大学生 Linus Torvalds 开发。它的起源离不开 Unix 家族&#xff0c;1969 年肯・汤普森设计了早期 Unix 的源头&#xff0c;到 1973 年丹尼斯・里奇等人以 C 语言…