本文整理汇总了C#中UnityEngine.UI.Windows.Plugins.Flow.FlowWindow类的典型用法代码示例。如果您正苦于以下问题:C# FlowWindow类的具体用法?C# FlowWindow怎么用?C# FlowWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FlowWindow类属于UnityEngine.UI.Windows.Plugins.Flow命名空间,在下文中一共展示了FlowWindow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get
public Window Get(FlowWindow window) {
Window result = null;
this.list.RemoveAll((info) => {
var w = Flow.FlowSystem.GetWindow(info.id);
return w == null || w.IsSocial() == false;
});
if (window.IsSocial() == false) return result;
foreach (var item in this.list) {
if (item.id == window.id) {
result = item;
break;
}
}
if (result == null) {
result = new Window(window);
this.list.Add(result);
}
return result;
}
示例2: OnFlowWindowGUI
public override void OnFlowWindowGUI(FlowWindow window) {
if (window.CanCompiled() == false) return;
if (string.IsNullOrEmpty(window.compiledDirectory) == false) {
window.compiled = System.IO.File.Exists(window.compiledDirectory + "/" + window.compiledBaseClassName + ".cs");
}
var oldColor = GUI.color;
var style = new GUIStyle("U2D.dragDotDimmed");
var styleCompiled = new GUIStyle("U2D.dragDot");
var elemWidth = style.fixedWidth - 3f;
var posY = -1f;
var posX = -1f;
GUI.color = window.compiled ? Color.white : Color.red;
GUI.Label(new Rect(posX, posY, elemWidth, style.fixedHeight), new GUIContent(string.Empty, window.compiled ? "Compiled" : "Not compiled"), window.compiled ? styleCompiled : style);
GUI.color = oldColor;
}
示例3: GenerateReturnMethod
public static string GenerateReturnMethod(FlowSystemEditorWindow flowEditor, FlowWindow exitWindow) {
var file = Resources.Load("UI.Windows/Functions/Templates/TemplateReturnMethod") as TextAsset;
if (file == null) {
Debug.LogError("Functions Template Loading Error: Could not load template 'TemplateReturnMethod'");
return string.Empty;
}
var data = FlowSystem.GetData();
if (data == null) return string.Empty;
var result = string.Empty;
var part = file.text;
var functionContainer = exitWindow.GetFunctionContainer();
var functionName = functionContainer.title;
var functionCallName = functionContainer.directory;
var classNameWithNamespace = Tpl.GetNamespace(exitWindow) + "." + Tpl.GetDerivedClassName(exitWindow);
result +=
part.Replace("{FUNCTION_NAME}", functionName)
.Replace("{FUNCTION_CALL_NAME}", functionCallName)
.Replace("{CLASS_NAME_WITH_NAMESPACE}", classNameWithNamespace);
return result;
}
示例4: Info
public Info(FlowWindow window) {
this.baseNamespace = window.compiledNamespace;
this.classname = window.compiledDerivedClassName;
this.baseClassname = window.compiledBaseClassName;
this.screenName = window.directory;
}
示例5: GenerateTransitionMethod
public static string GenerateTransitionMethod(FlowSystemEditorWindow flowEditor, FlowWindow windowFrom, FlowWindow windowTo) {
var file = Resources.Load("UI.Windows/Functions/Templates/TemplateTransitionMethod") as TextAsset;
if (file == null) {
Debug.LogError("Functions Template Loading Error: Could not load template 'TemplateTransitionMethod'");
return string.Empty;
}
var data = FlowSystem.GetData();
if (data == null) return string.Empty;
var result = string.Empty;
var part = file.text;
// Function link
var functionId = windowTo.GetFunctionId();
// Find function container
var functionContainer = data.GetWindow(functionId);
if (functionContainer == null) {
// Function not found
return string.Empty;
}
// Get function root window
var root = data.GetWindow(functionContainer.functionRootId);
//var exit = data.GetWindow(functionContainer.functionExitId);
var functionName = functionContainer.title;
var functionCallName = functionContainer.directory;
var classNameWithNamespace = Tpl.GetNamespace(root) + "." + Tpl.GetDerivedClassName(root);
var transitionMethods = Tpl.GenerateTransitionMethods(windowTo);
transitionMethods = transitionMethods.Replace("\r\n", "\r\n\t")
.Replace("\n", "\n\t");
result +=
part.Replace("{TRANSITION_METHODS}", transitionMethods)
.Replace("{FUNCTION_NAME}", functionName)
.Replace("{FUNCTION_CALL_NAME}", functionCallName)
.Replace("{FLOW_FROM_ID}", windowFrom.id.ToString())
.Replace("{FLOW_TO_ID}", windowTo.id.ToString())
.Replace("{CLASS_NAME_WITH_NAMESPACE}", classNameWithNamespace);
return result;
}
示例6: DrawComponentCurve
public void DrawComponentCurve(FlowWindow from, ref UnityEngine.UI.Windows.Plugins.Flow.FlowWindow.ComponentLink link, FlowWindow to) {
if (from.IsEnabled() == false || to.IsEnabled() == false) return;
var component = from.GetLayoutComponent(link.sourceComponentTag);
if (component != null) {
var rect = component.tempEditorRect;
var start = new Rect(from.rect.x + rect.x, from.rect.y + rect.y, rect.width, rect.height);
var end = to.rect;
var zOffset = -4f;
var offset = Vector2.zero;
var startPos = new Vector3(start.center.x + offset.x, start.center.y + offset.y, zOffset);
var endPos = new Vector3(end.center.x + offset.x, end.center.y + offset.y, zOffset);
var scale = FlowSystem.GetData().flowWindowWithLayoutScaleFactor;
var side1 = from.rect.size.x * 0.5f;
var side2 = from.rect.size.y * 0.5f;
var stopDistance = Mathf.Sqrt(side1 * side1 + side2 * side2);
var color = Color.white;
if (from.GetContainer() != to.GetContainer()) {
color = Color.gray;
if (to.GetContainer() != null) color = to.GetContainer().randomColor;
}
var comment = this.DrawComponentCurve(startPos, endPos, color, stopDistance + 50f * scale, link.comment);
if (link.comment != comment) {
link.comment = comment;
FlowSystem.SetDirty();
}
}
}
示例7: DrawStates
private void DrawStates(CompletedState[] states, FlowWindow window) {
if (states == null) return;
var oldColor = GUI.color;
var style = ME.Utilities.CacheStyle("FlowEditor.DrawStates.Styles", "Grad Down Swatch");
var elemWidth = style.fixedWidth - 3f;
var width = window.rect.width - 6f;
var posY = -9f;
var color = Color.black;
color.a = 0.6f;
var posX = width - elemWidth;
var shadowOffset = 1f;
for (int i = states.Length - 1; i >= 0; --i) {
GUI.color = color;
GUI.Label(new Rect(posX + shadowOffset, posY + shadowOffset, elemWidth, style.fixedHeight), string.Empty, style);
posX -= elemWidth;
}
posX = width - elemWidth;
for (int i = states.Length - 1; i >= 0; --i) {
var state = states[i];
if (state == CompletedState.NotReady) {
color = new Color(1f, 0.3f, 0.3f, 1f);
} else if (state == CompletedState.Ready) {
color = new Color(0.3f, 1f, 0.3f, 1f);
} else if (state == CompletedState.ReadyButWarnings) {
color = new Color(1f, 1f, 0.3f, 1f);
}
GUI.color = color;
GUI.Label(new Rect(posX, posY, elemWidth, style.fixedHeight), string.Empty, style);
posX -= elemWidth;
}
GUI.color = oldColor;
}
示例8: GetTagsHeight
public float GetTagsHeight(FlowWindow window) {
var columns = 3;
var height = 16f;
return Mathf.CeilToInt(window.tags.Count / (float)columns) * height + height + 2f;
}
示例9: DrawTags
private void DrawTags(FlowWindow window, bool defaultWindow = false) {
EditorGUIUtility.labelWidth = 35f;
var tagStyles = FlowSystemEditor.GetTagStyles();
var tagCaptionStyleText = ME.Utilities.CacheStyle("FlowEditor.DrawTags.Styles", "sv_label_0");
var tagCaptionStyle = ME.Utilities.CacheStyle("FlowEditor.DrawTags.Styles", "tagCaptionStyle", (styleName) => {
var _tagCaptionStyle = new GUIStyle(GUI.skin.textField);
_tagCaptionStyle.alignment = TextAnchor.MiddleCenter;
_tagCaptionStyle.fixedWidth = 90f;
_tagCaptionStyle.fixedHeight = tagCaptionStyleText.fixedHeight;
_tagCaptionStyle.stretchWidth = false;
_tagCaptionStyle.font = tagCaptionStyleText.font;
_tagCaptionStyle.fontStyle = tagCaptionStyleText.fontStyle;
_tagCaptionStyle.fontSize = tagCaptionStyleText.fontSize;
_tagCaptionStyle.normal = tagCaptionStyleText.normal;
_tagCaptionStyle.focused = tagCaptionStyleText.normal;
_tagCaptionStyle.active = tagCaptionStyleText.normal;
_tagCaptionStyle.hover = tagCaptionStyleText.normal;
_tagCaptionStyle.border = tagCaptionStyleText.border;
//_tagCaptionStyle.padding = tagCaptionStyleText.padding;
//_tagCaptionStyle.margin = tagCaptionStyleText.margin;
_tagCaptionStyle.margin = new RectOffset();
return _tagCaptionStyle;
});
var tagStyleAdd = ME.Utilities.CacheStyle("FlowEditor.DrawTags.Styles", "sv_label_3", (styleName) => {
var _tagStyleAdd = new GUIStyle(styleName);
_tagStyleAdd.margin = new RectOffset(0, 0, 0, 0);
_tagStyleAdd.padding = new RectOffset(3, 5, 0, 2);
_tagStyleAdd.alignment = TextAnchor.MiddleCenter;
_tagStyleAdd.stretchWidth = false;
return _tagStyleAdd;
});
var tagsLabel = ME.Utilities.CacheStyle("FlowEditor.DrawTags.Styles", "defaultLabel", (styleName) => {
var _tagsLabel = new GUIStyle(FlowSystemEditorWindow.defaultSkin.label);
_tagsLabel.padding = new RectOffset(_tagsLabel.padding.left, _tagsLabel.padding.right, _tagsLabel.padding.top, _tagsLabel.padding.bottom + 4);
return _tagsLabel;
});
var changed = false;
GUILayout.BeginHorizontal();
{
GUILayoutExt.LabelWithShadow("Tags:", tagsLabel, GUILayout.Width(EditorGUIUtility.labelWidth));
GUILayout.BeginVertical();
{
GUILayout.Space(4f);
var tagCaption = string.Empty;
if (this.showTagsPopupId == window.id) tagCaption = this.tagCaption;
var isEnter = (Event.current.type == EventType.keyDown && Event.current.keyCode == KeyCode.Return);
GUILayout.BeginVertical();
{
GUILayout.BeginHorizontal();
{
var columns = 3;
var i = 0;
foreach (var tag in window.tags) {
if (i % columns == 0) {
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
}
var tagInfo = FlowSystem.GetData().GetTag(tag);
if (tagInfo == null) {
window.tags.Remove(tag);
break;
}
if (GUILayout.Button(tagInfo.title, tagStyles[tagInfo.color]) == true) {
FlowSystem.RemoveTag(window, tagInfo);
break;
}
++i;
//.........这里部分代码省略.........
示例10: SelectWindow
private void SelectWindow(FlowWindow window) {
for (int i = 0; i < window.states.Length; ++i) window.SetCompletedState(i, CompletedState.NotReady);
if (window.compiled == false) {
this.ShowNotification(new GUIContent("You need to compile this window to use `Select` command"));
} else {
if (Directory.Exists(window.compiledDirectory) == false) {
window.compiledDirectory = Path.GetDirectoryName(AssetDatabase.GetAssetPath(FlowSystem.GetData())) + "/" + window.compiledNamespace.Replace(FlowSystem.GetData().namespaceName, string.Empty) + "/" + window.compiledNamespace.Replace(".", "/");
}
Selection.activeObject = AssetDatabase.LoadAssetAtPath(window.compiledDirectory.Trim('/'), typeof(Object));
EditorGUIUtility.PingObject(Selection.activeObject);
//if (window.screen == null) {
window.SetCompletedState(0, CompletedState.NotReady);
var files = AssetDatabase.FindAssets("t:GameObject", new string[] { window.compiledDirectory.Trim('/') + "/Screens" });
foreach (var file in files) {
var path = AssetDatabase.GUIDToAssetPath(file);
var go = AssetDatabase.LoadAssetAtPath(path, typeof(GameObject)) as GameObject;
if (go != null) {
var screen = go.GetComponent<WindowBase>();
if (screen != null) {
window.SetScreen(screen);
window.SetCompletedState(0, CompletedState.Ready);
var lWin = screen as LayoutWindowType;
if (lWin != null) {
if (lWin.layout.layout != null) {
window.SetCompletedState(1, CompletedState.Ready);
window.SetCompletedState(2, (lWin.layout.components.Any((c) => c.component == null) == true) ? CompletedState.ReadyButWarnings : CompletedState.Ready);
} else {
window.SetCompletedState(0, CompletedState.NotReady);
window.SetCompletedState(1, CompletedState.NotReady);
window.SetCompletedState(2, CompletedState.NotReady);
}
} else {
window.SetCompletedState(1, CompletedState.Ready);
}
break;
} else {
window.SetCompletedState(0, CompletedState.ReadyButWarnings);
}
}
}
//}
}
}
示例11: CreateWindow
public FlowWindow CreateWindow(FlowWindow.Flags flags) {
var newId = this.AllocateId();
var window = new FlowWindow(newId, flags);
this.windows.Add(window);
this.windowsCache.Clear();
this.isDirty = true;
return window;
}
示例12: GetWindowSize
public Vector2 GetWindowSize(FlowWindow window) {
var flowWindowWithLayout = FlowSystem.GetData().flowWindowWithLayout;
var flowWindowWithLayoutScaleFactor = FlowSystem.GetData().flowWindowWithLayoutScaleFactor;
if (flowWindowWithLayout == true) {
return new Vector2(250f, 250f) * (1f + flowWindowWithLayoutScaleFactor);
}
return new Vector2(250f, 80f + (Mathf.CeilToInt(window.tags.Count / 3f)) * 15f);
}
示例13: DrawTransitionChooser
public void DrawTransitionChooser(UnityEngine.UI.Windows.Plugins.Flow.FlowWindow.AttachItem attach, FlowWindow fromWindow, FlowWindow toWindow, Vector2 offset, float size) {
var _size = Vector2.one * size;
var rect = new Rect(Vector2.Lerp(fromWindow.rect.center, toWindow.rect.center, 0.5f) + offset - _size * 0.5f, _size);
var transitionStyle = ME.Utilities.CacheStyle("UI.Windows.Styles.DefaultSkin", "TransitionIcon", (name) => FlowSystemEditorWindow.defaultSkin.FindStyle("TransitionIcon"));
var transitionStyleBorder = ME.Utilities.CacheStyle("UI.Windows.Styles.DefaultSkin", "TransitionIconBorder", (name) => FlowSystemEditorWindow.defaultSkin.FindStyle("TransitionIconBorder"));
if (transitionStyle != null && transitionStyleBorder != null) {
if (fromWindow.GetScreen() != null) {
System.Action onClick = () => {
FlowChooserFilter.CreateTransition(fromWindow, toWindow, "/Transitions", (element) => {
FlowSystem.Save();
});
};
// Has transition or not?
var hasTransition = attach.transition != null && attach.transitionParameters != null;
if (hasTransition == true) {
var hovered = rect.Contains(Event.current.mousePosition);
if (attach.editor == null) {
attach.editor = Editor.CreateEditor(attach.transitionParameters) as IPreviewEditor;
hovered = true;
}
if (attach.editor.HasPreviewGUI() == true) {
if (hovered == false) {
attach.editor.OnDisable();
} else {
attach.editor.OnEnable();
}
var style = new GUIStyle(EditorStyles.toolbarButton);
attach.editor.OnPreviewGUI(Color.white, rect, style, false, false, hovered);
}
if (GUI.Button(rect, string.Empty, transitionStyleBorder) == true) {
onClick();
}
} else {
GUI.Box(rect, string.Empty, transitionStyle);
if (GUI.Button(rect, string.Empty, transitionStyleBorder) == true) {
onClick();
}
}
}
}
}
示例14: GetRelativePath
public static string GetRelativePath(FlowWindow window, string token) {
var result = GetParentContainers(window, FlowSystem.GetContainers())
.Reverse()
.Select(w => w.directory)
.Aggregate(string.Empty, (total, path) => total + token + path);
if (string.IsNullOrEmpty(result) == true) {
result = token + FlowDatabase.OTHER_NAME;
}
result += token + window.directory;
return result;
}
示例15: CompiledInfoIsInvalid
/*
private static bool CompiledInfoIsInvalid( FlowWindow flowWindow ) {
return GetBaseClassName( flowWindow ) != flowWindow.compiledBaseClassName
|| GetNamespace( flowWindow ) != flowWindow.compiledNamespace;
}
private static void UpdateInheritedClasses( string oldBaseClassName, string newBaseClassName, string oldDerivedClassName, string newDerivedClassName, string oldNamespace, string newNamespace ) {
if ( string.IsNullOrEmpty( oldBaseClassName ) || string.IsNullOrEmpty( newBaseClassName ) ) {
return;
}
var oldFullClassPath = oldNamespace + oldBaseClassName;
var newFullClassPath = newNamespace + newBaseClassName;
AssetDatabase.StartAssetEditing();
try {
var scripts =
AssetDatabase.FindAssets( "t:MonoScript" )
.Select( _ => AssetDatabase.GUIDToAssetPath( _ ) )
.Select( _ => AssetDatabase.LoadAssetAtPath( _, typeof( MonoScript ) ) )
.OfType<MonoScript>()
.Where( _ => _.text.Contains( oldBaseClassName ) || _.text.Contains( oldDerivedClassName ) || _.text.Contains( oldNamespace ) )
.Where( _ => _.name != newBaseClassName );
foreach ( var each in scripts ) {
var path = AssetDatabase.GetAssetPath( each );
var lines = File.ReadAllLines( path );
var writer = new StreamWriter( path );
foreach ( var line in lines ) {
writer.WriteLine( line.Replace( oldFullClassPath, newFullClassPath )
.Replace( oldNamespace, newNamespace )
.Replace( oldBaseClassName, newBaseClassName )
.Replace( oldDerivedClassName, newDerivedClassName ) );
}
writer.Dispose();
}
} catch ( Exception e ) { Debug.LogException( e ); }
AssetDatabase.StopAssetEditing();
AssetDatabase.Refresh( ImportAssetOptions.ForceUpdate );
}
private static void GenerateUIWindow( string fullpath, FlowWindow window, bool recompile = false ) {
var isCompiledInfoInvalid = window.compiled && CompiledInfoIsInvalid( window );
if ( window.compiled == false || recompile == true || isCompiledInfoInvalid ) {
var baseClassName = GetBaseClassName( window );
var derivedClassName = GetDerivedClassName( window );
var classNamespace = GetNamespace( window );
var baseClassTemplate = FlowTemplateGenerator.GenerateWindowLayoutBaseClass( baseClassName, classNamespace, GenerateTransitionMethods( window ) );
var derivedClassTemplate = FlowTemplateGenerator.GenerateWindowLayoutDerivedClass( derivedClassName, baseClassName, classNamespace );
#if !UNITY_WEBPLAYER
var baseClassPath = ( fullpath + "/" + baseClassName + ".cs" ).Replace( "//", "/" );
var derivedClassPath = ( fullpath + "/" + derivedClassName + ".cs" ).Replace( "//", "/" );
#endif
if ( baseClassTemplate != null && derivedClassTemplate != null ) {
IO.CreateDirectory( fullpath, string.Empty );
IO.CreateDirectory( fullpath, FlowDatabase.COMPONENTS_FOLDER );
IO.CreateDirectory( fullpath, FlowDatabase.LAYOUT_FOLDER );
IO.CreateDirectory( fullpath, FlowDatabase.SCREENS_FOLDER );
#if !UNITY_WEBPLAYER
Directory.CreateDirectory( fullpath );
File.WriteAllText( baseClassPath, baseClassTemplate );
if ( !File.Exists( derivedClassPath ) ) {
File.WriteAllText( derivedClassPath, derivedClassTemplate );
AssetDatabase.ImportAsset( derivedClassName );
}
AssetDatabase.ImportAsset( baseClassPath );
#endif
} else {
return;
}
//.........这里部分代码省略.........