比较提交

...
此合并请求有变更与目标分支冲突。
/Runtime/LevelScripting/Callable.cs

1 次代码提交

作者 SHA1 备注 提交日期
Thomas ICHÉ f770b374 Base Commit 4 年前
共有 9 个文件被更改,包括 173 次插入0 次删除
  1. 10
      Runtime/LevelScripting/Callable.cs
  2. 8
      Editor/CallableFlow.meta
  3. 31
      Runtime/LevelScripting/CallableFlow.cs
  4. 11
      Runtime/LevelScripting/CallableFlow.cs.meta
  5. 25
      Editor/CallableFlow/CallableFlowEditor.cs
  6. 11
      Editor/CallableFlow/CallableFlowEditor.cs.meta
  7. 66
      Editor/CallableFlow/CallableFlowEditorWindow.cs
  8. 11
      Editor/CallableFlow/CallableFlowEditorWindow.cs.meta

10
Runtime/LevelScripting/Callable.cs


{
return GetType().Name;
}
#if UNITY_EDITOR
public bool isFlow => hideFlags == HideFlags.HideInInspector;
private Vector2 m_FlowGraphPosition;
public static void SetAsFlowComponent(Callable callable, bool flow)
{
callable.hideFlags = flow ? HideFlags.HideInInspector : HideFlags.None;
}
#endif
}
}

8
Editor/CallableFlow.meta


fileFormatVersion: 2
guid: edb34c886bd38a94eaf9e5206e96791a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

31
Runtime/LevelScripting/CallableFlow.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace GameplayIngredients
{
public class CallableFlow : MonoBehaviour
{
[SerializeField]
private List<Callable> callables = new List<Callable>();
public void AddCallable<T>() where T:Callable
{
var callable = gameObject.AddComponent<T>();
Callable.SetAsFlowComponent(callable, true);
}
private void OnDestroy()
{
if (callables == null)
return;
foreach(var callable in callables)
{
Destroy(callable);
}
}
}
}

11
Runtime/LevelScripting/CallableFlow.cs.meta


fileFormatVersion: 2
guid: 58b72d1c3d257ec42b7376de68b1e3fa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

25
Editor/CallableFlow/CallableFlowEditor.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace GameplayIngredients.Editor
{
[CustomEditor(typeof(CallableFlow))]
public class CallableFlowEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
if(GUILayout.Button("Open Flow Window"))
{
CallableFlowEditorWindow wnd = EditorWindow.GetWindow<CallableFlowEditorWindow>();
wnd.OpenCallableFlow(serializedObject.targetObject as CallableFlow);
}
}
}
}

11
Editor/CallableFlow/CallableFlowEditor.cs.meta


fileFormatVersion: 2
guid: 826867eec5ad1c942949866dc51e967a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

66
Editor/CallableFlow/CallableFlowEditorWindow.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Experimental.GraphView;
namespace GameplayIngredients.Editor
{
public class CallableFlowEditorWindow : EditorWindow
{
CallableFlow m_CallableFlow;
void OnEnable()
{
titleContent = new GUIContent("Callable Flow");
Selection.selectionChanged += OnSelectionChanged;
}
private void OnDisable()
{
Selection.selectionChanged -= OnSelectionChanged;
}
private void OnSelectionChanged()
{
CallableFlow flow;
if (Selection.activeObject != null && Selection.activeGameObject.TryGetComponent<CallableFlow>(out flow))
{
OpenCallableFlow(flow);
}
}
public void OpenCallableFlow(CallableFlow flow)
{
m_CallableFlow = flow;
Repaint();
}
private void OnGUI()
{
if(m_CallableFlow == null)
{
using(new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
using(new GUILayout.VerticalScope(GUILayout.Width(320)))
{
GUILayout.FlexibleSpace();
EditorGUILayout.HelpBox("No Object selected with Callable Flow, please select an object with a callable flow component.", MessageType.Info);
GUILayout.FlexibleSpace();
}
GUILayout.FlexibleSpace();
}
return;
}
using(new GUILayout.HorizontalScope(EditorStyles.toolbar))
{
GUILayout.Button("Refresh", EditorStyles.toolbarButton);
GUILayout.FlexibleSpace();
if (GUILayout.Button(m_CallableFlow.gameObject.name, EditorStyles.toolbarButton))
EditorGUIUtility.PingObject(m_CallableFlow.gameObject);
}
}
}
}

11
Editor/CallableFlow/CallableFlowEditorWindow.cs.meta


fileFormatVersion: 2
guid: f1140bbc6fc90eb48b5df6ae5b875695
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存