当前位置: 首页 > news >正文

自由学习记录(105)

这个函数的强大之处在于它能将单调递增的输入(如时间、距离)转化为周期性的震荡信号。

git reset 会导致 “丢失提交”

git reset 是修改当前分支指针位置的命令。比如你现在在第二次提交(记为 B),第一次提交是 A

  • 如果你执行 git reset --hard Amain 分支的指针会直接从 B 移到 A,此时 B 的提交记录在分支上 “消失” 了(但其实还存在于 Git 的本地数据库中,只是不被分支引用)。
  • 这时如果你没有记住 B 的 commit ID,就很难直接回到 B,看起来像是 “删了当前状态”。

  • git checkout 分支名 本质是 “让 HEAD(你的当前视角)指向该分支的指针”,从而切换到分支最新的状态。
  • git reset 之所以 “危险”,是因为它会直接移动分支指针的位置(比如把 main 指针从 B 拽回 A),导致分支默认状态变成了历史版本。

you must put the script file in a folder called “Editor”. Doing so prevents the script from being compiled into builds of the project, which would fail because we rely on several Editor-only APIs.

https://bronsonzgeb.com/index.php/2021/08/08/unity-editor-tools-the-place-objects-tool/

our barebones script starting point.

using System;
using UnityEngine;
using UnityEditor;
using UnityEditor.EditorTools;[EditorTool("Place Objects Tool")]
class PlaceObjectsTool : EditorTool
{[SerializeField] Texture2D _toolIcon; GUIContent _iconContent;void OnEnable(){_iconContent = new GUIContent(){image = _toolIcon,text = "Place Objects Tool",tooltip = "Place Objects Tool"};}public override GUIContent toolbarIcon{get { return _iconContent; }}public override void OnToolGUI(EditorWindow window){}
}

By the way, you can override toolbarIcon to give your tool an icon, but I won’t bother. Aside from that, the most important method is OnToolGUI. This method is essentially the EditorTool equivalent of Update in that it runs every time an editor window repaints.

Pay attention to the ToolManager.IsActiveTool, because the ToolManager is a valuable class when writing EditorTools. Here we’re using it to make sure our tool is the active tool. The reason we do this is that the editor could continue to call OnToolGUI on our tool after being initialized, even if it’s not currently the actively selected tool. 

The Handles API

This class contains many ways to draw debug tools in the Scene View, including shapes, lines, labels, and existing Unity tools like the Move, Scale and Rotate tools. I highly encourage you to check it out. 

//Draw a positional Handle.
Handles.DrawWireDisc(GetCurrentMousePositionInScene(), Vector3.up, 0.5f);

Here we pass in a position, normal and radius for wireframe disc

 a helper function that returns the position at which an object would spawn if we were to drag it into the scene

finds a surface, it’ll snap to it, and otherwise, it’ll choose a position in space.

Vector3 GetCurrentMousePositionInScene()
{Vector3 mousePosition = Event.current.mousePosition;var placeObject = HandleUtility.PlaceObject(mousePosition, out var newPosition, out var normal);return placeObject ? newPosition : HandleUtility.GUIPointToWorldRay(mousePosition).GetPoint(10);
}

Here we see another valuable class: HandleUtility

This class contains tons of utility functions that are the backbone of the built-in Scene View tools. 

using HandleUtility does the heavy lifting and keeps your tools consistent with the built-in ones.

The next step is to instantiate our selected object. There are a couple of cases to handle.

If the selected object is a prefab or belongs to a prefab, we’ll instantiate a linked prefab. Otherwise, we’ll instantiate a clone of the original game object. Append this code after the DrawWireDisc line.

直接 “复制粘贴” 场景中的预制体实例(类似普通对象的克隆),得到的新对象仍然会和原始预制体关联 —— 这其实和 “实例化一个新的关联预制体” 效果一致。但更规范的做法是通过 PrefabUtility.InstantiatePrefab() 显式创建关联实例,确保遵循预制体的设计逻辑

预制体的优雅封装

If the selected object is a prefab or belongs to a prefab, we’ll instantiate a linked prefab. Otherwise, we’ll instantiate a clone of the original game object.

