更新保存和打包

This commit is contained in:
ayuan9957 2026-03-18 18:34:44 +08:00
parent 07359082cd
commit 776d3c01aa
806 changed files with 123538 additions and 851 deletions

BIN
321/321.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@ -0,0 +1,102 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
跳跃脚本 - 让对象产生上下跳跃效果
"""
from core.script_system import ScriptBase
import math
class BouncerScript(ScriptBase):
"""跳跃脚本类"""
def __init__(self):
super().__init__()
# 跳跃参数
self.jump_height = 2.0 # 跳跃高度
self.jump_speed = 3.0 # 跳跃速度 (跳跃/秒)
self.bounce_type = "sine" # 跳跃类型: "sine", "abs_sine", "square"
# 内部变量
self.time_accumulator = 0.0 # 时间累积器
self.original_y = None # 原始Y位置
self.is_bouncing = True # 是否正在跳跃
self.bounce_direction = 1 # 跳跃方向
def start(self):
"""脚本开始时调用"""
self.log("跳跃脚本启动!")
self.log(f"跳跃参数: 高度={self.jump_height}, 速度={self.jump_speed}, 类型={self.bounce_type}")
# 记录原始Y位置
self.original_y = self.gameObject.getZ() # Z轴是高度
self.log(f"原始高度: {self.original_y}")
def update(self, dt):
"""每帧更新"""
if not self.is_bouncing:
return
# 累积时间
self.time_accumulator += dt * self.bounce_direction
# 根据类型计算跳跃高度
if self.bounce_type == "sine":
# 标准正弦波跳跃
height_offset = math.sin(self.time_accumulator * self.jump_speed * 2 * math.pi) * self.jump_height
elif self.bounce_type == "abs_sine":
# 绝对值正弦波(始终向上)
height_offset = abs(math.sin(self.time_accumulator * self.jump_speed * 2 * math.pi)) * self.jump_height
elif self.bounce_type == "square":
# 方波跳跃(突然跳起落下)
sine_val = math.sin(self.time_accumulator * self.jump_speed * 2 * math.pi)
height_offset = self.jump_height if sine_val > 0 else 0
else:
height_offset = 0
# 应用跳跃
current_pos = self.gameObject.getPos()
new_z = self.original_y + height_offset
self.gameObject.setPos(current_pos.getX(), current_pos.getY(), new_z)
def set_bounce_parameters(self, height=None, speed=None, bounce_type=None):
"""设置跳跃参数"""
if height is not None:
self.jump_height = height
if speed is not None:
self.jump_speed = speed
if bounce_type is not None and bounce_type in ["sine", "abs_sine", "square"]:
self.bounce_type = bounce_type
self.log(f"跳跃参数更新: 高度={self.jump_height}, 速度={self.jump_speed}, 类型={self.bounce_type}")
def toggle_bouncing(self):
"""切换跳跃状态"""
self.is_bouncing = not self.is_bouncing
status = "恢复" if self.is_bouncing else "暂停"
self.log(f"跳跃{status}")
def reverse_direction(self):
"""反转跳跃方向"""
self.bounce_direction *= -1
direction = "正向" if self.bounce_direction > 0 else "反向"
self.log(f"跳跃方向改为{direction}")
def reset_position(self):
"""重置到原始高度"""
if self.original_y is not None:
current_pos = self.gameObject.getPos()
self.gameObject.setPos(current_pos.getX(), current_pos.getY(), self.original_y)
self.time_accumulator = 0.0
self.log("位置已重置到原始高度")
def jump_once(self):
"""执行一次跳跃"""
self.time_accumulator = 0.0
self.log("执行单次跳跃")
def on_destroy(self):
"""脚本销毁时调用"""
self.log("跳跃脚本停止")

View File

@ -0,0 +1,8 @@
{
"guid": "814e7a11c43748a2990ed7f007a2eef6",
"asset_type": "script",
"source_hash": "252f45192f9eb8a0c109d5d9fff1c9d04760f42a332e65bbe8114afa12925507",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

View File

@ -0,0 +1,160 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
颜色变化脚本 - 让对象颜色产生循环变化
"""
from core.script_system import ScriptBase
from panda3d.core import Vec4
import math
class ColorChangerScript(ScriptBase):
"""颜色变化脚本类"""
def __init__(self):
super().__init__()
# 颜色参数
self.color_speed = 1.0 # 颜色变化速度 (周期/秒)
self.color_mode = "rainbow" # 颜色模式: "rainbow", "pulse", "fade", "strobe"
self.base_color = Vec4(1, 1, 1, 1) # 基础颜色
self.intensity = 1.0 # 颜色强度
# 内部变量
self.time_accumulator = 0.0 # 时间累积器
self.original_color = None # 原始颜色
self.is_changing = True # 是否正在变化
self.strobe_state = False # 闪烁状态
def start(self):
"""脚本开始时调用"""
self.log("颜色变化脚本启动!")
self.log(f"颜色参数: 速度={self.color_speed}, 模式={self.color_mode}, 强度={self.intensity}")
# 记录原始颜色
self.original_color = self.gameObject.getColor()
self.log(f"原始颜色: {self.original_color}")
def update(self, dt):
"""每帧更新"""
if not self.is_changing:
return
# 累积时间
self.time_accumulator += dt
# 根据模式计算新颜色
if self.color_mode == "rainbow":
new_color = self._calculate_rainbow_color()
elif self.color_mode == "pulse":
new_color = self._calculate_pulse_color()
elif self.color_mode == "fade":
new_color = self._calculate_fade_color()
elif self.color_mode == "strobe":
new_color = self._calculate_strobe_color()
else:
new_color = self.base_color
# 应用颜色
self.gameObject.setColor(new_color)
def _calculate_rainbow_color(self):
"""计算彩虹颜色"""
# 使用HSV到RGB的转换创建彩虹效果
hue = (self.time_accumulator * self.color_speed) % 1.0
# 简单的HSV到RGB转换
i = int(hue * 6.0)
f = (hue * 6.0) - i
p = 0.0
q = 1.0 - f
t = f
if i % 6 == 0:
r, g, b = 1.0, t, p
elif i % 6 == 1:
r, g, b = q, 1.0, p
elif i % 6 == 2:
r, g, b = p, 1.0, t
elif i % 6 == 3:
r, g, b = p, q, 1.0
elif i % 6 == 4:
r, g, b = t, p, 1.0
else:
r, g, b = 1.0, p, q
return Vec4(r * self.intensity, g * self.intensity, b * self.intensity, 1.0)
def _calculate_pulse_color(self):
"""计算脉冲颜色"""
pulse = (math.sin(self.time_accumulator * self.color_speed * 2 * math.pi) + 1.0) / 2.0
multiplier = pulse * self.intensity
return Vec4(
self.base_color.getX() * multiplier,
self.base_color.getY() * multiplier,
self.base_color.getZ() * multiplier,
self.base_color.getW()
)
def _calculate_fade_color(self):
"""计算淡入淡出颜色"""
fade = (math.sin(self.time_accumulator * self.color_speed * 2 * math.pi) + 1.0) / 2.0
alpha = fade * self.intensity
return Vec4(
self.base_color.getX(),
self.base_color.getY(),
self.base_color.getZ(),
alpha
)
def _calculate_strobe_color(self):
"""计算闪烁颜色"""
# 根据时间间隔切换状态
interval = 1.0 / (self.color_speed * 2) # 闪烁间隔
if int(self.time_accumulator / interval) % 2 == 0:
return Vec4(
self.base_color.getX() * self.intensity,
self.base_color.getY() * self.intensity,
self.base_color.getZ() * self.intensity,
self.base_color.getW()
)
else:
return Vec4(0.1, 0.1, 0.1, self.base_color.getW()) # 暗色状态
def set_color_parameters(self, speed=None, mode=None, base_color=None, intensity=None):
"""设置颜色参数"""
if speed is not None:
self.color_speed = speed
if mode is not None and mode in ["rainbow", "pulse", "fade", "strobe"]:
self.color_mode = mode
if base_color is not None:
self.base_color = base_color
if intensity is not None:
self.intensity = intensity
self.log(f"颜色参数更新: 速度={self.color_speed}, 模式={self.color_mode}, 强度={self.intensity}")
def toggle_color_change(self):
"""切换颜色变化状态"""
self.is_changing = not self.is_changing
status = "恢复" if self.is_changing else "暂停"
self.log(f"颜色变化{status}")
def reset_color(self):
"""重置到原始颜色"""
if self.original_color:
self.gameObject.setColor(self.original_color)
self.time_accumulator = 0.0
self.log("颜色已重置到原始值")
def set_solid_color(self, r=1.0, g=1.0, b=1.0, a=1.0):
"""设置固定颜色"""
color = Vec4(r, g, b, a)
self.gameObject.setColor(color)
self.base_color = color
self.log(f"设置固定颜色: {color}")
def on_destroy(self):
"""脚本销毁时调用"""
self.log("颜色变化脚本停止")

