功能扩展
This commit is contained in:
parent
e1de33b896
commit
e52eddcf1a
@ -231,6 +231,11 @@ public class ActionHelper
|
|||||||
var dictAction = (XMLTool.DictionaryAction)act;
|
var dictAction = (XMLTool.DictionaryAction)act;
|
||||||
return TimeLineAction.Allocate(act.Value, dictAction.args);
|
return TimeLineAction.Allocate(act.Value, dictAction.args);
|
||||||
}
|
}
|
||||||
|
case "Mat":
|
||||||
|
{
|
||||||
|
var dictAction = (XMLTool.DictionaryAction)act;
|
||||||
|
return MatAction.Allocate(dictAction.args);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
Debug.LogError($"没有找到此Action的类型{act.Type}");
|
Debug.LogError($"没有找到此Action的类型{act.Type}");
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -24,6 +24,7 @@ namespace QFramework
|
|||||||
Color color = Color.green;
|
Color color = Color.green;
|
||||||
bool isHigh = true;
|
bool isHigh = true;
|
||||||
string deviceName = string.Empty;
|
string deviceName = string.Empty;
|
||||||
|
string isIndependent;
|
||||||
public static HighLightAction Allocate(string path, Dictionary<string, string> datas, System.Action OnFinished = null)
|
public static HighLightAction Allocate(string path, Dictionary<string, string> datas, System.Action OnFinished = null)
|
||||||
{
|
{
|
||||||
var retNode = mPool.Allocate();
|
var retNode = mPool.Allocate();
|
||||||
@ -43,6 +44,7 @@ namespace QFramework
|
|||||||
bool.TryParse(datas["isHigh"], out retNode.isHigh);
|
bool.TryParse(datas["isHigh"], out retNode.isHigh);
|
||||||
}
|
}
|
||||||
retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : string.Empty;
|
retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : string.Empty;
|
||||||
|
retNode.isIndependent = datas.ContainsKey("isIndependent") ? datas["isIndependent"] : string.Empty;
|
||||||
retNode.OnFinished = OnFinished;
|
retNode.OnFinished = OnFinished;
|
||||||
return retNode;
|
return retNode;
|
||||||
}
|
}
|
||||||
@ -70,6 +72,18 @@ namespace QFramework
|
|||||||
var effect = obj.GetOrAddComponent<HighlightEffect>();
|
var effect = obj.GetOrAddComponent<HighlightEffect>();
|
||||||
effect.outlineColor = color;
|
effect.outlineColor = color;
|
||||||
effect.highlighted = true;
|
effect.highlighted = true;
|
||||||
|
if (string.IsNullOrEmpty(isIndependent) == false)
|
||||||
|
{
|
||||||
|
switch (isIndependent)
|
||||||
|
{
|
||||||
|
case "true":
|
||||||
|
effect.outlineIndependent = true;
|
||||||
|
break;
|
||||||
|
case "false":
|
||||||
|
effect.outlineIndependent = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -78,10 +92,10 @@ namespace QFramework
|
|||||||
{
|
{
|
||||||
effect.highlighted = false;
|
effect.highlighted = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void OnExecute(float dt)
|
public void OnExecute(float dt)
|
||||||
{
|
{
|
||||||
|
|||||||
93
Assets/Scripts/Actions/MatAction.cs
Normal file
93
Assets/Scripts/Actions/MatAction.cs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace QFramework
|
||||||
|
{
|
||||||
|
internal class MatAction : IAction
|
||||||
|
{
|
||||||
|
|
||||||
|
public System.Action OnFinished { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
private MatAction()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly SimpleObjectPool<MatAction> mPool =
|
||||||
|
new SimpleObjectPool<MatAction>(() => new MatAction(), null, 10);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string value;
|
||||||
|
string deviceName;
|
||||||
|
string matName;
|
||||||
|
string index;
|
||||||
|
public static MatAction Allocate(Dictionary<string, string> datas, System.Action OnFinished = null)
|
||||||
|
{
|
||||||
|
var retNode = mPool.Allocate();
|
||||||
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
||||||
|
retNode.Deinited = false;
|
||||||
|
retNode.Reset();
|
||||||
|
retNode.value = datas.ContainsKey("value") ? datas["value"] : "";
|
||||||
|
retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : "";
|
||||||
|
retNode.matName = datas.ContainsKey("matName") ? datas["matName"] : "";
|
||||||
|
retNode.index = datas.ContainsKey("index") ? datas["index"] : "0";
|
||||||
|
retNode.OnFinished = OnFinished;
|
||||||
|
return retNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ulong ActionID { get; set; }
|
||||||
|
public ActionStatus Status { get; set; }
|
||||||
|
|
||||||
|
public void OnStart()
|
||||||
|
{
|
||||||
|
GameObject obj;
|
||||||
|
if (string.IsNullOrEmpty(deviceName))
|
||||||
|
{
|
||||||
|
obj = Utility.FindObj(value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
obj = DeviceController.Instance.GetDeviceObj(deviceName);
|
||||||
|
}
|
||||||
|
var mesh = obj.GetComponent<Renderer>();
|
||||||
|
int matIndex = 0;
|
||||||
|
int.TryParse(index, out matIndex);
|
||||||
|
mesh.materials[matIndex] = Resources.Load<Material>("Mat/" + matName);
|
||||||
|
this.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnExecute(float dt)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnFinish()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
Status = ActionStatus.NotStart;
|
||||||
|
Paused = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Paused { get; set; }
|
||||||
|
|
||||||
|
public void Deinit()
|
||||||
|
{
|
||||||
|
if (!Deinited)
|
||||||
|
{
|
||||||
|
OnFinished = null;
|
||||||
|
Deinited = true;
|
||||||
|
mPool.Recycle(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Deinited { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
11
Assets/Scripts/Actions/MatAction.cs.meta
Normal file
11
Assets/Scripts/Actions/MatAction.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 05ceca20dad98ea4092091f19ff388a3
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -772,7 +772,14 @@ namespace XMLTool
|
|||||||
act.args.Add("deviceName", deviceName.Value);
|
act.args.Add("deviceName", deviceName.Value);
|
||||||
}
|
}
|
||||||
newAction = act;
|
newAction = act;
|
||||||
|
XAttribute isIndependent = action.Attribute("isIndependent");
|
||||||
|
if (isIndependent != null)
|
||||||
|
{
|
||||||
|
act.args.Add("isIndependent", isIndependent.Value);
|
||||||
}
|
}
|
||||||
|
newAction = act;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "LoadRes":
|
case "LoadRes":
|
||||||
{
|
{
|
||||||
@ -1087,6 +1094,32 @@ namespace XMLTool
|
|||||||
newAction = act;
|
newAction = act;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "Mat":
|
||||||
|
{
|
||||||
|
var act = new DictionaryAction();
|
||||||
|
XAttribute value = action.Attribute("value");
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
act.args.Add("value", value.Value);
|
||||||
|
}
|
||||||
|
XAttribute deviceName = action.Attribute("deviceName");
|
||||||
|
if (deviceName != null)
|
||||||
|
{
|
||||||
|
act.args.Add("deviceName", deviceName.Value);
|
||||||
|
}
|
||||||
|
XAttribute matName = action.Attribute("matName");
|
||||||
|
if (matName != null)
|
||||||
|
{
|
||||||
|
act.args.Add("matName", matName.Value);
|
||||||
|
}
|
||||||
|
XAttribute index = action.Attribute("index");
|
||||||
|
if (index != null)
|
||||||
|
{
|
||||||
|
act.args.Add("index", index.Value);
|
||||||
|
}
|
||||||
|
newAction = act;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
newAction = new Action();
|
newAction = new Action();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user