PrefabUtility.IsPartOfAnyPrefab(newObject) 方法会沿着对象的层级关系,检查该对象及其所有父对象是否属于预制体实例。它的判断依据是 Unity 内部对预制体和实例之间的关联记录。

具体来说:

  • 如果传入的 GameObject 本身就是一个预制体实例(无论是完整的预制体实例,还是预制体嵌套结构中的一个子对象 ),该方法会返回 true
  • 只有当这个 GameObject 是完全独立创建在场景中,没有与任何预制体资源建立关联时,该方法才会返回 false

The main thing I want to introduce right now is the PrefabUtility class. This class contains a bunch of prefab-related utility functions for the editor. For example, you can use PrefabUtility.InstantiatePrefab to create a linked prefab in the scene instead of an unlinked game object clone.

(这里作者用了个有人味的玩笑,差点没缓过来...也许对他们来说这算不上?)

To be a good editor citizen, we notify the Undo system that we created a new object so Ctrl+Z will remove it.

Undo.RegisterCreatedObjectUndo(newObjectInstance, "Place new object");

https://www.youtube.com/watch?v=oIur9NATg-I

可以把webgpu当做webgl的子代,但是改进了很大

可以直接在browers里面运行compute shader,这一点改进很大

调用 Event.current.Use() 后,相当于告诉编辑器:“这个鼠标抬起事件我已经处理完了,你不用再执行默认的选中逻辑了”,从而避免冲突,确保你的自定义逻辑能正常生效。

For example, when we receive a MouseUp event, we want to place an object, but the Scene View selects the object under the mouse by default. So, by calling Use(), we tell the Scene View to ignore it instead of picking an object.

//Force the window to repaint.
window.Repaint();

The reason is that the Scene View doesn’t automatically update at a real-time frame rate, like 60fps. 

https://bronsonzgeb.com/index.php/2021/08/14/unity-editor-tools-the-place-objects-tool-part-2/

build your interface in an HTML-inspired UXML document

USS, or Unity Style Sheet.Then you can write a separate USS, or Unity Style Sheet, to describe the style properties. 

Then in your code, you load your UXML file and apply your USS to it. 

You could also do the whole thing in C#. (I’m lazy and not interested in messing around in three different files, so I chose the latter option. )

We’ll create the UI in OnActivated().Additionally, we’ll remove it in OnWillBeDeactivated() to ensure we don’t keep stacking UIs every time we select the tool.

public override void OnWillBeDeactivated()
{_toolRootElement?.RemoveFromHierarchy();
}

Contrary to a game that updates at a real-time frame rate (usually 30-60fps), the editor is idle and only updates when it reacts to an event.

Most of the events are input, but others include `Repaint` or `Layout`. You can see all the event types here.

first, we need to understand the notion of using an event.

When the editor receives an event, it passes it from window to window until one calls Use()

Once this happens, the event becomes Used, an EventType to signify that one of the windows processed it

Doing so is a bit tricky because, typically, the SceneView will process it first. Luckily, the SceneView has a callback called beforeSceneGui.

 So we’ll hook into that callback and capture the MouseDown event first.

add a custom context menu on right-click.

void ShowMenu()
{var picked = HandleUtility.PickGameObject(Event.current.mousePosition, true);if (!picked) return;var menu = new GenericMenu();menu.AddItem(new GUIContent($"Pick {picked.name}"), false, () => { _prefabObjectField.value = picked; });menu.ShowAsContext();
}

我的想法是找出更简便的控制办法,都是可以修改的范围

HandleUtility.PickGameObject(Event.current.mousePosition, true);

new GUIContent($"Pick {picked.name}"), false, () => { _prefabObjectField.value = picked; })

where do we call the ShowMenu() method?

Since the SceneView uses right-click to enter Fly mode, we have to catch the button press before the SceneView does. So we’ll add it to BeforeSceneGUI

我其实不会用ai,不够自由

https://www.youtube.com/watch?v=sOvi9Iu1Dq8

大模型是天花板,工程是如何调用这些大模型,我在工程上的管控太弱了,

和novelai一样的,我有着ai会有持续记忆的错觉,但这只是上层的工程区域做的一个gpt的封装,这甚至可能影响了我对ai的使用,所以我才会出现一下子感觉ai聪明,一下感觉ai笨的不行的原因,欠学习了

