我们创建了 Fontainebleau 演示来说明摄影photogrammetry流程和 LayeredLit 着色器的使用。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

54 行
1.6 KiB

using NaughtyAttributes;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace GameplayIngredients.Actions
{
public class AttachToObjectAction : ActionBase
{
public enum Action
{
Attach,
Detach,
ToggleAttachment
}
public Action action = Action.Attach;
[ReorderableList]
public GameObject[] objectsToAttach;
public bool AttachInstigator = false;
public GameObject parentObject;
public bool KeepScale;
public override void Execute(GameObject instigator = null)
{
if (parentObject == null)
{
Debug.LogWarning("No Object to attach to.");
return;
}
if (objectsToAttach != null)
{
foreach (var obj in objectsToAttach)
DoAttach(obj, parentObject, action, KeepScale);
}
if (AttachInstigator && instigator != null)
DoAttach(instigator, parentObject, action, KeepScale);
}
static void DoAttach(GameObject attachment, GameObject parent, Action action, bool keepScale)
{
if(action == Action.Attach || (action == Action.ToggleAttachment && attachment.transform.parent != parent.transform))
{
attachment.transform.parent = parent.transform;
}
else if(action == Action.Detach || (action == Action.ToggleAttachment && attachment.transform.parent == parent.transform))
{
attachment.transform.parent = null;
}
}
}
}