View File

@ -0,0 +1,8 @@
{
"guid": "d1abb9e4bdfe4c679b8cc1880b5c53e1",
"asset_type": "script",
"source_hash": "36865decfa06b8b3b7949914bcfce691f3f1441de890564f51b522e274b8105b",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

View File

@ -0,0 +1,39 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
复合动画脚本 - 结合旋转和跳跃效果
"""
from core.script_system import ScriptBase
import math
class ComboAnimatorScript(ScriptBase):
def __init__(self):
super().__init__()
self.time = 0.0
self.original_pos = None
self.is_active = True
def start(self):
self.log("复合动画脚本启动!")
self.original_pos = self.gameObject.getPos()
def update(self, dt):
if not self.is_active:
return
self.time += dt
# 旋转效果
current_hpr = self.gameObject.getHpr()
new_h = current_hpr.getX() + 45.0 * dt
self.gameObject.setHpr(new_h, current_hpr.getY(), current_hpr.getZ())
# 跳跃效果
if self.original_pos:
bounce_offset = abs(math.sin(self.time * 3.0)) * 1.0
self.gameObject.setZ(self.original_pos.getZ() + bounce_offset)
def on_destroy(self):
self.log("复合动画脚本停止")

View File

@ -0,0 +1,8 @@
{
"guid": "2487836243524f74aa3e75fd70211bda",
"asset_type": "script",
"source_hash": "d792886dd2b9a362b6df71a64cc76b9b88d06eb29521ac54bc57bbb5562377c7",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

View File

@ -0,0 +1,69 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
跟随脚本 - 让对象跟随指定的目标对象
"""
from core.script_system import ScriptBase
from panda3d.core import Vec3
class FollowerScript(ScriptBase):
"""跟随脚本类"""
def __init__(self):
super().__init__()
self.target = None # 跟随目标
self.follow_speed = 5.0 # 跟随速度
self.follow_distance = 2.0 # 跟随距离
self.is_following = True # 是否正在跟随
def start(self):
"""脚本开始时调用"""
self.log("跟随脚本启动!")
self.log(f"跟随参数: 速度={self.follow_speed}, 距离={self.follow_distance}")
def update(self, dt):
"""每帧更新"""
if not self.is_following or self.target is None:
return
target_pos = self.target.getPos()
current_pos = self.gameObject.getPos()
# 计算目标方向
direction = target_pos - current_pos
distance = direction.length()
# 如果距离大于跟随距离,则移动
if distance > self.follow_distance:
if distance > 0:
direction.normalize()
# 计算目标位置(保持跟随距离)
target_follow_pos = target_pos - direction * self.follow_distance
# 平滑移动到目标位置
move_direction = target_follow_pos - current_pos
move_distance = move_direction.length()
if move_distance > 0:
move_direction.normalize()
move_amount = min(self.follow_speed * dt, move_distance)
new_pos = current_pos + move_direction * move_amount
self.gameObject.setPos(new_pos)
# 朝向目标
self.gameObject.lookAt(target_pos)
def set_target(self, target):
"""设置跟随目标"""
self.target = target
if target:
self.log(f"设置跟随目标: {target.getName()}")
else:
self.log("清除跟随目标")
def on_destroy(self):
"""脚本销毁时调用"""
self.log("跟随脚本停止")

View File

@ -0,0 +1,8 @@
{
"guid": "005dde4c3ead4ad2984fc1a672b0b505",
"asset_type": "script",
"source_hash": "12a8766c1dea5defd0e0e12960a8355715239174bf5f384d08f1326122c9abf5",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

View File

@ -0,0 +1,91 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
移动脚本 - 让对象在指定方向上来回移动
"""
from core.script_system import ScriptBase
import math
class MoverScript(ScriptBase):
"""移动脚本类"""
def __init__(self):
super().__init__()
# 移动参数
self.move_distance = 5.0 # 移动距离
self.move_speed = 2.0 # 移动速度 (单位/秒)
self.move_axis = "x" # 移动轴: "x", "y", "z"
# 内部变量
self.start_position = None # 起始位置
self.current_direction = 1 # 当前移动方向: 1或-1
self.current_distance = 0.0 # 当前移动距离
self.is_moving = True # 是否正在移动
def start(self):
"""脚本开始时调用"""
self.log("移动脚本启动!")
self.log(f"移动参数: 距离={self.move_distance}, 速度={self.move_speed}, 轴={self.move_axis}")
# 记录起始位置
self.start_position = self.gameObject.getPos()
self.log(f"起始位置: {self.start_position}")
def update(self, dt):
"""每帧更新"""
if not self.is_moving or self.start_position is None:
return
# 计算移动增量
move_delta = self.move_speed * dt * self.current_direction
self.current_distance += abs(move_delta)
# 检查是否需要改变方向
if self.current_distance >= self.move_distance:
self.current_direction *= -1
self.current_distance = 0.0
# 应用移动
current_pos = self.gameObject.getPos()
new_pos = [current_pos.getX(), current_pos.getY(), current_pos.getZ()]
if self.move_axis == "x":
new_pos[0] += move_delta
elif self.move_axis == "y":
new_pos[1] += move_delta
elif self.move_axis == "z":
new_pos[2] += move_delta
self.gameObject.setPos(new_pos[0], new_pos[1], new_pos[2])
def set_move_parameters(self, distance=None, speed=None, axis=None):
"""设置移动参数"""
if distance is not None:
self.move_distance = distance
if speed is not None:
self.move_speed = speed
if axis is not None and axis in ["x", "y", "z"]:
self.move_axis = axis
self.log(f"移动参数更新: 距离={self.move_distance}, 速度={self.move_speed}, 轴={self.move_axis}")
def toggle_movement(self):
"""切换移动状态"""
self.is_moving = not self.is_moving
status = "恢复" if self.is_moving else "暂停"
self.log(f"移动{status}")
def reset_position(self):
"""重置到起始位置"""
if self.start_position:
self.gameObject.setPos(self.start_position)
self.current_distance = 0.0
self.current_direction = 1
self.log("位置已重置到起始点")
def on_destroy(self):
"""脚本销毁时调用"""
self.log("移动脚本停止")

View File

@ -0,0 +1,8 @@
{
"guid": "5a1581070fd144ad80f0ace97085bb10",
"asset_type": "script",
"source_hash": "fe2a9e902716c7c36208c9f75a68e11efa12778d2d3559ff15d164c3c7495669",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

133
321/Assets/Scripts/R_P.py Normal file
View File

@ -0,0 +1,133 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
旋转脚本 - 让对象持续旋转
"""
from core.script_system import ScriptBase
class RotatorScript(ScriptBase):
"""旋转脚本类"""
def __init__(self):
super().__init__()
self.rotation_speed_y = 30.0 # Y轴旋转速度 (度/秒)
self.max_angle = 30.0 # 最大旋转角度(相对于初始角度)
self.direction = 1
self.current_offset = 0.0 # 当前相对于初始角度的偏移
self.initial_angle = None # 模型的初始角度
self.is_rotating = True # 是否正在旋转
def start(self):
"""脚本开始时调用"""
self.log("旋转脚本启动!")
self.log(f"旋转速度: {self.rotation_speed_y}度/秒")
self.log(f"最大旋转角度: ±{self.max_angle}")
# 记录模型的初始角度
if self.gameObject:
initial_hpr = self.gameObject.getHpr()
self.initial_angle = initial_hpr.getZ() # 记录Z轴的初始角度
self.log(f"模型初始角度: {self.initial_angle}")
self.log(f"旋转范围: {self.initial_angle - self.max_angle}° 到 {self.initial_angle + self.max_angle}°")
else:
self.log("⚠️ 无法获取游戏对象使用默认初始角度0")
self.initial_angle = 0.0
def update(self, dt):
"""每帧更新"""
if not self.is_rotating or self.initial_angle is None:
return
# 计算角度变化量
delta_angle = self.rotation_speed_y * dt * self.direction
self.current_offset += delta_angle
# 如果超出角度范围,则反向并限制在边界
if self.current_offset > self.max_angle:
self.current_offset = self.max_angle
self.direction *= -1
elif self.current_offset < -self.max_angle:
self.current_offset = -self.max_angle
self.direction *= -1
# 计算最终角度(初始角度 + 偏移量)
final_angle = self.initial_angle + self.current_offset
# 设置新的旋转只改变Z轴保持其他不变
current_hpr = self.gameObject.getHpr()
self.gameObject.setHpr(current_hpr.getX(), final_angle, current_hpr.getZ())
# if not self.is_rotating:
# return
#
# # 获取当前旋转并应用增量
# current_hpr = self.gameObject.getHpr()
# new_r = current_hpr.getZ() + self.rotation_speed_y * dt
# self.gameObject.setHpr(current_hpr.getX(), current_hpr.getY(), new_r)
def on_destroy(self):
"""脚本销毁时调用"""
self.log("旋转脚本停止")
# ==================== 控制方法 ====================
def set_max_angle(self, new_max_angle):
"""
设置新的最大旋转角度
Args:
new_max_angle: 新的最大角度值
"""
self.max_angle = new_max_angle
self.log(f"最大旋转角度已设置为: ±{self.max_angle}")
if self.initial_angle is not None:
self.log(f"新的旋转范围: {self.initial_angle - self.max_angle}° 到 {self.initial_angle + self.max_angle}°")
def set_rotation_speed(self, new_speed):
"""
设置新的旋转速度
Args:
new_speed: 新的旋转速度/
"""
self.rotation_speed_y = new_speed
self.log(f"旋转速度已设置为: {self.rotation_speed_y}度/秒")
def pause_rotation(self):
"""暂停旋转"""
self.is_rotating = False
self.log("旋转已暂停")
def resume_rotation(self):
"""恢复旋转"""
self.is_rotating = True
self.log("旋转已恢复")
def reset_to_initial_angle(self):
"""重置到初始角度"""
if self.initial_angle is not None and self.gameObject:
current_hpr = self.gameObject.getHpr()
self.gameObject.setHpr(current_hpr.getX(), current_hpr.getY(), self.initial_angle)
self.current_offset = 0.0
self.direction = 1
self.log(f"已重置到初始角度: {self.initial_angle}")
def get_current_info(self):
"""获取当前旋转信息"""
if self.gameObject and self.initial_angle is not None:
current_hpr = self.gameObject.getHpr()
current_angle = current_hpr.getZ()
self.log("=== 当前旋转信息 ===")
self.log(f"初始角度: {self.initial_angle}")
self.log(f"当前角度: {current_angle}")
self.log(f"偏移量: {self.current_offset}")
self.log(f"最大角度: ±{self.max_angle}")
self.log(f"旋转速度: {self.rotation_speed_y}度/秒")
self.log(f"旋转方向: {'正向' if self.direction > 0 else '反向'}")
self.log(f"旋转状态: {'运行中' if self.is_rotating else '已暂停'}")
self.log("=== 信息结束 ===")
else:
self.log("无法获取旋转信息")

View File

@ -0,0 +1,8 @@
{
"guid": "7be42ab6b97d4bd28574a39e0785903d",
"asset_type": "script",
"source_hash": "0e0927b903628d9141c2a16ab5427cd18738fd1c9b09016ce1573fbbc37f9c73",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

133
321/Assets/Scripts/R_R.py Normal file
View File

@ -0,0 +1,133 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
旋转脚本 - 让对象持续旋转
"""
from core.script_system import ScriptBase
class RotatorScript(ScriptBase):
"""旋转脚本类"""
def __init__(self):
super().__init__()
self.rotation_speed_y = 30.0 # Y轴旋转速度 (度/秒)
self.max_angle = 30.0 # 最大旋转角度(相对于初始角度)
self.direction = 1
self.current_offset = 0.0 # 当前相对于初始角度的偏移
self.initial_angle = None # 模型的初始角度
self.is_rotating = True # 是否正在旋转
def start(self):
"""脚本开始时调用"""
self.log("旋转脚本启动!")
self.log(f"旋转速度: {self.rotation_speed_y}度/秒")
self.log(f"最大旋转角度: ±{self.max_angle}")
# 记录模型的初始角度
if self.gameObject:
initial_hpr = self.gameObject.getHpr()
self.initial_angle = initial_hpr.getZ() # 记录Z轴的初始角度
self.log(f"模型初始角度: {self.initial_angle}")
self.log(f"旋转范围: {self.initial_angle - self.max_angle}° 到 {self.initial_angle + self.max_angle}°")
else:
self.log("⚠️ 无法获取游戏对象使用默认初始角度0")
self.initial_angle = 0.0
def update(self, dt):
"""每帧更新"""
if not self.is_rotating or self.initial_angle is None:
return
# 计算角度变化量
delta_angle = self.rotation_speed_y * dt * self.direction
self.current_offset += delta_angle
# 如果超出角度范围,则反向并限制在边界
if self.current_offset > self.max_angle:
self.current_offset = self.max_angle
self.direction *= -1
elif self.current_offset < -self.max_angle:
self.current_offset = -self.max_angle
self.direction *= -1
# 计算最终角度(初始角度 + 偏移量)
final_angle = self.initial_angle + self.current_offset
# 设置新的旋转只改变Z轴保持其他不变
current_hpr = self.gameObject.getHpr()
self.gameObject.setHpr(current_hpr.getX(), current_hpr.getY(), final_angle)
# if not self.is_rotating:
# return
#
# # 获取当前旋转并应用增量
# current_hpr = self.gameObject.getHpr()
# new_r = current_hpr.getZ() + self.rotation_speed_y * dt
# self.gameObject.setHpr(current_hpr.getX(), current_hpr.getY(), new_r)
def on_destroy(self):
"""脚本销毁时调用"""
self.log("旋转脚本停止")
# ==================== 控制方法 ====================
def set_max_angle(self, new_max_angle):
"""
设置新的最大旋转角度
Args:
new_max_angle: 新的最大角度值
"""
self.max_angle = new_max_angle
self.log(f"最大旋转角度已设置为: ±{self.max_angle}")
if self.initial_angle is not None:
self.log(f"新的旋转范围: {self.initial_angle - self.max_angle}° 到 {self.initial_angle + self.max_angle}°")
def set_rotation_speed(self, new_speed):
"""
设置新的旋转速度
Args:
new_speed: 新的旋转速度/
"""
self.rotation_speed_y = new_speed
self.log(f"旋转速度已设置为: {self.rotation_speed_y}度/秒")
def pause_rotation(self):
"""暂停旋转"""
self.is_rotating = False
self.log("旋转已暂停")
def resume_rotation(self):
"""恢复旋转"""
self.is_rotating = True
self.log("旋转已恢复")
def reset_to_initial_angle(self):
"""重置到初始角度"""
if self.initial_angle is not None and self.gameObject:
current_hpr = self.gameObject.getHpr()
self.gameObject.setHpr(current_hpr.getX(), current_hpr.getY(), self.initial_angle)
self.current_offset = 0.0
self.direction = 1
self.log(f"已重置到初始角度: {self.initial_angle}")
def get_current_info(self):
"""获取当前旋转信息"""
if self.gameObject and self.initial_angle is not None:
current_hpr = self.gameObject.getHpr()
current_angle = current_hpr.getZ()
self.log("=== 当前旋转信息 ===")
self.log(f"初始角度: {self.initial_angle}")
self.log(f"当前角度: {current_angle}")
self.log(f"偏移量: {self.current_offset}")
self.log(f"最大角度: ±{self.max_angle}")
self.log(f"旋转速度: {self.rotation_speed_y}度/秒")
self.log(f"旋转方向: {'正向' if self.direction > 0 else '反向'}")
self.log(f"旋转状态: {'运行中' if self.is_rotating else '已暂停'}")
self.log("=== 信息结束 ===")
else:
self.log("无法获取旋转信息")

View File

@ -0,0 +1,8 @@
{
"guid": "b7a4ec6b2c1644f0bc7f60ea2dda8f58",
"asset_type": "script",
"source_hash": "77af84fe420c8380d3501e3b5e56b06983496900604dbcde61a586eff7b90a28",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

View File

@ -0,0 +1,215 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
旋转脚本 - 让对象持续旋转
"""
from core.script_system import ScriptBase
class RotatorScript(ScriptBase):
"""旋转脚本类"""
def __init__(self):
super().__init__()
self.rotation_speed_y = 30.0 # Y轴旋转速度 (度/秒)
self.max_angle = 30.0 # 最大旋转角度(相对于初始角度)
self.direction = 1
self.current_offset = 0.0 # 当前相对于初始角度的偏移
self.initial_angle = None # 模型的初始角度
self.is_rotating = True # 是否正在旋转
# 机器人式停顿参数
self.pause_duration = 0.5 # 停顿时间(秒)
self.current_pause_time = 0.0 # 当前停顿计时
self.is_paused = False # 是否正在停顿
self.robot_mode = True # 是否启用机器人模式
def start(self):
"""脚本开始时调用"""
self.log("机器人旋转脚本启动!")
self.log(f"旋转速度: {self.rotation_speed_y}度/秒")
self.log(f"最大旋转角度: ±{self.max_angle}")
self.log(f"机器人模式: {'开启' if self.robot_mode else '关闭'}")
if self.robot_mode:
self.log(f"停顿时间: {self.pause_duration}")
# 记录模型的初始角度
if self.gameObject:
initial_hpr = self.gameObject.getHpr()
self.initial_angle = initial_hpr.getY() # 记录Y轴的初始角度Pitch
self.log(f"模型初始角度: {self.initial_angle}")
self.log(f"旋转范围: {self.initial_angle - self.max_angle}° 到 {self.initial_angle + self.max_angle}°")
else:
self.log("⚠️ 无法获取游戏对象使用默认初始角度0")
self.initial_angle = 0.0
def update(self, dt):
"""每帧更新 - 机器人式旋转"""
if not self.is_rotating or self.initial_angle is None:
return
# 如果正在停顿中
if self.is_paused:
self.current_pause_time += dt
if self.current_pause_time >= self.pause_duration:
# 停顿结束,继续旋转
self.is_paused = False
self.current_pause_time = 0.0
self.log(f"停顿结束,继续旋转,方向: {'正向' if self.direction > 0 else '反向'}")
return
# 计算角度变化量
delta_angle = self.rotation_speed_y * dt * self.direction
self.current_offset += delta_angle
# 检查是否到达边界
reached_boundary = False
if self.current_offset > self.max_angle:
self.current_offset = self.max_angle
self.direction *= -1
reached_boundary = True
elif self.current_offset < -self.max_angle:
self.current_offset = -self.max_angle
self.direction *= -1
reached_boundary = True
# 如果到达边界且启用机器人模式,开始停顿
if reached_boundary and self.robot_mode:
self.is_paused = True
self.current_pause_time = 0.0
self.log(f"到达边界 ({self.current_offset}°),开始停顿 {self.pause_duration}")
# 计算最终角度(初始角度 + 偏移量)
final_angle = self.initial_angle + self.current_offset
# 设置新的旋转只改变Y轴保持其他不变
current_hpr = self.gameObject.getHpr()
self.gameObject.setHpr(final_angle, current_hpr.getY(), current_hpr.getZ())
# if not self.is_rotating:
# return
#
# # 获取当前旋转并应用增量
# current_hpr = self.gameObject.getHpr()
# new_r = current_hpr.getZ() + self.rotation_speed_y * dt
# self.gameObject.setHpr(current_hpr.getX(), current_hpr.getY(), new_r)
def on_destroy(self):
"""脚本销毁时调用"""
self.log("机器人旋转脚本停止")
# ==================== 机器人模式控制方法 ====================
def set_robot_mode(self, enabled=True):
"""
启用或禁用机器人模式
Args:
enabled: 是否启用机器人模式
"""
self.robot_mode = enabled
self.log(f"机器人模式: {'开启' if enabled else '关闭'}")
if not enabled:
self.is_paused = False # 如果禁用机器人模式,立即结束停顿
def set_pause_duration(self, duration):
"""
设置停顿时间
Args:
duration: 停顿时间
"""
self.pause_duration = max(0.1, duration) # 最小0.1秒
self.log(f"停顿时间已设置为: {self.pause_duration}")
def set_max_angle(self, new_max_angle):
"""
设置新的最大旋转角度
Args:
new_max_angle: 新的最大角度值
"""
self.max_angle = new_max_angle
self.log(f"最大旋转角度已设置为: ±{self.max_angle}")
if self.initial_angle is not None:
self.log(f"新的旋转范围: {self.initial_angle - self.max_angle}° 到 {self.initial_angle + self.max_angle}°")
def set_rotation_speed(self, new_speed):
"""
设置新的旋转速度
Args:
new_speed: 新的旋转速度/
"""
self.rotation_speed_y = new_speed
self.log(f"旋转速度已设置为: {self.rotation_speed_y}度/秒")
def pause_rotation(self):
"""暂停旋转"""
self.is_rotating = False
self.log("旋转已暂停")
def resume_rotation(self):
"""恢复旋转"""
self.is_rotating = True
self.is_paused = False # 同时结束停顿状态
self.log("旋转已恢复")
def reset_to_initial_angle(self):
"""重置到初始角度"""
if self.initial_angle is not None and self.gameObject:
current_hpr = self.gameObject.getHpr()
self.gameObject.setHpr(current_hpr.getX(), self.initial_angle, current_hpr.getZ())
self.current_offset = 0.0
self.direction = 1
self.is_paused = False
self.current_pause_time = 0.0
self.log(f"已重置到初始角度: {self.initial_angle}")
def get_current_info(self):
"""获取当前旋转信息"""
if self.gameObject and self.initial_angle is not None:
current_hpr = self.gameObject.getHpr()
current_angle = current_hpr.getY()
self.log("=== 机器人旋转信息 ===")
self.log(f"初始角度: {self.initial_angle}")
self.log(f"当前角度: {current_angle}")
self.log(f"偏移量: {self.current_offset}")
self.log(f"最大角度: ±{self.max_angle}")
self.log(f"旋转速度: {self.rotation_speed_y}度/秒")
self.log(f"旋转方向: {'正向' if self.direction > 0 else '反向'}")
self.log(f"旋转状态: {'运行中' if self.is_rotating else '已暂停'}")
self.log(f"机器人模式: {'开启' if self.robot_mode else '关闭'}")
if self.robot_mode:
self.log(f"停顿时间: {self.pause_duration}")
self.log(f"当前状态: {'停顿中' if self.is_paused else '旋转中'}")
if self.is_paused:
remaining_time = self.pause_duration - self.current_pause_time
self.log(f"剩余停顿时间: {remaining_time:.1f}")
self.log("=== 信息结束 ===")
else:
self.log("无法获取旋转信息")
# ==================== 预设配置方法 ====================
def set_slow_robot_mode(self):
"""预设:慢速机器人模式"""
self.set_rotation_speed(15.0)
self.set_pause_duration(1.0)
self.set_robot_mode(True)
self.log("已设置为慢速机器人模式")
def set_fast_robot_mode(self):
"""预设:快速机器人模式"""
self.set_rotation_speed(45.0)
self.set_pause_duration(0.3)
self.set_robot_mode(True)
self.log("已设置为快速机器人模式")
def set_smooth_mode(self):
"""预设:平滑模式(非机器人)"""
self.set_robot_mode(False)
self.set_rotation_speed(30.0)
self.log("已设置为平滑旋转模式")

View File

@ -0,0 +1,8 @@
{
"guid": "aaf23848122d4b9c8b03f440c37a24e1",
"asset_type": "script",
"source_hash": "f5ad272f76a60794e62e88525c4cf911da08ecd1494281150360a7abd35c0173",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

View File

@ -0,0 +1,215 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
旋转脚本 - 让对象持续旋转
"""
from core.script_system import ScriptBase
class RotatorScript(ScriptBase):
"""旋转脚本类"""
def __init__(self):
super().__init__()
self.rotation_speed_y = 30.0 # Y轴旋转速度 (度/秒)
self.max_angle = 25.0 # 最大旋转角度(相对于初始角度)
self.direction = 1
self.current_offset = 0.0 # 当前相对于初始角度的偏移
self.initial_angle = None # 模型的初始角度
self.is_rotating = True # 是否正在旋转
# 机器人式停顿参数
self.pause_duration = 0.5 # 停顿时间(秒)
self.current_pause_time = 0.0 # 当前停顿计时
self.is_paused = False # 是否正在停顿
self.robot_mode = True # 是否启用机器人模式
def start(self):
"""脚本开始时调用"""
self.log("机器人旋转脚本启动!")
self.log(f"旋转速度: {self.rotation_speed_y}度/秒")
self.log(f"最大旋转角度: ±{self.max_angle}")
self.log(f"机器人模式: {'开启' if self.robot_mode else '关闭'}")
if self.robot_mode:
self.log(f"停顿时间: {self.pause_duration}")
# 记录模型的初始角度
if self.gameObject:
initial_hpr = self.gameObject.getHpr()
self.initial_angle = initial_hpr.getY() # 记录Y轴的初始角度Pitch
self.log(f"模型初始角度: {self.initial_angle}")
self.log(f"旋转范围: {self.initial_angle - self.max_angle}° 到 {self.initial_angle + self.max_angle}°")
else:
self.log("⚠️ 无法获取游戏对象使用默认初始角度0")
self.initial_angle = 0.0
def update(self, dt):
"""每帧更新 - 机器人式旋转"""
if not self.is_rotating or self.initial_angle is None:
return
# 如果正在停顿中
if self.is_paused:
self.current_pause_time += dt
if self.current_pause_time >= self.pause_duration:
# 停顿结束,继续旋转
self.is_paused = False
self.current_pause_time = 0.0
self.log(f"停顿结束,继续旋转,方向: {'正向' if self.direction > 0 else '反向'}")
return
# 计算角度变化量
delta_angle = self.rotation_speed_y * dt * self.direction
self.current_offset += delta_angle
# 检查是否到达边界
reached_boundary = False
if self.current_offset > self.max_angle:
self.current_offset = self.max_angle
self.direction *= -1
reached_boundary = True
elif self.current_offset < -self.max_angle:
self.current_offset = -self.max_angle
self.direction *= -1
reached_boundary = True
# 如果到达边界且启用机器人模式,开始停顿
if reached_boundary and self.robot_mode:
self.is_paused = True
self.current_pause_time = 0.0
self.log(f"到达边界 ({self.current_offset}°),开始停顿 {self.pause_duration}")
# 计算最终角度(初始角度 + 偏移量)
final_angle = self.initial_angle + self.current_offset
# 设置新的旋转只改变Y轴保持其他不变
current_hpr = self.gameObject.getHpr()
self.gameObject.setHpr(current_hpr.getX(), final_angle, current_hpr.getZ())
# if not self.is_rotating:
# return
#
# # 获取当前旋转并应用增量
# current_hpr = self.gameObject.getHpr()
# new_r = current_hpr.getZ() + self.rotation_speed_y * dt
# self.gameObject.setHpr(current_hpr.getX(), current_hpr.getY(), new_r)
def on_destroy(self):
"""脚本销毁时调用"""
self.log("机器人旋转脚本停止")
# ==================== 机器人模式控制方法 ====================
def set_robot_mode(self, enabled=True):
"""
启用或禁用机器人模式
Args:
enabled: 是否启用机器人模式
"""
self.robot_mode = enabled
self.log(f"机器人模式: {'开启' if enabled else '关闭'}")
if not enabled:
self.is_paused = False # 如果禁用机器人模式,立即结束停顿
def set_pause_duration(self, duration):
"""
设置停顿时间
Args:
duration: 停顿时间
"""
self.pause_duration = max(0.1, duration) # 最小0.1秒
self.log(f"停顿时间已设置为: {self.pause_duration}")
def set_max_angle(self, new_max_angle):
"""
设置新的最大旋转角度
Args:
new_max_angle: 新的最大角度值
"""
self.max_angle = new_max_angle
self.log(f"最大旋转角度已设置为: ±{self.max_angle}")
if self.initial_angle is not None:
self.log(f"新的旋转范围: {self.initial_angle - self.max_angle}° 到 {self.initial_angle + self.max_angle}°")
def set_rotation_speed(self, new_speed):
"""
设置新的旋转速度
Args:
new_speed: 新的旋转速度/
"""
self.rotation_speed_y = new_speed
self.log(f"旋转速度已设置为: {self.rotation_speed_y}度/秒")
def pause_rotation(self):
"""暂停旋转"""
self.is_rotating = False
self.log("旋转已暂停")
def resume_rotation(self):
"""恢复旋转"""
self.is_rotating = True
self.is_paused = False # 同时结束停顿状态
self.log("旋转已恢复")
def reset_to_initial_angle(self):
"""重置到初始角度"""
if self.initial_angle is not None and self.gameObject:
current_hpr = self.gameObject.getHpr()
self.gameObject.setHpr(current_hpr.getX(), self.initial_angle, current_hpr.getZ())
self.current_offset = 0.0
self.direction = 1
self.is_paused = False
self.current_pause_time = 0.0
self.log(f"已重置到初始角度: {self.initial_angle}")
def get_current_info(self):
"""获取当前旋转信息"""
if self.gameObject and self.initial_angle is not None:
current_hpr = self.gameObject.getHpr()
current_angle = current_hpr.getY()
self.log("=== 机器人旋转信息 ===")
self.log(f"初始角度: {self.initial_angle}")
self.log(f"当前角度: {current_angle}")
self.log(f"偏移量: {self.current_offset}")
self.log(f"最大角度: ±{self.max_angle}")
self.log(f"旋转速度: {self.rotation_speed_y}度/秒")
self.log(f"旋转方向: {'正向' if self.direction > 0 else '反向'}")
self.log(f"旋转状态: {'运行中' if self.is_rotating else '已暂停'}")
self.log(f"机器人模式: {'开启' if self.robot_mode else '关闭'}")
if self.robot_mode:
self.log(f"停顿时间: {self.pause_duration}")
self.log(f"当前状态: {'停顿中' if self.is_paused else '旋转中'}")
if self.is_paused:
remaining_time = self.pause_duration - self.current_pause_time
self.log(f"剩余停顿时间: {remaining_time:.1f}")
self.log("=== 信息结束 ===")
else:
self.log("无法获取旋转信息")
# ==================== 预设配置方法 ====================
def set_slow_robot_mode(self):
"""预设:慢速机器人模式"""
self.set_rotation_speed(15.0)
self.set_pause_duration(1.0)
self.set_robot_mode(True)
self.log("已设置为慢速机器人模式")
def set_fast_robot_mode(self):
"""预设:快速机器人模式"""
self.set_rotation_speed(45.0)
self.set_pause_duration(0.3)
self.set_robot_mode(True)
self.log("已设置为快速机器人模式")
def set_smooth_mode(self):
"""预设:平滑模式(非机器人)"""
self.set_robot_mode(False)
self.set_rotation_speed(30.0)
self.log("已设置为平滑旋转模式")

View File

@ -0,0 +1,8 @@
{
"guid": "6a667d9af5cf4fa6bbe3538783fdb7f8",
"asset_type": "script",
"source_hash": "ac9fd300f5492b360bcb7c7b8b559405d2e0de0c035f80a401910ed0940318d2",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

View File

@ -0,0 +1,56 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
旋转脚本 - 让对象持续旋转
"""
from core.script_system import ScriptBase
class RotatorScript(ScriptBase):
"""旋转脚本类"""
def __init__(self):
super().__init__()
self.rotation_speed_y = 30.0 # Y轴旋转速度 (度/秒)
self.max_angle = 15.0
self.direction = 1
self.current_angle = 0.0
self.is_rotating = True # 是否正在旋转
def start(self):
"""脚本开始时调用"""
self.log("旋转脚本启动!")
self.log(f"旋转速度: {self.rotation_speed_y}度/秒")
def update(self, dt):
"""每帧更新"""
delta_angle = self.rotation_speed_y * dt * self.direction
self.current_angle += delta_angle
# 如果超出角度范围,则反向
if self.current_angle > self.max_angle:
self.current_angle = self.max_angle
self.direction *= -1
elif self.current_angle < -self.max_angle:
self.current_angle = -self.max_angle
self.direction *= -1
# 设置新的旋转只改变Z轴保持其他不变
base_hpr = self.gameObject.getHpr()
new_r = self.current_angle
self.gameObject.setHpr(base_hpr.getX(), base_hpr.getY(), new_r)
# if not self.is_rotating:
# return
#
# # 获取当前旋转并应用增量
# current_hpr = self.gameObject.getHpr()
# new_r = current_hpr.getZ() + self.rotation_speed_y * dt
# self.gameObject.setHpr(current_hpr.getX(), current_hpr.getY(), new_r)
def on_destroy(self):
"""脚本销毁时调用"""
self.log("旋转脚本停止")

View File

@ -0,0 +1,8 @@
{
"guid": "a47fd70877bb43c1a1a47ebe14c23a51",
"asset_type": "script",
"source_hash": "835d86d24bc516a2b5ef4848d0c3be700da364e396383778288ce4e75a1b63c3",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

View File

@ -0,0 +1,39 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
旋转脚本 - 让对象持续旋转
"""
from core.script_system import ScriptBase
class RotatorScript(ScriptBase):
"""旋转脚本类"""
def __init__(self):
super().__init__()
self.rotation_speed_y = 30.0 # Y轴旋转速度 (度/秒)
self.is_rotating = True # 是否正在旋转
def start(self):
"""脚本开始时调用"""
self.log("旋转脚本启动!")
self.log(f"旋转速度: {self.rotation_speed_y}度/秒")
def update(self, dt):
# 检查 gameObject 是否存在且不为空
if not self.gameObject or self.gameObject.isEmpty():
print("RotatorScript: gameObject is empty or None, skipping update")
return
"""每帧更新"""
if not self.is_rotating:
return
# 获取当前旋转并应用增量
current_hpr = self.gameObject.getHpr()
new_h = current_hpr.getX() + self.rotation_speed_y * dt
self.gameObject.setHpr(new_h, current_hpr.getY(), current_hpr.getZ())
def on_destroy(self):
"""脚本销毁时调用"""
self.log("旋转脚本停止")

View File

@ -0,0 +1,8 @@
{
"guid": "ef63be9617ef4396b7c3949a26e1ae2e",
"asset_type": "script",
"source_hash": "022537b7b2d9a413fe3619336b497a6ef2dcb443229c0042efca56072ac67eba",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

View File

@ -0,0 +1,91 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
缩放脚本 - 让对象产生呼吸般的缩放效果
"""
from core.script_system import ScriptBase
import math
class ScalerScript(ScriptBase):
"""缩放脚本类"""
def __init__(self):
super().__init__()
# 缩放参数
self.base_scale = 1.0 # 基础缩放
self.scale_amplitude = 0.3 # 缩放幅度
self.scale_speed = 2.0 # 缩放速度 (周期/秒)
self.uniform_scale = True # 是否统一缩放(所有轴)
# 内部变量
self.time_accumulator = 0.0 # 时间累积器
self.original_scale = None # 原始缩放
self.is_scaling = True # 是否正在缩放
def start(self):
"""脚本开始时调用"""
self.log("缩放脚本启动!")
self.log(f"缩放参数: 基础={self.base_scale}, 幅度={self.scale_amplitude}, 速度={self.scale_speed}")
# 记录原始缩放
self.original_scale = self.gameObject.getScale()
self.log(f"原始缩放: {self.original_scale}")
def update(self, dt):
"""每帧更新"""
if not self.is_scaling:
return
# 累积时间
self.time_accumulator += dt
# 计算正弦波缩放值
sine_value = math.sin(self.time_accumulator * self.scale_speed * 2 * math.pi)
scale_factor = self.base_scale + (self.scale_amplitude * sine_value)
# 应用缩放
if self.uniform_scale:
# 统一缩放
self.gameObject.setScale(scale_factor)
else:
# 非统一缩放仅Z轴
current_scale = self.gameObject.getScale()
self.gameObject.setScale(current_scale.getX(), current_scale.getY(), scale_factor)
def set_scale_parameters(self, base=None, amplitude=None, speed=None, uniform=None):
"""设置缩放参数"""
if base is not None:
self.base_scale = base
if amplitude is not None:
self.scale_amplitude = amplitude
if speed is not None:
self.scale_speed = speed
if uniform is not None:
self.uniform_scale = uniform
self.log(f"缩放参数更新: 基础={self.base_scale}, 幅度={self.scale_amplitude}, 速度={self.scale_speed}")
def toggle_scaling(self):
"""切换缩放状态"""
self.is_scaling = not self.is_scaling
status = "恢复" if self.is_scaling else "暂停"
self.log(f"缩放{status}")
def reset_scale(self):
"""重置到原始缩放"""
if self.original_scale:
self.gameObject.setScale(self.original_scale)
self.time_accumulator = 0.0
self.log("缩放已重置到原始值")
def pulse_once(self):
"""执行一次脉冲缩放"""
self.time_accumulator = 0.0
self.log("执行脉冲缩放")
def on_destroy(self):
"""脚本销毁时调用"""
self.log("缩放脚本停止")

View File

@ -0,0 +1,8 @@
{
"guid": "66eb4d9378a94173b959407896cd1e58",
"asset_type": "script",
"source_hash": "133640b172b69c184b1504ac8631fbc7374814d94fc786d551906e378e421c01",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

View File

@ -0,0 +1,41 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
TestMover - 移动脚本
"""
from core.script_system import ScriptBase
class Testmover(ScriptBase):
"""移动脚本类"""
def __init__(self):
super().__init__()
self.speed = 5.0 # 移动速度
self.direction = [1, 0, 0] # 移动方向
def start(self):
"""脚本开始时调用"""
self.log("移动脚本开始运行!")
def update(self, dt):
"""每帧更新"""
if self.transform:
# 计算移动偏移
offset_x = self.direction[0] * self.speed * dt
offset_y = self.direction[1] * self.speed * dt
offset_z = self.direction[2] * self.speed * dt
# 更新位置
current_pos = self.transform.getPos()
new_pos = (
current_pos.x + offset_x,
current_pos.y + offset_y,
current_pos.z + offset_z
)
self.transform.setPos(*new_pos)
def on_destroy(self):
"""脚本销毁时调用"""
self.log("移动脚本被销毁")

View File

@ -0,0 +1,8 @@
{
"guid": "1de4ebbdeec2479e805ba81c37333308",
"asset_type": "script",
"source_hash": "8b28fcd66c813df50473c53df714f726ae396ad98d23084c846d139a0738180c",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

View File

@ -0,0 +1,28 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
TestRotator - 自定义脚本
"""
from core.script_system import ScriptBase
class Testrotator(ScriptBase):
"""自定义脚本类"""
def __init__(self):
super().__init__()
# 在这里初始化您的变量
def start(self):
"""脚本开始时调用"""
self.log("脚本开始运行!")
def update(self, dt):
"""每帧更新"""
# 在这里编写更新逻辑
pass
def on_destroy(self):
"""脚本销毁时调用"""
self.log("脚本被销毁")

View File

@ -0,0 +1,8 @@
{
"guid": "213fc3b009ab4efaab63773b651161a4",
"asset_type": "script",
"source_hash": "2af9f7c47a239cf742270d306aadd76ed1a6fde98c415bb44d0866ad94207811",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

View File

@ -0,0 +1,28 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
TestScaler - 自定义脚本
"""
from core.script_system import ScriptBase
class Testscaler(ScriptBase):
"""自定义脚本类"""
def __init__(self):
super().__init__()
# 在这里初始化您的变量
def start(self):
"""脚本开始时调用"""
self.log("脚本开始运行!")
def update(self, dt):
"""每帧更新"""
# 在这里编写更新逻辑
pass
def on_destroy(self):
"""脚本销毁时调用"""
self.log("脚本被销毁")

View File

@ -0,0 +1,8 @@
{
"guid": "a8e9db2e3da24fa0910a7324c941daa4",
"asset_type": "script",
"source_hash": "e2df9ee8bc4131ff7e71b90aa87db12597d3ab50a848afbfbda726ee795038e9",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

28
321/Assets/Scripts/a.py Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
a - 自定义脚本
"""
from core.script_system import ScriptBase
class A(ScriptBase):
"""自定义脚本类"""
def __init__(self):
super().__init__()
# 在这里初始化您的变量
def start(self):
"""脚本开始时调用"""
self.log("脚本开始运行!")
def update(self, dt):
"""每帧更新"""
# 在这里编写更新逻辑
pass
def on_destroy(self):
"""脚本销毁时调用"""
self.log("脚本被销毁")

View File

@ -0,0 +1,8 @@
{
"guid": "82ad6d9198b547f6a27582bc9abe1cb2",
"asset_type": "script",
"source_hash": "25a5114db02ca93ee86ea51d4e20216b9f272f75e5e45019d331570b64f23830",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

View File

@ -0,0 +1,47 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
示例脚本 - 演示如何编写脚本
"""
from core.script_system import ScriptBase
class ExampleScript(ScriptBase):
"""示例脚本类"""
def __init__(self):
super().__init__()
self.counter = 0
self.rotation_speed = 30.0 # 度/秒
def start(self):
"""脚本开始时调用"""
self.log("示例脚本开始运行!")
self.log(f"挂载到对象: {self.gameObject.getName()}")
def update(self, dt):
"""每帧更新"""
self.counter += 1
# 每60帧输出一次信息
if self.counter % 60 == 0:
self.log(f"运行了 {self.counter}")
# 让对象旋转
if self.transform:
current_h = self.transform.getH()
new_h = current_h + self.rotation_speed * dt
self.transform.setH(new_h)
def on_destroy(self):
"""脚本销毁时调用"""
self.log("示例脚本被销毁")
def on_enable(self):
"""脚本启用时调用"""
self.log("示例脚本被启用")
def on_disable(self):
"""脚本禁用时调用"""
self.log("示例脚本被禁用")

View File

@ -0,0 +1,8 @@
{
"guid": "e810d70352d7499ebc246a869ed44e1c",
"asset_type": "script",
"source_hash": "349e4d61f9b8647ceba6dccabfa32f904392ed8bfc2c33110a8fac8b841ab47f",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

View File

@ -0,0 +1,28 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
test_quick_script - 自定义脚本
"""
from core.script_system import ScriptBase
class TestQuickScript(ScriptBase):
"""自定义脚本类"""
def __init__(self):
super().__init__()
# 在这里初始化您的变量
def start(self):
"""脚本开始时调用"""
self.log("脚本开始运行!")
def update(self, dt):
"""每帧更新"""
# 在这里编写更新逻辑
pass
def on_destroy(self):
"""脚本销毁时调用"""
self.log("脚本被销毁")

View File

@ -0,0 +1,8 @@
{
"guid": "d0798db317a94732a69cb6ab1d22a0d5",
"asset_type": "script",
"source_hash": "00ec4c1a1b2093b79685f357eda0b32cf1897df75e76f6148ff63f826a9957eb",
"importer": "script_importer",
"import_settings": {},
"dependency_guids": []
}

BIN
321/Builds/321/321.exe Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More