https://bronsonzgeb.com/index.php/2021/08/14/unity-editor-tools-the-place-objects-tool-part-2/

比如这样的需求,我要的是,如何让cluade可以做到言出法随,首先我肯定了解没有cluade的大模型的知识库多,所以我必然要做的就是把需求丢给cluade先去做,以及我要如何供着模型持续的保持清醒,这是我应该去锻炼的能力,而不是自我意识过强了

配置 Claude Code 使用 Kimi K2是可以做到的

https://www.youtube.com/watch?v=xoxfS8BM1x0

CLI 是什么意思?

CLI 是 Command-Line Interface(命令行界面) 的缩写。

  • 通俗理解:它就是那个你经常看到的黑色/白色的终端窗口,你通过输入文本命令来与计算机交互,而不是通过点击图形界面(GUI)。

  • 例子:在终端里输入 cd projects 进入项目文件夹,或输入 npm install 安装软件包,你就是在使用 CLI。

https://www.youtube.com/watch?v=TSycyPHse9o

博主表示在使用相同的kimi k2 模型的时候,codex是被博主额外夸的那个,两个工程都调用相同的模型,但给博主的反馈,他更喜欢codex

价格的比对,这是一种 “自助餐” 模式。你付一个固定的月费,然后在一定的“额度”内随意使用。

Claude Pro ($20/月)

  • 这个订阅同时用于 Claude 官网聊天和 Claude Code CLI。你的额度(聊天约 45次/5小时,Claude Code 约 10-40次/5小时)是两者共享的。

  • 特点:额度一旦用完,无论是网站还是 CLI 都无法使用了,直到额度重置。

“很多人会说VibeCoding会毁了软件,毁了软件工程”,哈哈哈

Vibe Coding 描述的是一种高度依赖 AI 编程助手(如 GitHub Copilot、Cursor、Claude Code 等)的编程风格。开发者不再需要精确地记忆语法、API 细节或深入设计架构,而是

通过用

自然语言描述一种“感觉”或“大概想法”(也就是所谓的 "vibe"),

然后让 AI 生成代码,开发者再基于“感觉”进行审核和微调。

一直用的都是gpt,最近不用了才发现国内的模型,豆包depsek都是不能设置全局记忆的,每次想要使用都需要自己重复的复述

MCP 是 Model Context Protocol

Anthropic 公司发起并开源的一个开放标准,旨在标准化 AI 模型(如 Claude)与外部工具、数据源和服务之间的连接方式

可以把它理解成 AI 世界的 “USB 标准” 或 “应用商店协议”

https://www.youtube.com/watch?v=yjBUnbRgiNs

cline是vscode的一个插件

Node.js的核心边界可以概括为:它是一个JavaScript运行时,专门处理I/O密集型的网络应用

// 这些都是稳定且被AI熟练运用的
const fs = require('fs'); // 文件系统
const path = require('path'); // 路径处理
const http = require('http'); // HTTP服务
const events = require('events'); // 事件机制
  • 文件操作 (fs模块) - 读、写、删除文件

  • 网络请求 (http/https模块) - 创建Web服务器

  • 操作系统交互 (os模块) - 获取系统信息

  • 进程管理 (child_process) - 执行外部命令

很可能是Node.js环境问题的情况:

  1. 模块导入失败

    bash

    Error: Cannot find module 'fs'
    • 说明Node.js核心模块都出问题了

  2. 语法解析错误

    bash

    SyntaxError: Unexpected token ...
    • 说明你的Node.js版本太老,不支持新语法

  3. 内存相关错误

    bash

    JavaScript heap out of memory
    • Node.js进程内存耗尽

  4. 安装全局工具失败

    bash

    npm ERR! code EACCES
    • 权限问题,与Node.js安装配置相关

❌ 很可能不是Node.js问题的情况:

  1. 第三方包报错

    bash

    Error: Cannot find module 'express'
    • 这是npm包管理问题,不是Node.js本身

  2. 业务逻辑错误

    • 代码逻辑bug、数据类型错误等

  3. 数据库连接问题

    • 网络、配置或数据库服务问题

  4. 前端资源加载失败

    • 静态文件路径或服务器配置问题

快速排查步骤

当遇到问题时,按这个顺序检查:

  1. 检查Node.js基础功能

    bash

    node -v
    npm -v
    node -e "console.log('Hello Node')"
  2. 检查核心模块

    javascript

    // test_core.js
    const fs = require('fs');
    const path = require('path');
    console.log('Core modules work!');
  3. 如果是安装问题

    • 检查环境变量 PATH 是否包含Node.js安装路径

    • 检查安装目录权限

https://nodejs.org/en/download

added 1 package in 17s 表示 @openai/codex 包已成功安装。

后面的 npm notice 只是提醒有新版 npm,可选择性更新,不影响使用。

验证是否安装成功

npm list -g @openai/codex

set HTTPS_PROXY=http://127.0.0.1:7897
set HTTP_PROXY=http://127.0.0.1:7897
claude

然后就是要跳到官网去了,结果发现你个穷鬼没有订阅pro 和max,很快的,就被赶出来了

但是知道这一点还是比较重要的,还挺有教育意义,,至少知道了这种agent的代理是以这种形式存在的,这样是对ai模型的额外一个 工程做法,这样对于我要写代码,vide code肯定是会更加能纠正我要怎么做

 “server” 确实是指网络服务器(比如用于部署网站、提供 API 服务的服务器)。而能让 JavaScript 运行在服务器上,在当年(2009 年 Node.js 诞生时)绝对是一件划时代的大事

Node.js 出现之前,JavaScript 几乎被 “绑定” 在浏览器里 —— 它是前端的专属语言,负责网页交互(比如点击按钮、动态加载内容),而服务器端开发则被 Java、Python、PHP、Ruby 等语言垄断。这种 “前端用 JS,后端用其他语言” 的割裂状态,带来了很多问题:

  • 前后端代码无法复用(比如验证用户输入的逻辑,前端写一套 JS,后端还得用 Java 再写一套);

而 Node.js 的出现打破了这种割裂:它基于 Chrome 的 V8 引擎(高性能 JS 解释器),让 JavaScript 第一次能脱离浏览器,直接运行在服务器操作系统(如 Linux、Windows)上

  1. 生态爆发:基于 Node.js,npm(JavaScript 包管理工具)迅速崛起,如今已成为全球最大的软件包仓库之一,开发者可以轻松复用数百万个现成工具,极大提升开发效率。

本质上是打破了前端与后端的语言壁垒,重塑了 Web 开发的模式

如今 Node.js 已经成为服务器端开发的主流技术之一(比如 Netflix、Uber、阿里巴巴等都在用),它的出现绝对配得上 “了不起” 这三个字。

图中占比最高的是 PHP,还有ASP.NET、Ruby、Java 等传统后端语言也有不少份额,但没有 Node.js 的身影。这说明在 2013 年,Node.js 虽然已经诞生(2009 年推出),但还没在 “服务器端语言选择” 的主流视野里占据显著位置,仍处于市场教育和生态建设的阶段。

https://www.youtube.com/watch?v=Azg_6jRwQ1U

这就是我很缺乏的能力了,我还认为自己停留在需要ai领导的阶段,没有自己主动产出什么的算法逻辑,所以我难以让ai产生有效的帮助,甚至说我缺乏了大量的知识,这些知识应该在plan阶段和ai聊清楚之后才真正开始自己的工程,这样会出现的问题都会是自己可控的

如果自己不知道该提供什么样的上下文,需要的就是先问ai自己需要提供什么上下文,列出清晰的todo,而不是说我不要这个不要那个,

这样的扭扭捏捏的做法要在plan阶段就让ai好好的调教一下自己,

  • 基准线意义:在GitHub生态中,1000 stars通常是一个项目从"个人玩具"过渡到"被社区认可"的初步标志。

  • 质量过滤:达到这个星数的项目,通常意味着:

    • 有基本文档

    • 经历过一定规模的用户测试

    • 有持续的维护迹象

  • 实践依据:很多开发者在使用"Awesome Lists"筛选项目时,常以1000 stars作为初步质量过滤器。

实际开发中的问题:

  • 领域差异:在新兴技术领域,一个500 stars的项目可能就是该领域的权威实现。

  • 时间因素:一个3年前达到1000 stars但已停止维护的项目,可能不如一个近期活跃的300 stars项目。

中文社区指标的设定逻辑

知乎:赞同≥200 + 评论≥20

  • 200赞在技术领域表示内容获得了显著认可

  • 20条评论意味着有实际的技术讨论,不是单方面输出

CSDN:阅读≥10000 或 点赞≥150

  • 10000阅读在CSDN技术深度文章中是较好的传播量

  • 150点赞作为替代指标,反映内容质量而非单纯流量

B站:播放≥20000 + 点赞≥500

  • 20000播放确保不是小众内容

  • 500点赞要求(2.5%点赞率)过滤掉标题党视频

https://www.youtube.com/watch?v=EiqvtENKc6Y

2023时的gpt,那是还没有agent在你和模型之前,所有的聊天都是两小无猜的

agent是后来的概念,而且最开始是围绕gpt的一个开源github项目,之后大公司发现这方面的确值得发展一下,所以自己也亲自做,就出现后来的各种~

ai模型还是照样不变的,自己用自己的讲话的那套逻辑,

如果agent想要ai返回需要的东西,就需要额外写prompt给ai模型,告诉ai模型它返回什么可以代表什么

大公司做的发展也是在这里,创建了function call的设置,方便了ai模型去正确的返回需要的答案,

此时还不是大公司下场去做codex和claude code这样的agent的时候

standardizes these causal human language descriptions into the format

因此也从系统提示词里分离出来了(但是本质上同源,只是增加了少量额外的处理)

但是各个大公司的function calling 格式各不相同,开源模型甚至有些不直接支持这种分离的做法,

以上都是agent 和ai在交互,但重点是agent 和写好的那些agent tool是如何交互的

事实上agent的数量 肯定会各不相同,有很多种,但是要调用的agent tools 会很多部分都是一样的,所以就出现 MCP这个东西

https://github.com/mcp?utm_source=vscode-website&utm_campaign=mcp-registry-server-launch-2025

vscode也是这样子的,一个server就是包裹了很多个tool

MCP is called a communication protocol to standardize  how agent and the tool services interact.

provide

MCP server

http://www.dtcms.com/a/446051.html

相关文章:

  • 聚类之KMeans
  • 汽车企业管理系统自己的网站怎么做关键词优化
  • 大模型落地的四大核心引擎:从技术突破到产业重构
  • find 命令使用介绍
  • 蓝桥杯Python备考全攻略:从入门到精通
  • 数据结构初阶(第六讲)单链表的功能实现
  • 做付费推广哪个网站好工作室网页模板
  • 合川网站建设天津自助建站
  • 元模型训练中平衡历史数据与实时市场变化的关系
  • 新手直播冷场难破?场景模拟工具解决测试与练手难题
  • 半球陀螺仪吸气剂热激活真空共晶炉
  • C++多态特性详解
  • 嵌入式第六十七天(SPI子系统架构)
  • MVC 视图
  • 公司网站运营方案东莞市建设工程检测中心网站
  • 从 C 到 C++:用 C 语言思维理解面向对象四大特性
  • SOFA 架构--02--核心中间件与工具
  • 如何利用淘宝建设网站挣钱在线注册个体工商户
  • 近世代数(抽象代数)详细笔记--域
  • 计算机网络第四章(5)——网络层《路由协议+路由协议》
  • KingbaseES在Alibaba Cloud Linux 3 的深度体验,从部署到性能实战
  • Oracle OCP认证考试题目详解082系列第50题
  • 网站建设流程百科wordpress响应式博客主题模版
  • Leetcode 3704. Count No-Zero Pairs That Sum to N
  • 微信小程序入门学习教程,从入门到精通,WXSS样式处理语法基础(9)
  • 网站开发技术 文库国外医院网站设计
  • 旅游网站建设的总结深圳市勘察设计
  • 企业网站建设费用的预算西安seo网站关键词
  • jvm垃圾回收算法和垃圾收集器(Serial、Parallel、Parnew、CMS)
  • R 绘图 - 条形图