NBC修改
This commit is contained in:
@@ -37,7 +37,6 @@ MonoBehaviour:
|
||||
- Assembly-CSharp-firstpass
|
||||
- ECM2
|
||||
- Enviro3.Runtime
|
||||
- FairyGUI
|
||||
- Ilumisoft.GraphicsControl
|
||||
- Ilumisoft.GraphicsControl.BuiltIn
|
||||
- Ilumisoft.GraphicsControl.UI
|
||||
@@ -48,10 +47,7 @@ MonoBehaviour:
|
||||
- JBooth.MicroVerseCore.Demo.TimeOfDay.Runtime
|
||||
- JBooth.MicroVerseCore.Roads.Demo
|
||||
- KWS2
|
||||
- NBC.Asset
|
||||
- NBC.Core
|
||||
- NBC.Lan
|
||||
- NBC.UI
|
||||
- NBC
|
||||
- Obi
|
||||
- Rowlan.MicroVerse.Presets.Runtime
|
||||
- Rowlan.MicroVerse.Presets_2.Runtime
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d62b02f274ce4253af1ef45831279e3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,329 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using FairyGUI;
|
||||
|
||||
namespace FairyGUIEditor
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(DisplayObjectInfo))]
|
||||
public class DisplayObjectEditor : Editor
|
||||
{
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
bool _guiControllersFoldout = true;
|
||||
bool _guiTransitionsFoldout = true;
|
||||
bool _guiTextFormatFoldout = true;
|
||||
#endif
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
EditorApplication.update += _onEditorAppUpdate;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
EditorApplication.update -= _onEditorAppUpdate;
|
||||
}
|
||||
|
||||
void _onEditorAppUpdate()
|
||||
{
|
||||
Repaint();
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DisplayObject obj = (target as DisplayObjectInfo).displayObject;
|
||||
if (obj == null)
|
||||
return;
|
||||
|
||||
EditorGUILayout.LabelField(obj.GetType().Name + ": " + obj.id, (GUIStyle)"OL Title");
|
||||
EditorGUILayout.Separator();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
string name = EditorGUILayout.TextField("Name", obj.name);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
obj.name = name;
|
||||
if (obj is Container)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
bool fairyBatching = EditorGUILayout.Toggle("FairyBatching", ((Container)obj).fairyBatching);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
((Container)obj).fairyBatching = fairyBatching;
|
||||
}
|
||||
|
||||
GObject gObj = obj.gOwner;
|
||||
if (gObj != null)
|
||||
{
|
||||
EditorGUILayout.Separator();
|
||||
EditorGUILayout.LabelField(gObj.GetType().Name + ": " + gObj.id, (GUIStyle)"OL Title");
|
||||
EditorGUILayout.Separator();
|
||||
|
||||
if (!string.IsNullOrEmpty(gObj.resourceURL))
|
||||
{
|
||||
PackageItem pi = UIPackage.GetItemByURL(gObj.resourceURL);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PrefixLabel("Resource");
|
||||
EditorGUILayout.LabelField(pi.name + "@" + pi.owner.name);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
name = EditorGUILayout.TextField("Name", gObj.name);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
gObj.name = name;
|
||||
|
||||
if (gObj.parent != null)
|
||||
{
|
||||
string[] options = new string[gObj.parent.numChildren];
|
||||
int[] values = new int[options.Length];
|
||||
for (int i = 0; i < options.Length; i++)
|
||||
{
|
||||
options[i] = i.ToString();
|
||||
values[i] = i;
|
||||
}
|
||||
EditorGUI.BeginChangeCheck();
|
||||
int childIndex = EditorGUILayout.IntPopup("Child Index", gObj.parent.GetChildIndex(gObj), options, values);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
gObj.parent.SetChildIndex(gObj, childIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PrefixLabel("Child Index");
|
||||
EditorGUILayout.LabelField("No Parent");
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
float alpha = EditorGUILayout.Slider("Alpha", gObj.alpha, 0, 1);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
gObj.alpha = alpha;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
Vector3 position = EditorGUILayout.Vector3Field("Position", gObj.position);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
gObj.position = position;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
Vector3 rotation = EditorGUILayout.Vector3Field("Rotation", new Vector3(gObj.rotationX, gObj.rotationY, gObj.rotation));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
gObj.rotationX = rotation.x;
|
||||
gObj.rotationY = rotation.y;
|
||||
gObj.rotation = rotation.z;
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
Vector2 scale = EditorGUILayout.Vector2Field("Scale", gObj.scale);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
gObj.scale = scale;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
Vector2 skew = EditorGUILayout.Vector2Field("Skew", gObj.skew);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
gObj.skew = skew;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
Vector2 size = EditorGUILayout.Vector2Field("Size", gObj.size);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
gObj.size = size;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
Vector2 pivot = EditorGUILayout.Vector2Field("Pivot", gObj.pivot);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
gObj.pivot = pivot;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
string text = EditorGUILayout.TextField("Text", gObj.text);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
gObj.text = text;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
string icon = EditorGUILayout.TextField("Icon", gObj.icon);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
gObj.icon = icon;
|
||||
|
||||
//Draw Color Field
|
||||
var objType = gObj.GetType();
|
||||
var colorProperty = objType.GetProperty("color");
|
||||
if (colorProperty != null)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
Color color = (Color)colorProperty.GetValue(gObj);
|
||||
color = EditorGUILayout.ColorField("Color", color);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
colorProperty.SetValue(gObj, color);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
string tooltips = EditorGUILayout.TextField("Tooltips", gObj.tooltips);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
gObj.tooltips = tooltips;
|
||||
|
||||
if (!(gObj is GImage))
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
bool touchable = EditorGUILayout.Toggle("Touchable", gObj.touchable);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
gObj.touchable = touchable;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
bool draggable = EditorGUILayout.Toggle("Draggable", gObj.draggable);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
gObj.draggable = draggable;
|
||||
}
|
||||
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
TextFormat textFormat = null;
|
||||
if (gObj is GTextField gTxt)
|
||||
{
|
||||
textFormat = gTxt.textFormat;
|
||||
}
|
||||
|
||||
if (textFormat != null)
|
||||
{
|
||||
_guiTextFormatFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(_guiTextFormatFoldout, "Text Format");
|
||||
EditorGUI.BeginChangeCheck();
|
||||
if (_guiTextFormatFoldout)
|
||||
{
|
||||
|
||||
var initLabelWidth = EditorGUIUtility.labelWidth;
|
||||
|
||||
var richStyle = new GUIStyle(GUI.skin.label);
|
||||
richStyle.richText = true;
|
||||
EditorGUIUtility.labelWidth = 60;
|
||||
textFormat.font = EditorGUILayout.TextField("Font", textFormat.font);
|
||||
textFormat.align = (AlignType)EditorGUILayout.EnumPopup("Align", textFormat.align);
|
||||
|
||||
EditorGUIUtility.labelWidth = initLabelWidth;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUIUtility.labelWidth = 40;
|
||||
textFormat.size = EditorGUILayout.IntField("Size", textFormat.size);
|
||||
textFormat.color = EditorGUILayout.ColorField("Color", textFormat.color);
|
||||
EditorGUIUtility.labelWidth = initLabelWidth;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUIUtility.labelWidth = 40;
|
||||
textFormat.outline = EditorGUILayout.FloatField("Outline", textFormat.outline);
|
||||
textFormat.outlineColor = EditorGUILayout.ColorField("Color", textFormat.outlineColor);
|
||||
EditorGUIUtility.labelWidth = initLabelWidth;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUIUtility.labelWidth = 50;
|
||||
textFormat.shadowOffset = EditorGUILayout.Vector2Field("Shadow Offset", textFormat.shadowOffset);
|
||||
textFormat.shadowColor = EditorGUILayout.ColorField("Color", textFormat.shadowColor);
|
||||
EditorGUIUtility.labelWidth = initLabelWidth;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
textFormat.italic = EditorGUILayout.ToggleLeft("<i>I</i>", textFormat.italic, richStyle, GUILayout.Width(30));
|
||||
textFormat.bold = EditorGUILayout.ToggleLeft("<b>B</b>", textFormat.bold, richStyle, GUILayout.Width(30));
|
||||
textFormat.underline = EditorGUILayout.ToggleLeft("U̲", textFormat.underline, richStyle, GUILayout.Width(30));
|
||||
textFormat.strikethrough = EditorGUILayout.ToggleLeft(" S̶ ̶ ̶", textFormat.strikethrough, richStyle, GUILayout.Width(36));
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUIUtility.labelWidth = 90;
|
||||
textFormat.lineSpacing = EditorGUILayout.IntField("Line Spacing", textFormat.lineSpacing);
|
||||
textFormat.letterSpacing = EditorGUILayout.IntField("Letter Spacing", textFormat.letterSpacing);
|
||||
EditorGUIUtility.labelWidth = initLabelWidth;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
textFormat.specialStyle = (TextFormat.SpecialStyle)EditorGUILayout.EnumPopup("Special Style", textFormat.specialStyle);
|
||||
|
||||
}
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
gObj.asTextField.textFormat = textFormat;
|
||||
|
||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||
}
|
||||
|
||||
if (gObj is GComponent gComp)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
bool opaque = EditorGUILayout.Toggle("Opaque", gComp.opaque);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
gComp.opaque = opaque;
|
||||
|
||||
var headerLabelStyle = new GUIStyle(GUI.skin.label);
|
||||
headerLabelStyle.fontStyle = FontStyle.Bold;
|
||||
|
||||
if (gComp.Controllers.Count > 0)
|
||||
{
|
||||
_guiControllersFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(_guiControllersFoldout, "Controllers");
|
||||
if (_guiControllersFoldout)
|
||||
{
|
||||
foreach (var ctl in gComp.Controllers)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField(ctl.name, headerLabelStyle, GUILayout.MaxWidth(ctl.name.Length * 15));
|
||||
|
||||
for (var i = 0; i < ctl.pageCount; i++)
|
||||
{
|
||||
var btnName = ctl.GetPageId(i) + ": " + ctl.GetPageName(i);
|
||||
var btnStyle = new GUIStyle("ButtonMid");
|
||||
if (ctl.selectedIndex == i)
|
||||
{
|
||||
btnStyle.normal.textColor = Color.green;
|
||||
btnStyle.hover.textColor = Color.yellow;
|
||||
btnStyle.fontStyle = FontStyle.Bold;
|
||||
}
|
||||
if (GUILayout.Button(btnName, btnStyle))
|
||||
{
|
||||
ctl.selectedIndex = i;
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||
}
|
||||
|
||||
if (gComp.Transitions.Count > 0)
|
||||
{
|
||||
_guiTransitionsFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(_guiTransitionsFoldout, "Transitions");
|
||||
if (_guiTransitionsFoldout)
|
||||
{
|
||||
foreach (var transition in gComp.Transitions)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
var labelStyle = new GUIStyle(headerLabelStyle);
|
||||
if (transition.playing)
|
||||
{
|
||||
labelStyle.normal.textColor = Color.yellow;
|
||||
}
|
||||
|
||||
EditorGUILayout.LabelField($"{transition.name} - {transition.totalDuration}s", labelStyle, GUILayout.MinWidth(150));
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var timeScale = transition.timeScale;
|
||||
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
transition.timeScale = timeScale;
|
||||
|
||||
|
||||
if (GUILayout.Button("▶", GUILayout.Width(20)))
|
||||
{
|
||||
transition.Play();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("■", GUILayout.Width(20)))
|
||||
{
|
||||
transition.Stop();
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2f78faa29e5e1547837f976bf4b39f2
|
||||
timeCreated: 1541149029
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,142 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using FairyGUI;
|
||||
|
||||
namespace FairyGUIEditor
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class EditorToolSet
|
||||
{
|
||||
public static GUIContent[] packagesPopupContents;
|
||||
|
||||
static bool _loaded;
|
||||
|
||||
[InitializeOnLoadMethod]
|
||||
static void Startup()
|
||||
{
|
||||
EditorApplication.update += EditorApplication_Update;
|
||||
}
|
||||
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
static void InitializeOnLoad()
|
||||
{
|
||||
_loaded = false;
|
||||
}
|
||||
|
||||
[MenuItem("GameObject/FairyGUI/UI Panel", false, 0)]
|
||||
static void CreatePanel()
|
||||
{
|
||||
EditorApplication.update -= EditorApplication_Update;
|
||||
EditorApplication.update += EditorApplication_Update;
|
||||
|
||||
StageCamera.CheckMainCamera();
|
||||
|
||||
GameObject panelObject = new GameObject("UIPanel");
|
||||
if (Selection.activeGameObject != null)
|
||||
{
|
||||
panelObject.transform.parent = Selection.activeGameObject.transform;
|
||||
panelObject.layer = Selection.activeGameObject.layer;
|
||||
}
|
||||
else
|
||||
{
|
||||
int layer = LayerMask.NameToLayer(StageCamera.LayerName);
|
||||
panelObject.layer = layer;
|
||||
}
|
||||
panelObject.AddComponent<FairyGUI.UIPanel>();
|
||||
Selection.objects = new Object[] { panelObject };
|
||||
}
|
||||
|
||||
[MenuItem("GameObject/FairyGUI/UI Camera", false, 0)]
|
||||
static void CreateCamera()
|
||||
{
|
||||
StageCamera.CheckMainCamera();
|
||||
Selection.objects = new Object[] { StageCamera.main.gameObject };
|
||||
}
|
||||
|
||||
[MenuItem("Window/FairyGUI - Refresh Packages And Panels")]
|
||||
static void RefreshPanels()
|
||||
{
|
||||
ReloadPackages();
|
||||
}
|
||||
|
||||
static void EditorApplication_Update()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
return;
|
||||
|
||||
if (_loaded || !EMRenderSupport.hasTarget)
|
||||
return;
|
||||
|
||||
LoadPackages();
|
||||
}
|
||||
|
||||
public static void ReloadPackages()
|
||||
{
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
_loaded = false;
|
||||
LoadPackages();
|
||||
Debug.Log("FairyGUI - Refresh Packages And Panels complete.");
|
||||
}
|
||||
else
|
||||
EditorUtility.DisplayDialog("FairyGUI", "Cannot run in play mode.", "OK");
|
||||
}
|
||||
|
||||
public static void LoadPackages()
|
||||
{
|
||||
if (Application.isPlaying || _loaded)
|
||||
return;
|
||||
|
||||
EditorApplication.update -= EditorApplication_Update;
|
||||
EditorApplication.update += EditorApplication_Update;
|
||||
|
||||
_loaded = true;
|
||||
|
||||
UIPackage.RemoveAllPackages();
|
||||
UIPackage.branch = null;
|
||||
FontManager.Clear();
|
||||
NTexture.DisposeEmpty();
|
||||
UIObjectFactory.Clear();
|
||||
|
||||
string[] ids = AssetDatabase.FindAssets("_fui t:textAsset");
|
||||
int cnt = ids.Length;
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(ids[i]);
|
||||
int pos = assetPath.LastIndexOf("_fui");
|
||||
if (pos == -1)
|
||||
continue;
|
||||
|
||||
assetPath = assetPath.Substring(0, pos);
|
||||
if (AssetDatabase.AssetPathToGUID(assetPath) != null)
|
||||
UIPackage.AddPackage(assetPath,
|
||||
(string name, string extension, System.Type type, out DestroyMethod destroyMethod) =>
|
||||
{
|
||||
destroyMethod = DestroyMethod.Unload;
|
||||
return AssetDatabase.LoadAssetAtPath(name + extension, type);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
List<UIPackage> pkgs = UIPackage.GetPackages();
|
||||
pkgs.Sort(CompareUIPackage);
|
||||
|
||||
cnt = pkgs.Count;
|
||||
packagesPopupContents = new GUIContent[cnt + 1];
|
||||
for (int i = 0; i < cnt; i++)
|
||||
packagesPopupContents[i] = new GUIContent(pkgs[i].name);
|
||||
packagesPopupContents[cnt] = new GUIContent("Please Select");
|
||||
|
||||
EMRenderSupport.Reload();
|
||||
}
|
||||
|
||||
static int CompareUIPackage(UIPackage u1, UIPackage u2)
|
||||
{
|
||||
return u1.name.CompareTo(u2.name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35dcb233f95ffd54c94f09d731db89ae
|
||||
timeCreated: 1535374214
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "FairyGUI-Editor",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"FairyGUI"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f11907887f480418c8c693a619e2dbf0
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,193 +0,0 @@
|
||||
using FairyGUI;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using System.Collections.Generic;
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
using UnityEditor.Experimental.SceneManagement;
|
||||
#endif
|
||||
|
||||
namespace FairyGUIEditor
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class PackagesWindow : EditorWindow
|
||||
{
|
||||
Vector2 scrollPos1;
|
||||
Vector2 scrollPos2;
|
||||
GUIStyle itemStyle;
|
||||
|
||||
int selectedPackage;
|
||||
string selectedPackageName;
|
||||
string selectedComponentName;
|
||||
|
||||
public PackagesWindow()
|
||||
{
|
||||
this.maxSize = new Vector2(550, 400);
|
||||
this.minSize = new Vector2(550, 400);
|
||||
}
|
||||
|
||||
public void SetSelection(string packageName, string componentName)
|
||||
{
|
||||
selectedPackageName = packageName;
|
||||
selectedComponentName = componentName;
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
if (itemStyle == null)
|
||||
itemStyle = new GUIStyle(GUI.skin.GetStyle("Tag MenuItem"));
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
//package list start------
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.Space(5);
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
GUILayout.Space(10);
|
||||
|
||||
EditorGUILayout.LabelField("Packages", (GUIStyle)"OL Title", GUILayout.Width(300));
|
||||
GUILayout.Space(5);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.Space(4);
|
||||
|
||||
scrollPos1 = EditorGUILayout.BeginScrollView(scrollPos1, (GUIStyle)"CN Box", GUILayout.Height(300), GUILayout.Width(300));
|
||||
EditorToolSet.LoadPackages();
|
||||
List<UIPackage> pkgs = UIPackage.GetPackages();
|
||||
int cnt = pkgs.Count;
|
||||
if (cnt == 0)
|
||||
{
|
||||
selectedPackage = -1;
|
||||
selectedPackageName = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Toggle(selectedPackageName == pkgs[i].name, pkgs[i].name, itemStyle, GUILayout.ExpandWidth(true)))
|
||||
{
|
||||
selectedPackage = i;
|
||||
selectedPackageName = pkgs[i].name;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndScrollView();
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
//package list end------
|
||||
|
||||
//component list start------
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.Space(5);
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
GUILayout.Space(10);
|
||||
|
||||
EditorGUILayout.LabelField("Components", (GUIStyle)"OL Title", GUILayout.Width(220));
|
||||
GUILayout.Space(5);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.Space(4);
|
||||
|
||||
scrollPos2 = EditorGUILayout.BeginScrollView(scrollPos2, (GUIStyle)"CN Box", GUILayout.Height(300), GUILayout.Width(220));
|
||||
if (selectedPackage >= 0)
|
||||
{
|
||||
List<PackageItem> items = pkgs[selectedPackage].GetItems();
|
||||
int i = 0;
|
||||
foreach (PackageItem pi in items)
|
||||
{
|
||||
if (pi.type == PackageItemType.Component && pi.exported)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Toggle(selectedComponentName == pi.name, pi.name, itemStyle, GUILayout.ExpandWidth(true)))
|
||||
selectedComponentName = pi.name;
|
||||
i++;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndScrollView();
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
//component list end------
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space(20);
|
||||
|
||||
//buttons start---
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
GUILayout.Space(180);
|
||||
|
||||
if (GUILayout.Button("Refresh", GUILayout.Width(100)))
|
||||
EditorToolSet.ReloadPackages();
|
||||
|
||||
GUILayout.Space(20);
|
||||
if (GUILayout.Button("OK", GUILayout.Width(100)) && selectedPackage >= 0)
|
||||
{
|
||||
UIPackage selectedPkg = pkgs[selectedPackage];
|
||||
string tmp = selectedPkg.assetPath.ToLower();
|
||||
string packagePath;
|
||||
int pos = tmp.LastIndexOf("/resources/");
|
||||
if (pos != -1)
|
||||
packagePath = selectedPkg.assetPath.Substring(pos + 11);
|
||||
else
|
||||
{
|
||||
pos = tmp.IndexOf("resources/");
|
||||
if (pos == 0)
|
||||
packagePath = selectedPkg.assetPath.Substring(pos + 10);
|
||||
else
|
||||
packagePath = selectedPkg.assetPath;
|
||||
}
|
||||
if (Selection.activeGameObject != null)
|
||||
{
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
bool isPrefab = PrefabUtility.GetPrefabAssetType(Selection.activeGameObject) != PrefabAssetType.NotAPrefab;
|
||||
#else
|
||||
bool isPrefab = PrefabUtility.GetPrefabType(Selection.activeGameObject) == PrefabType.Prefab;
|
||||
#endif
|
||||
Selection.activeGameObject.SendMessage("OnUpdateSource",
|
||||
new object[] { selectedPkg.name, packagePath, selectedComponentName, !isPrefab },
|
||||
SendMessageOptions.DontRequireReceiver);
|
||||
}
|
||||
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
PrefabStage prefabStage = PrefabStageUtility.GetCurrentPrefabStage();
|
||||
if (prefabStage != null)
|
||||
EditorSceneManager.MarkSceneDirty(prefabStage.scene);
|
||||
else
|
||||
ApplyChange();
|
||||
#else
|
||||
ApplyChange();
|
||||
#endif
|
||||
this.Close();
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
void ApplyChange()
|
||||
{
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83ed477a96af9c94f9f2ccc24b5a24c0
|
||||
timeCreated: 1535374214
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,29 +0,0 @@
|
||||
using UnityEditor;
|
||||
using FairyGUI;
|
||||
|
||||
namespace FairyGUIEditor
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(StageCamera))]
|
||||
public class StageCameraEditor : Editor
|
||||
{
|
||||
string[] propertyToExclude;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
propertyToExclude = new string[] { "m_Script" };
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
DrawPropertiesExcluding(serializedObject, propertyToExclude);
|
||||
|
||||
if (serializedObject.ApplyModifiedProperties())
|
||||
(target as StageCamera).ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b99582678b83dc46986b02984c665a3
|
||||
timeCreated: 1460480287
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,226 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using FairyGUI;
|
||||
|
||||
namespace FairyGUIEditor
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UIConfig))]
|
||||
public class UIConfigEditor : Editor
|
||||
{
|
||||
string[] propertyToExclude;
|
||||
bool itemsFoldout;
|
||||
bool packagesFoldOut;
|
||||
int errorState;
|
||||
|
||||
private const float kButtonWidth = 18f;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
propertyToExclude = new string[] { "m_Script", "Items", "PreloadPackages" };
|
||||
|
||||
itemsFoldout = EditorPrefs.GetBool("itemsFoldOut");
|
||||
packagesFoldOut = EditorPrefs.GetBool("packagesFoldOut");
|
||||
errorState = 0;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
DrawPropertiesExcluding(serializedObject, propertyToExclude);
|
||||
|
||||
UIConfig config = (UIConfig)target;
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
itemsFoldout = EditorGUILayout.Foldout(itemsFoldout, "Config Items");
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
EditorPrefs.SetBool("itemsFoldOut", itemsFoldout);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
bool modified = false;
|
||||
|
||||
if (itemsFoldout)
|
||||
{
|
||||
Undo.RecordObject(config, "Items");
|
||||
|
||||
int len = config.Items.Count;
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PrefixLabel("Add");
|
||||
UIConfig.ConfigKey selectedKey = (UIConfig.ConfigKey)EditorGUILayout.EnumPopup((System.Enum)UIConfig.ConfigKey.PleaseSelect);
|
||||
|
||||
if (selectedKey != UIConfig.ConfigKey.PleaseSelect)
|
||||
{
|
||||
int index = (int)selectedKey;
|
||||
|
||||
if (index > len - 1)
|
||||
{
|
||||
for (int i = len; i < index; i++)
|
||||
config.Items.Add(new UIConfig.ConfigValue());
|
||||
|
||||
UIConfig.ConfigValue value = new UIConfig.ConfigValue();
|
||||
value.valid = true;
|
||||
UIConfig.SetDefaultValue(selectedKey, value);
|
||||
config.Items.Add(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
UIConfig.ConfigValue value = config.Items[index];
|
||||
if (value == null)
|
||||
{
|
||||
value = new UIConfig.ConfigValue();
|
||||
value.valid = true;
|
||||
UIConfig.SetDefaultValue(selectedKey, value);
|
||||
config.Items[index] = value;
|
||||
}
|
||||
else if (!value.valid)
|
||||
{
|
||||
value.valid = true;
|
||||
UIConfig.SetDefaultValue(selectedKey, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
UIConfig.ConfigValue value = config.Items[i];
|
||||
if (value == null || !value.valid)
|
||||
continue;
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PrefixLabel(((UIConfig.ConfigKey)i).ToString());
|
||||
switch ((UIConfig.ConfigKey)i)
|
||||
{
|
||||
case UIConfig.ConfigKey.ClickDragSensitivity:
|
||||
case UIConfig.ConfigKey.DefaultComboBoxVisibleItemCount:
|
||||
case UIConfig.ConfigKey.DefaultScrollStep:
|
||||
case UIConfig.ConfigKey.TouchDragSensitivity:
|
||||
case UIConfig.ConfigKey.TouchScrollSensitivity:
|
||||
case UIConfig.ConfigKey.InputCaretSize:
|
||||
value.i = EditorGUILayout.IntField(value.i);
|
||||
break;
|
||||
|
||||
case UIConfig.ConfigKey.ButtonSound:
|
||||
case UIConfig.ConfigKey.GlobalModalWaiting:
|
||||
case UIConfig.ConfigKey.HorizontalScrollBar:
|
||||
case UIConfig.ConfigKey.LoaderErrorSign:
|
||||
case UIConfig.ConfigKey.PopupMenu:
|
||||
case UIConfig.ConfigKey.PopupMenu_seperator:
|
||||
case UIConfig.ConfigKey.TooltipsWin:
|
||||
case UIConfig.ConfigKey.VerticalScrollBar:
|
||||
case UIConfig.ConfigKey.WindowModalWaiting:
|
||||
case UIConfig.ConfigKey.DefaultFont:
|
||||
value.s = EditorGUILayout.TextField(value.s);
|
||||
break;
|
||||
|
||||
case UIConfig.ConfigKey.DefaultScrollBounceEffect:
|
||||
case UIConfig.ConfigKey.DefaultScrollTouchEffect:
|
||||
case UIConfig.ConfigKey.RenderingTextBrighterOnDesktop:
|
||||
case UIConfig.ConfigKey.AllowSoftnessOnTopOrLeftSide:
|
||||
case UIConfig.ConfigKey.DepthSupportForPaintingMode:
|
||||
value.b = EditorGUILayout.Toggle(value.b);
|
||||
break;
|
||||
|
||||
case UIConfig.ConfigKey.ButtonSoundVolumeScale:
|
||||
value.f = EditorGUILayout.Slider(value.f, 0, 1);
|
||||
break;
|
||||
|
||||
case UIConfig.ConfigKey.ModalLayerColor:
|
||||
case UIConfig.ConfigKey.InputHighlightColor:
|
||||
value.c = EditorGUILayout.ColorField(value.c);
|
||||
break;
|
||||
|
||||
case UIConfig.ConfigKey.Branch:
|
||||
EditorGUI.BeginChangeCheck();
|
||||
value.s = EditorGUILayout.TextField(value.s);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
modified = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (GUILayout.Button(new GUIContent("X", "Delete Item"), EditorStyles.miniButtonRight, GUILayout.Width(30)))
|
||||
{
|
||||
config.Items[i].Reset();
|
||||
UIConfig.SetDefaultValue((UIConfig.ConfigKey)i, config.Items[i]);
|
||||
modified = true;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
packagesFoldOut = EditorGUILayout.Foldout(packagesFoldOut, "Preload Packages");
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
EditorPrefs.SetBool("packagesFoldOut", packagesFoldOut);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (packagesFoldOut)
|
||||
{
|
||||
Undo.RecordObject(config, "PreloadPackages");
|
||||
|
||||
EditorToolSet.LoadPackages();
|
||||
|
||||
if (EditorToolSet.packagesPopupContents != null)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PrefixLabel("Add");
|
||||
int selected = EditorGUILayout.Popup(EditorToolSet.packagesPopupContents.Length - 1, EditorToolSet.packagesPopupContents);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (selected != EditorToolSet.packagesPopupContents.Length - 1)
|
||||
{
|
||||
UIPackage pkg = UIPackage.GetPackages()[selected];
|
||||
string tmp = pkg.assetPath.ToLower();
|
||||
int pos = tmp.LastIndexOf("resources/");
|
||||
if (pos != -1)
|
||||
{
|
||||
string packagePath = pkg.assetPath.Substring(pos + 10);
|
||||
if (config.PreloadPackages.IndexOf(packagePath) == -1)
|
||||
config.PreloadPackages.Add(packagePath);
|
||||
|
||||
errorState = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorState = 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (errorState > 0)
|
||||
{
|
||||
errorState--;
|
||||
EditorGUILayout.HelpBox("Package is not in resources folder.", MessageType.Warning);
|
||||
}
|
||||
|
||||
int cnt = config.PreloadPackages.Count;
|
||||
int pi = 0;
|
||||
while (pi < cnt)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PrefixLabel("" + pi + ".");
|
||||
config.PreloadPackages[pi] = EditorGUILayout.TextField(config.PreloadPackages[pi]);
|
||||
if (GUILayout.Button(new GUIContent("X", "Delete Item"), EditorStyles.miniButtonRight, GUILayout.Width(30)))
|
||||
{
|
||||
config.PreloadPackages.RemoveAt(pi);
|
||||
cnt--;
|
||||
}
|
||||
else
|
||||
pi++;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
else
|
||||
errorState = 0;
|
||||
|
||||
if (serializedObject.ApplyModifiedProperties() || modified)
|
||||
(target as UIConfig).ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74df68b10ee56a54a8105d88312571ce
|
||||
timeCreated: 1460480288
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,64 +0,0 @@
|
||||
using UnityEditor;
|
||||
using FairyGUI;
|
||||
|
||||
namespace FairyGUIEditor
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UIContentScaler))]
|
||||
public class UIContentScalerEditor : Editor
|
||||
{
|
||||
SerializedProperty scaleMode;
|
||||
SerializedProperty screenMatchMode;
|
||||
SerializedProperty designResolutionX;
|
||||
SerializedProperty designResolutionY;
|
||||
SerializedProperty fallbackScreenDPI;
|
||||
SerializedProperty defaultSpriteDPI;
|
||||
SerializedProperty constantScaleFactor;
|
||||
SerializedProperty ignoreOrientation;
|
||||
|
||||
string[] propertyToExclude;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
scaleMode = serializedObject.FindProperty("scaleMode");
|
||||
screenMatchMode = serializedObject.FindProperty("screenMatchMode");
|
||||
designResolutionX = serializedObject.FindProperty("designResolutionX");
|
||||
designResolutionY = serializedObject.FindProperty("designResolutionY");
|
||||
fallbackScreenDPI = serializedObject.FindProperty("fallbackScreenDPI");
|
||||
defaultSpriteDPI = serializedObject.FindProperty("defaultSpriteDPI");
|
||||
constantScaleFactor = serializedObject.FindProperty("constantScaleFactor");
|
||||
ignoreOrientation = serializedObject.FindProperty("ignoreOrientation");
|
||||
|
||||
propertyToExclude = new string[] { "m_Script", "scaleMode", "screenMatchMode", "designResolutionX", "designResolutionY",
|
||||
"fallbackScreenDPI", "defaultSpriteDPI", "constantScaleFactor", "ignoreOrientation"};
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
DrawPropertiesExcluding(serializedObject, propertyToExclude);
|
||||
|
||||
EditorGUILayout.PropertyField(scaleMode);
|
||||
if ((UIContentScaler.ScaleMode)scaleMode.enumValueIndex == UIContentScaler.ScaleMode.ScaleWithScreenSize)
|
||||
{
|
||||
EditorGUILayout.PropertyField(designResolutionX);
|
||||
EditorGUILayout.PropertyField(designResolutionY);
|
||||
EditorGUILayout.PropertyField(screenMatchMode);
|
||||
EditorGUILayout.PropertyField(ignoreOrientation);
|
||||
}
|
||||
else if ((UIContentScaler.ScaleMode)scaleMode.enumValueIndex == UIContentScaler.ScaleMode.ConstantPhysicalSize)
|
||||
{
|
||||
EditorGUILayout.PropertyField(fallbackScreenDPI);
|
||||
EditorGUILayout.PropertyField(defaultSpriteDPI);
|
||||
}
|
||||
else
|
||||
EditorGUILayout.PropertyField(constantScaleFactor);
|
||||
|
||||
if (serializedObject.ApplyModifiedProperties())
|
||||
(target as UIContentScaler).ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69174d19fa9521b4283e0b8f0e85acc8
|
||||
timeCreated: 1460480288
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,88 +0,0 @@
|
||||
using FairyGUI;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
namespace FairyGUIEditor
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UIPainter))]
|
||||
public class UIPainterEditor : Editor
|
||||
{
|
||||
SerializedProperty packageName;
|
||||
SerializedProperty componentName;
|
||||
SerializedProperty renderCamera;
|
||||
SerializedProperty fairyBatching;
|
||||
SerializedProperty touchDisabled;
|
||||
SerializedProperty sortingOrder;
|
||||
|
||||
string[] propertyToExclude;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
packageName = serializedObject.FindProperty("packageName");
|
||||
componentName = serializedObject.FindProperty("componentName");
|
||||
renderCamera = serializedObject.FindProperty("renderCamera");
|
||||
fairyBatching = serializedObject.FindProperty("fairyBatching");
|
||||
touchDisabled = serializedObject.FindProperty("touchDisabled");
|
||||
sortingOrder = serializedObject.FindProperty("sortingOrder");
|
||||
|
||||
propertyToExclude = new string[] { "m_Script", "packageName", "componentName", "packagePath",
|
||||
"renderCamera", "fairyBatching", "touchDisabled","sortingOrder"
|
||||
};
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
UIPainter panel = target as UIPainter;
|
||||
|
||||
DrawPropertiesExcluding(serializedObject, propertyToExclude);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PrefixLabel("Package Name");
|
||||
if (GUILayout.Button(packageName.stringValue, "ObjectField"))
|
||||
EditorWindow.GetWindow<PackagesWindow>(true, "Select a UI Component").SetSelection(packageName.stringValue, componentName.stringValue);
|
||||
|
||||
if (GUILayout.Button("Clear", GUILayout.Width(50)))
|
||||
{
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
bool isPrefab = PrefabUtility.GetPrefabAssetType(panel) != PrefabAssetType.NotAPrefab;
|
||||
#else
|
||||
bool isPrefab = PrefabUtility.GetPrefabType(panel) == PrefabType.Prefab;
|
||||
#endif
|
||||
panel.SendMessage("OnUpdateSource", new object[] { null, null, null, !isPrefab });
|
||||
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PrefixLabel("Component Name");
|
||||
if (GUILayout.Button(componentName.stringValue, "ObjectField"))
|
||||
EditorWindow.GetWindow<PackagesWindow>(true, "Select a UI Component").SetSelection(packageName.stringValue, componentName.stringValue);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
int oldSortingOrder = panel.sortingOrder;
|
||||
EditorGUILayout.PropertyField(sortingOrder);
|
||||
EditorGUILayout.PropertyField(renderCamera);
|
||||
EditorGUILayout.PropertyField(fairyBatching);
|
||||
EditorGUILayout.PropertyField(touchDisabled);
|
||||
|
||||
if (serializedObject.ApplyModifiedProperties())
|
||||
{
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
bool isPrefab = PrefabUtility.GetPrefabAssetType(panel) != PrefabAssetType.NotAPrefab;
|
||||
#else
|
||||
bool isPrefab = PrefabUtility.GetPrefabType(panel) == PrefabType.Prefab;
|
||||
#endif
|
||||
if (!isPrefab)
|
||||
{
|
||||
panel.ApplyModifiedProperties(sortingOrder.intValue != oldSortingOrder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5cb0f73c030157845aaa7b42a2b8d577
|
||||
timeCreated: 1461566835
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,157 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
namespace FairyGUIEditor
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(FairyGUI.UIPanel))]
|
||||
public class UIPanelEditor : Editor
|
||||
{
|
||||
SerializedProperty packageName;
|
||||
SerializedProperty componentName;
|
||||
SerializedProperty packagePath;
|
||||
SerializedProperty renderMode;
|
||||
SerializedProperty renderCamera;
|
||||
SerializedProperty sortingOrder;
|
||||
SerializedProperty position;
|
||||
SerializedProperty scale;
|
||||
SerializedProperty rotation;
|
||||
SerializedProperty fairyBatching;
|
||||
SerializedProperty fitScreen;
|
||||
SerializedProperty touchDisabled;
|
||||
SerializedProperty hitTestMode;
|
||||
SerializedProperty setNativeChildrenOrder;
|
||||
|
||||
string[] propertyToExclude;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
packageName = serializedObject.FindProperty("packageName");
|
||||
componentName = serializedObject.FindProperty("componentName");
|
||||
packagePath = serializedObject.FindProperty("packagePath");
|
||||
renderMode = serializedObject.FindProperty("renderMode");
|
||||
renderCamera = serializedObject.FindProperty("renderCamera");
|
||||
sortingOrder = serializedObject.FindProperty("sortingOrder");
|
||||
position = serializedObject.FindProperty("position");
|
||||
scale = serializedObject.FindProperty("scale");
|
||||
rotation = serializedObject.FindProperty("rotation");
|
||||
fairyBatching = serializedObject.FindProperty("fairyBatching");
|
||||
fitScreen = serializedObject.FindProperty("fitScreen");
|
||||
touchDisabled = serializedObject.FindProperty("touchDisabled");
|
||||
hitTestMode = serializedObject.FindProperty("hitTestMode");
|
||||
setNativeChildrenOrder = serializedObject.FindProperty("setNativeChildrenOrder");
|
||||
|
||||
|
||||
propertyToExclude = new string[] { "m_Script", "packageName", "componentName", "packagePath", "renderMode",
|
||||
"renderCamera", "sortingOrder", "position", "scale", "rotation", "fairyBatching", "fitScreen","touchDisabled",
|
||||
"hitTestMode","cachedUISize","setNativeChildrenOrder"
|
||||
};
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
FairyGUI.UIPanel panel = target as FairyGUI.UIPanel;
|
||||
|
||||
DrawPropertiesExcluding(serializedObject, propertyToExclude);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PrefixLabel("Package Name");
|
||||
if (GUILayout.Button(packageName.stringValue, "ObjectField"))
|
||||
EditorWindow.GetWindow<PackagesWindow>(true, "Select a UI Component").SetSelection(packageName.stringValue, componentName.stringValue);
|
||||
|
||||
if (GUILayout.Button("Clear", GUILayout.Width(50)))
|
||||
{
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
bool isPrefab = PrefabUtility.GetPrefabAssetType(panel) != PrefabAssetType.NotAPrefab;
|
||||
#else
|
||||
bool isPrefab = PrefabUtility.GetPrefabType(panel) == PrefabType.Prefab;
|
||||
#endif
|
||||
panel.SendMessage("OnUpdateSource", new object[] { null, null, null, !isPrefab });
|
||||
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PrefixLabel("Component Name");
|
||||
if (GUILayout.Button(componentName.stringValue, "ObjectField"))
|
||||
EditorWindow.GetWindow<PackagesWindow>(true, "Select a UI Component").SetSelection(packageName.stringValue, componentName.stringValue);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PrefixLabel("Package Path");
|
||||
EditorGUILayout.LabelField(packagePath.stringValue, (GUIStyle)"helpbox");
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (Application.isPlaying)
|
||||
EditorGUILayout.EnumPopup("Render Mode", panel.container.renderMode);
|
||||
else
|
||||
EditorGUILayout.PropertyField(renderMode);
|
||||
if ((RenderMode)renderMode.enumValueIndex != RenderMode.ScreenSpaceOverlay)
|
||||
EditorGUILayout.PropertyField(renderCamera);
|
||||
|
||||
int oldSortingOrder = panel.sortingOrder;
|
||||
EditorGUILayout.PropertyField(sortingOrder);
|
||||
EditorGUILayout.PropertyField(fairyBatching);
|
||||
EditorGUILayout.PropertyField(hitTestMode);
|
||||
EditorGUILayout.PropertyField(touchDisabled);
|
||||
EditorGUILayout.PropertyField(setNativeChildrenOrder);
|
||||
EditorGUILayout.Separator();
|
||||
EditorGUILayout.LabelField("UI Transform", (GUIStyle)"OL Title");
|
||||
EditorGUILayout.Separator();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(position);
|
||||
EditorGUILayout.PropertyField(rotation);
|
||||
EditorGUILayout.PropertyField(scale);
|
||||
EditorGUILayout.Space();
|
||||
|
||||
FairyGUI.FitScreen oldFitScreen = (FairyGUI.FitScreen)fitScreen.enumValueIndex;
|
||||
EditorGUILayout.PropertyField(fitScreen);
|
||||
|
||||
if (serializedObject.ApplyModifiedProperties())
|
||||
{
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
bool isPrefab = PrefabUtility.GetPrefabAssetType(panel) != PrefabAssetType.NotAPrefab;
|
||||
#else
|
||||
bool isPrefab = PrefabUtility.GetPrefabType(panel) == PrefabType.Prefab;
|
||||
#endif
|
||||
if (!isPrefab)
|
||||
{
|
||||
panel.ApplyModifiedProperties(sortingOrder.intValue != oldSortingOrder, (FairyGUI.FitScreen)fitScreen.enumValueIndex != oldFitScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnSceneGUI()
|
||||
{
|
||||
FairyGUI.UIPanel panel = (target as FairyGUI.UIPanel);
|
||||
if (panel.container == null)
|
||||
return;
|
||||
|
||||
Vector3 pos = panel.GetUIWorldPosition();
|
||||
float sizeFactor = HandleUtility.GetHandleSize(pos);
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
Vector3 newPos = Handles.FreeMoveHandle(pos, sizeFactor, Vector3.one, Handles.ArrowHandleCap);
|
||||
#elif UNITY_2017_1_OR_NEWER
|
||||
Vector3 newPos = Handles.FreeMoveHandle(pos, Quaternion.identity, sizeFactor, Vector3.one, Handles.ArrowHandleCap);
|
||||
#else
|
||||
Vector3 newPos = Handles.FreeMoveHandle(pos, Quaternion.identity, sizeFactor, Vector3.one, Handles.ArrowCap);
|
||||
#endif
|
||||
if (newPos != pos)
|
||||
{
|
||||
Vector2 v1 = HandleUtility.WorldToGUIPoint(pos);
|
||||
Vector2 v2 = HandleUtility.WorldToGUIPoint(newPos);
|
||||
Vector3 delta = v2 - v1;
|
||||
delta.x = (int)delta.x;
|
||||
delta.y = (int)delta.y;
|
||||
|
||||
panel.MoveUI(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94949994c6eda08448145f618d0db72f
|
||||
timeCreated: 1535374215
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd0c51d2146977c4aa7ab34e712a863d
|
||||
folderAsset: yes
|
||||
timeCreated: 1446193142
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 458c4ffa8748140419a56ce3d93de74a
|
||||
folderAsset: yes
|
||||
timeCreated: 1446625368
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,36 +0,0 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
/// <summary>
|
||||
/// A game bag demo, demonstrated how to customize loader to load icons not in the UI package.
|
||||
/// </summary>
|
||||
public class BagMain : MonoBehaviour
|
||||
{
|
||||
GComponent _mainView;
|
||||
BagWindow _bagWindow;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
//Register custom loader class
|
||||
UIObjectFactory.SetLoaderExtension(typeof(MyGLoader));
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
GRoot.inst.SetContentScaleFactor(1136, 640);
|
||||
_mainView = this.GetComponent<UIPanel>().ui;
|
||||
|
||||
_bagWindow = new BagWindow();
|
||||
_mainView.GetChild("bagBtn").onClick.Add(() => { _bagWindow.Show(); });
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72adad54c37cc25499988e9b785d5b90
|
||||
timeCreated: 1446194671
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,49 +0,0 @@
|
||||
using FairyGUI;
|
||||
using UnityEngine;
|
||||
|
||||
public class BagWindow : Window
|
||||
{
|
||||
GList _list;
|
||||
|
||||
public BagWindow()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.contentPane = UIPackage.CreateObject("Bag", "BagWin").asCom;
|
||||
this.Center();
|
||||
this.modal = true;
|
||||
|
||||
_list = this.contentPane.GetChild("list").asList;
|
||||
_list.onClickItem.Add(__clickItem);
|
||||
_list.itemRenderer = RenderListItem;
|
||||
_list.numItems = 45;
|
||||
}
|
||||
|
||||
void RenderListItem(int index, GObject obj)
|
||||
{
|
||||
GButton button = (GButton)obj;
|
||||
button.icon = "i" + UnityEngine.Random.Range(0, 10);
|
||||
button.title = "" + UnityEngine.Random.Range(0, 100);
|
||||
}
|
||||
|
||||
override protected void DoShowAnimation()
|
||||
{
|
||||
this.SetScale(0.1f, 0.1f);
|
||||
this.SetPivot(0.5f, 0.5f);
|
||||
this.TweenScale(new Vector2(1, 1), 0.3f).OnComplete(this.OnShown);
|
||||
}
|
||||
|
||||
override protected void DoHideAnimation()
|
||||
{
|
||||
this.TweenScale(new Vector2(0.1f, 0.1f), 0.3f).OnComplete(this.HideImmediately);
|
||||
}
|
||||
|
||||
void __clickItem(EventContext context)
|
||||
{
|
||||
GButton item = (GButton)context.data;
|
||||
this.contentPane.GetChild("n11").asLoader.url = item.icon;
|
||||
this.contentPane.GetChild("n13").text = item.icon;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 418d0818f0209ee42938610bc6cb82be
|
||||
timeCreated: 1446193148
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,188 +0,0 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
using UnityEngine.Networking;
|
||||
#endif
|
||||
|
||||
public delegate void LoadCompleteCallback(NTexture texture);
|
||||
public delegate void LoadErrorCallback(string error);
|
||||
|
||||
/// <summary>
|
||||
/// Use to load icons from asset bundle, and pool them
|
||||
/// </summary>
|
||||
public class IconManager : MonoBehaviour
|
||||
{
|
||||
static IconManager _instance;
|
||||
public static IconManager inst
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
GameObject go = new GameObject("IconManager");
|
||||
DontDestroyOnLoad(go);
|
||||
_instance = go.AddComponent<IconManager>();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public const int POOL_CHECK_TIME = 30;
|
||||
public const int MAX_POOL_SIZE = 10;
|
||||
|
||||
List<LoadItem> _items;
|
||||
bool _started;
|
||||
Hashtable _pool;
|
||||
string _basePath;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_items = new List<LoadItem>();
|
||||
_pool = new Hashtable();
|
||||
_basePath = Application.streamingAssetsPath.Replace("\\", "/") + "/fairygui-examples/";
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
_basePath = "file:///" + _basePath;
|
||||
|
||||
StartCoroutine(FreeIdleIcons());
|
||||
}
|
||||
|
||||
public void LoadIcon(string url,
|
||||
LoadCompleteCallback onSuccess,
|
||||
LoadErrorCallback onFail)
|
||||
{
|
||||
LoadItem item = new LoadItem();
|
||||
item.url = url;
|
||||
item.onSuccess = onSuccess;
|
||||
item.onFail = onFail;
|
||||
_items.Add(item);
|
||||
if (!_started)
|
||||
StartCoroutine(Run());
|
||||
}
|
||||
|
||||
IEnumerator Run()
|
||||
{
|
||||
_started = true;
|
||||
|
||||
LoadItem item = null;
|
||||
while (true)
|
||||
{
|
||||
if (_items.Count > 0)
|
||||
{
|
||||
item = _items[0];
|
||||
_items.RemoveAt(0);
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
if (_pool.ContainsKey(item.url))
|
||||
{
|
||||
//Debug.Log("hit " + item.url);
|
||||
|
||||
NTexture texture = (NTexture)_pool[item.url];
|
||||
texture.refCount++;
|
||||
|
||||
if (item.onSuccess != null)
|
||||
item.onSuccess(texture);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
string url = _basePath + item.url + ".ab";
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(url);
|
||||
#else
|
||||
UnityWebRequest www = UnityWebRequest.GetAssetBundle(url);
|
||||
#endif
|
||||
yield return www.SendWebRequest();
|
||||
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
if (www.result == UnityWebRequest.Result.Success)
|
||||
#else
|
||||
if (!www.isNetworkError && !www.isHttpError)
|
||||
#endif
|
||||
{
|
||||
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(www);
|
||||
#else
|
||||
WWW www = new WWW(url);
|
||||
yield return www;
|
||||
|
||||
if (string.IsNullOrEmpty(www.error))
|
||||
{
|
||||
AssetBundle bundle = www.assetBundle;
|
||||
#endif
|
||||
|
||||
if (bundle == null)
|
||||
{
|
||||
Debug.LogWarning("Run Window->Build FairyGUI example Bundles first.");
|
||||
if (item.onFail != null)
|
||||
item.onFail(www.error);
|
||||
continue;
|
||||
}
|
||||
#if (UNITY_5 || UNITY_5_3_OR_NEWER)
|
||||
NTexture texture = new NTexture(bundle.LoadAllAssets<Texture2D>()[0]);
|
||||
#else
|
||||
NTexture texture = new NTexture((Texture2D)bundle.mainAsset);
|
||||
#endif
|
||||
texture.refCount++;
|
||||
bundle.Unload(false);
|
||||
|
||||
_pool[item.url] = texture;
|
||||
|
||||
if (item.onSuccess != null)
|
||||
item.onSuccess(texture);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.onFail != null)
|
||||
item.onFail(www.error);
|
||||
}
|
||||
}
|
||||
|
||||
_started = false;
|
||||
}
|
||||
|
||||
IEnumerator FreeIdleIcons()
|
||||
{
|
||||
yield return new WaitForSeconds(POOL_CHECK_TIME); //check the pool every 30 seconds
|
||||
|
||||
int cnt = _pool.Count;
|
||||
if (cnt > MAX_POOL_SIZE)
|
||||
{
|
||||
ArrayList toRemove = null;
|
||||
foreach (DictionaryEntry de in _pool)
|
||||
{
|
||||
string key = (string)de.Key;
|
||||
NTexture texture = (NTexture)de.Value;
|
||||
if (texture.refCount == 0)
|
||||
{
|
||||
if (toRemove == null)
|
||||
toRemove = new ArrayList();
|
||||
toRemove.Add(key);
|
||||
texture.Dispose();
|
||||
|
||||
//Debug.Log("free icon " + de.Key);
|
||||
|
||||
cnt--;
|
||||
if (cnt <= 8)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (toRemove != null)
|
||||
{
|
||||
foreach (string key in toRemove)
|
||||
_pool.Remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class LoadItem
|
||||
{
|
||||
public string url;
|
||||
public LoadCompleteCallback onSuccess;
|
||||
public LoadErrorCallback onFail;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5725e4855896724d9bdeb29c68c6c92
|
||||
timeCreated: 1446193148
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,33 +0,0 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using System.IO;
|
||||
|
||||
/// <summary>
|
||||
/// Extend the ability of GLoader
|
||||
/// </summary>
|
||||
public class MyGLoader : GLoader
|
||||
{
|
||||
protected override void LoadExternal()
|
||||
{
|
||||
IconManager.inst.LoadIcon(this.url, OnLoadSuccess, OnLoadFail);
|
||||
}
|
||||
|
||||
protected override void FreeExternal(NTexture texture)
|
||||
{
|
||||
texture.refCount--;
|
||||
}
|
||||
|
||||
void OnLoadSuccess(NTexture texture)
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.url))
|
||||
return;
|
||||
|
||||
this.onExternalLoadSuccess(texture);
|
||||
}
|
||||
|
||||
void OnLoadFail(string error)
|
||||
{
|
||||
Debug.Log("load " + this.url + " failed: " + error);
|
||||
this.onExternalLoadFailed();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca2c5718cae50694a8291cc372ad458d
|
||||
timeCreated: 1446193148
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7afac4ff0289dac479c37c0cbf60f745
|
||||
folderAsset: yes
|
||||
timeCreated: 1446194671
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,441 +0,0 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
|
||||
public class BasicsMain : MonoBehaviour
|
||||
{
|
||||
private GComponent _mainView;
|
||||
private GObject _backBtn;
|
||||
private GComponent _demoContainer;
|
||||
private Controller _viewController;
|
||||
private Dictionary<string, GComponent> _demoObjects;
|
||||
|
||||
public Gradient lineGradient;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
#if (UNITY_5 || UNITY_5_3_OR_NEWER)
|
||||
//Use the font names directly
|
||||
UIConfig.defaultFont = "Microsoft YaHei";
|
||||
#else
|
||||
//Need to put a ttf file into Resources folder. Here is the file name of the ttf file.
|
||||
UIConfig.defaultFont = "afont";
|
||||
#endif
|
||||
UIPackage.AddPackage("UI/Basics");
|
||||
|
||||
UIConfig.verticalScrollBar = "ui://Basics/ScrollBar_VT";
|
||||
UIConfig.horizontalScrollBar = "ui://Basics/ScrollBar_HZ";
|
||||
UIConfig.popupMenu = "ui://Basics/PopupMenu";
|
||||
UIConfig.buttonSound = (NAudioClip)UIPackage.GetItemAsset("Basics", "click");
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
_mainView = this.GetComponent<UIPanel>().ui;
|
||||
|
||||
_backBtn = _mainView.GetChild("btn_Back");
|
||||
_backBtn.visible = false;
|
||||
_backBtn.onClick.Add(onClickBack);
|
||||
|
||||
_demoContainer = _mainView.GetChild("container").asCom;
|
||||
_viewController = _mainView.GetController("c1");
|
||||
|
||||
_demoObjects = new Dictionary<string, GComponent>();
|
||||
|
||||
int cnt = _mainView.numChildren;
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
GObject obj = _mainView.GetChildAt(i);
|
||||
if (obj.group != null && obj.group.name == "btns")
|
||||
obj.onClick.Add(runDemo);
|
||||
}
|
||||
}
|
||||
|
||||
private void runDemo(EventContext context)
|
||||
{
|
||||
string type = ((GObject)(context.sender)).name.Substring(4);
|
||||
GComponent obj;
|
||||
if (!_demoObjects.TryGetValue(type, out obj))
|
||||
{
|
||||
obj = UIPackage.CreateObject("Basics", "Demo_" + type).asCom;
|
||||
_demoObjects[type] = obj;
|
||||
}
|
||||
|
||||
_demoContainer.RemoveChildren();
|
||||
_demoContainer.AddChild(obj);
|
||||
_viewController.selectedIndex = 1;
|
||||
_backBtn.visible = true;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case "Graph":
|
||||
PlayGraph();
|
||||
break;
|
||||
|
||||
case "Button":
|
||||
PlayButton();
|
||||
break;
|
||||
|
||||
case "Text":
|
||||
PlayText();
|
||||
break;
|
||||
|
||||
case "Grid":
|
||||
PlayGrid();
|
||||
break;
|
||||
|
||||
case "Transition":
|
||||
PlayTransition();
|
||||
break;
|
||||
|
||||
case "Window":
|
||||
PlayWindow();
|
||||
break;
|
||||
|
||||
case "Popup":
|
||||
PlayPopup();
|
||||
break;
|
||||
|
||||
case "Drag&Drop":
|
||||
PlayDragDrop();
|
||||
break;
|
||||
|
||||
case "Depth":
|
||||
PlayDepth();
|
||||
break;
|
||||
|
||||
case "ProgressBar":
|
||||
PlayProgressBar();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void onClickBack()
|
||||
{
|
||||
_viewController.selectedIndex = 0;
|
||||
_backBtn.visible = false;
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------
|
||||
private void PlayGraph()
|
||||
{
|
||||
GComponent obj = _demoObjects["Graph"];
|
||||
|
||||
Shape shape;
|
||||
|
||||
shape = obj.GetChild("pie").asGraph.shape;
|
||||
EllipseMesh ellipse = shape.graphics.GetMeshFactory<EllipseMesh>();
|
||||
ellipse.startDegree = 30;
|
||||
ellipse.endDegreee = 300;
|
||||
shape.graphics.SetMeshDirty();
|
||||
|
||||
shape = obj.GetChild("trapezoid").asGraph.shape;
|
||||
PolygonMesh trapezoid = shape.graphics.GetMeshFactory<PolygonMesh>();
|
||||
trapezoid.usePercentPositions = true;
|
||||
trapezoid.points.Clear();
|
||||
trapezoid.points.Add(new Vector2(0f, 1f));
|
||||
trapezoid.points.Add(new Vector2(0.3f, 0));
|
||||
trapezoid.points.Add(new Vector2(0.7f, 0));
|
||||
trapezoid.points.Add(new Vector2(1f, 1f));
|
||||
trapezoid.texcoords.Clear();
|
||||
trapezoid.texcoords.AddRange(VertexBuffer.NormalizedUV);
|
||||
shape.graphics.SetMeshDirty();
|
||||
shape.graphics.texture = (NTexture)UIPackage.GetItemAsset("Basics", "change");
|
||||
|
||||
shape = obj.GetChild("line").asGraph.shape;
|
||||
LineMesh line = shape.graphics.GetMeshFactory<LineMesh>();
|
||||
line.lineWidthCurve = AnimationCurve.Linear(0, 25, 1, 10);
|
||||
line.roundEdge = true;
|
||||
line.gradient = lineGradient;
|
||||
line.path.Create(new GPathPoint[] {
|
||||
new GPathPoint(new Vector3(0, 120, 0)),
|
||||
new GPathPoint(new Vector3(20, 120, 0)),
|
||||
new GPathPoint(new Vector3(100, 100, 0)),
|
||||
new GPathPoint(new Vector3(180, 30, 0)),
|
||||
new GPathPoint(new Vector3(100, 0, 0)),
|
||||
new GPathPoint(new Vector3(20, 30, 0)),
|
||||
new GPathPoint(new Vector3(100, 100, 0)),
|
||||
new GPathPoint(new Vector3(180, 120, 0)),
|
||||
new GPathPoint(new Vector3(200, 120, 0)),
|
||||
});
|
||||
shape.graphics.SetMeshDirty();
|
||||
GTween.To(0, 1, 5).SetEase(EaseType.Linear).SetTarget(shape.graphics).OnUpdate((GTweener t) =>
|
||||
{
|
||||
((NGraphics)t.target).GetMeshFactory<LineMesh>().fillEnd = t.value.x;
|
||||
((NGraphics)t.target).SetMeshDirty();
|
||||
});
|
||||
|
||||
shape = obj.GetChild("line2").asGraph.shape;
|
||||
LineMesh line2 = shape.graphics.GetMeshFactory<LineMesh>();
|
||||
line2.lineWidth = 3;
|
||||
line2.roundEdge = true;
|
||||
line2.path.Create(new GPathPoint[] {
|
||||
new GPathPoint(new Vector3(0, 120, 0), GPathPoint.CurveType.Straight),
|
||||
new GPathPoint(new Vector3(60, 30, 0), GPathPoint.CurveType.Straight),
|
||||
new GPathPoint(new Vector3(80, 90, 0), GPathPoint.CurveType.Straight),
|
||||
new GPathPoint(new Vector3(140, 30, 0), GPathPoint.CurveType.Straight),
|
||||
new GPathPoint(new Vector3(160, 90, 0), GPathPoint.CurveType.Straight),
|
||||
new GPathPoint(new Vector3(220, 30, 0), GPathPoint.CurveType.Straight)
|
||||
});
|
||||
shape.graphics.SetMeshDirty();
|
||||
|
||||
GObject image = obj.GetChild("line3");
|
||||
LineMesh line3 = image.displayObject.graphics.GetMeshFactory<LineMesh>();
|
||||
line3.lineWidth = 30;
|
||||
line3.roundEdge = false;
|
||||
line3.path.Create(new GPathPoint[] {
|
||||
new GPathPoint(new Vector3(0, 30, 0), new Vector3(50, -30), new Vector3(150, -50)),
|
||||
new GPathPoint(new Vector3(200, 30, 0), new Vector3(300, 130)),
|
||||
new GPathPoint(new Vector3(400, 30, 0))
|
||||
});
|
||||
image.displayObject.graphics.SetMeshDirty();
|
||||
}
|
||||
|
||||
//-----------------------------
|
||||
private void PlayButton()
|
||||
{
|
||||
GComponent obj = _demoObjects["Button"];
|
||||
obj.GetChild("n34").onClick.Add(() => { UnityEngine.Debug.Log("click button"); });
|
||||
}
|
||||
|
||||
//------------------------------
|
||||
private void PlayText()
|
||||
{
|
||||
GComponent obj = _demoObjects["Text"];
|
||||
obj.GetChild("n12").asRichTextField.onClickLink.Add((EventContext context) =>
|
||||
{
|
||||
GRichTextField t = context.sender as GRichTextField;
|
||||
t.text = "[img]ui://Basics/pet[/img][color=#FF0000]You click the link[/color]:" + context.data;
|
||||
});
|
||||
obj.GetChild("n25").onClick.Add(() =>
|
||||
{
|
||||
obj.GetChild("n24").text = obj.GetChild("n22").text;
|
||||
});
|
||||
}
|
||||
|
||||
//------------------------------
|
||||
private void PlayGrid()
|
||||
{
|
||||
GComponent obj = _demoObjects["Grid"];
|
||||
GList list1 = obj.GetChild("list1").asList;
|
||||
list1.RemoveChildrenToPool();
|
||||
string[] testNames = System.Enum.GetNames(typeof(RuntimePlatform));
|
||||
Color[] testColor = new Color[] { Color.yellow, Color.red, Color.white, Color.cyan };
|
||||
int cnt = testNames.Length;
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
GButton item = list1.AddItemFromPool().asButton;
|
||||
item.GetChild("t0").text = "" + (i + 1);
|
||||
item.GetChild("t1").text = testNames[i];
|
||||
item.GetChild("t2").asTextField.color = testColor[UnityEngine.Random.Range(0, 4)];
|
||||
item.GetChild("star").asProgress.value = (int)((float)UnityEngine.Random.Range(1, 4) / 3f * 100);
|
||||
}
|
||||
|
||||
GList list2 = obj.GetChild("list2").asList;
|
||||
list2.RemoveChildrenToPool();
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
GButton item = list2.AddItemFromPool().asButton;
|
||||
item.GetChild("cb").asButton.selected = false;
|
||||
item.GetChild("t1").text = testNames[i];
|
||||
item.GetChild("mc").asMovieClip.playing = i % 2 == 0;
|
||||
item.GetChild("t3").text = "" + UnityEngine.Random.Range(0, 10000);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------
|
||||
private void PlayTransition()
|
||||
{
|
||||
GComponent obj = _demoObjects["Transition"];
|
||||
obj.GetChild("n2").asCom.GetTransition("t0").Play(int.MaxValue, 0, null);
|
||||
obj.GetChild("n3").asCom.GetTransition("peng").Play(int.MaxValue, 0, null);
|
||||
|
||||
obj.onAddedToStage.Add(() =>
|
||||
{
|
||||
obj.GetChild("n2").asCom.GetTransition("t0").Stop();
|
||||
obj.GetChild("n3").asCom.GetTransition("peng").Stop();
|
||||
});
|
||||
}
|
||||
|
||||
//------------------------------
|
||||
private Window _winA;
|
||||
private Window _winB;
|
||||
private void PlayWindow()
|
||||
{
|
||||
GComponent obj = _demoObjects["Window"];
|
||||
obj.GetChild("n0").onClick.Add(() =>
|
||||
{
|
||||
if (_winA == null)
|
||||
_winA = new Window1();
|
||||
_winA.Show();
|
||||
});
|
||||
|
||||
obj.GetChild("n1").onClick.Add(() =>
|
||||
{
|
||||
if (_winB == null)
|
||||
_winB = new Window2();
|
||||
_winB.Show();
|
||||
});
|
||||
}
|
||||
|
||||
//------------------------------
|
||||
private PopupMenu _pm;
|
||||
private GComponent _popupCom;
|
||||
private void PlayPopup()
|
||||
{
|
||||
if (_pm == null)
|
||||
{
|
||||
_pm = new PopupMenu();
|
||||
_pm.AddItem("Item 1", __clickMenu);
|
||||
_pm.AddItem("Item 2", __clickMenu);
|
||||
_pm.AddItem("Item 3", __clickMenu);
|
||||
_pm.AddItem("Item 4", __clickMenu);
|
||||
}
|
||||
|
||||
if (_popupCom == null)
|
||||
{
|
||||
_popupCom = UIPackage.CreateObject("Basics", "Component12").asCom;
|
||||
_popupCom.Center();
|
||||
}
|
||||
GComponent obj = _demoObjects["Popup"];
|
||||
obj.GetChild("n0").onClick.Add((EventContext context) =>
|
||||
{
|
||||
_pm.Show((GObject)context.sender, PopupDirection.Down);
|
||||
});
|
||||
|
||||
obj.GetChild("n1").onClick.Add(() =>
|
||||
{
|
||||
GRoot.inst.ShowPopup(_popupCom);
|
||||
});
|
||||
|
||||
|
||||
obj.onRightClick.Add(() =>
|
||||
{
|
||||
_pm.Show();
|
||||
});
|
||||
}
|
||||
|
||||
private void __clickMenu(EventContext context)
|
||||
{
|
||||
GObject itemObject = (GObject)context.data;
|
||||
UnityEngine.Debug.Log("click " + itemObject.text);
|
||||
}
|
||||
|
||||
//------------------------------
|
||||
Vector2 startPos;
|
||||
private void PlayDepth()
|
||||
{
|
||||
GComponent obj = _demoObjects["Depth"];
|
||||
GComponent testContainer = obj.GetChild("n22").asCom;
|
||||
GObject fixedObj = testContainer.GetChild("n0");
|
||||
fixedObj.sortingOrder = 100;
|
||||
fixedObj.draggable = true;
|
||||
|
||||
int numChildren = testContainer.numChildren;
|
||||
int i = 0;
|
||||
while (i < numChildren)
|
||||
{
|
||||
GObject child = testContainer.GetChildAt(i);
|
||||
if (child != fixedObj)
|
||||
{
|
||||
testContainer.RemoveChildAt(i);
|
||||
numChildren--;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
startPos = new Vector2(fixedObj.x, fixedObj.y);
|
||||
|
||||
obj.GetChild("btn0").onClick.Add(() =>
|
||||
{
|
||||
GGraph graph = new GGraph();
|
||||
startPos.x += 10;
|
||||
startPos.y += 10;
|
||||
graph.xy = startPos;
|
||||
graph.DrawRect(150, 150, 1, Color.black, Color.red);
|
||||
obj.GetChild("n22").asCom.AddChild(graph);
|
||||
});
|
||||
|
||||
obj.GetChild("btn1").onClick.Add(() =>
|
||||
{
|
||||
GGraph graph = new GGraph();
|
||||
startPos.x += 10;
|
||||
startPos.y += 10;
|
||||
graph.xy = startPos;
|
||||
graph.DrawRect(150, 150, 1, Color.black, Color.green);
|
||||
graph.sortingOrder = 200;
|
||||
obj.GetChild("n22").asCom.AddChild(graph);
|
||||
});
|
||||
}
|
||||
|
||||
//------------------------------
|
||||
private void PlayDragDrop()
|
||||
{
|
||||
GComponent obj = _demoObjects["Drag&Drop"];
|
||||
obj.GetChild("a").draggable = true;
|
||||
|
||||
GButton b = obj.GetChild("b").asButton;
|
||||
b.draggable = true;
|
||||
b.onDragStart.Add((EventContext context) =>
|
||||
{
|
||||
//Cancel the original dragging, and start a new one with a agent.
|
||||
context.PreventDefault();
|
||||
|
||||
DragDropManager.inst.StartDrag(b, b.icon, b.icon, (int)context.data);
|
||||
});
|
||||
|
||||
GButton c = obj.GetChild("c").asButton;
|
||||
c.icon = null;
|
||||
c.onDrop.Add((EventContext context) =>
|
||||
{
|
||||
c.icon = (string)context.data;
|
||||
});
|
||||
|
||||
GObject bounds = obj.GetChild("n7");
|
||||
Rect rect = bounds.TransformRect(new Rect(0, 0, bounds.width, bounds.height), GRoot.inst);
|
||||
|
||||
//---!!Because at this time the container is on the right side of the stage and beginning to move to left(transition), so we need to caculate the final position
|
||||
rect.x -= obj.parent.x;
|
||||
//----
|
||||
|
||||
GButton d = obj.GetChild("d").asButton;
|
||||
d.draggable = true;
|
||||
d.dragBounds = rect;
|
||||
}
|
||||
|
||||
//------------------------------
|
||||
private void PlayProgressBar()
|
||||
{
|
||||
GComponent obj = _demoObjects["ProgressBar"];
|
||||
Timers.inst.Add(0.001f, 0, __playProgress);
|
||||
obj.onRemovedFromStage.Add(() => { Timers.inst.Remove(__playProgress); });
|
||||
}
|
||||
|
||||
void __playProgress(object param)
|
||||
{
|
||||
GComponent obj = _demoObjects["ProgressBar"];
|
||||
int cnt = obj.numChildren;
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
GProgressBar child = obj.GetChildAt(i) as GProgressBar;
|
||||
if (child != null)
|
||||
{
|
||||
|
||||
child.value += 1;
|
||||
if (child.value > child.max)
|
||||
child.value = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7c649dfadf79df4a963190eded74b30
|
||||
timeCreated: 1446194671
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,29 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
|
||||
public class Window1 : Window
|
||||
{
|
||||
public Window1()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.contentPane = UIPackage.CreateObject("Basics", "WindowA").asCom;
|
||||
this.Center();
|
||||
}
|
||||
|
||||
override protected void OnShown()
|
||||
{
|
||||
GList list = this.contentPane.GetChild("n6").asList;
|
||||
list.RemoveChildrenToPool();
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
GButton item = list.AddItemFromPool().asButton;
|
||||
item.title = "" + i;
|
||||
item.icon = UIPackage.GetItemURL("Basics", "r4");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9e33dc08a51fd04883526e4f5129e42
|
||||
timeCreated: 1447054717
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
using UnityEngine;
|
||||
|
||||
public class Window2 : Window
|
||||
{
|
||||
public Window2()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.contentPane = UIPackage.CreateObject("Basics", "WindowB").asCom;
|
||||
this.Center();
|
||||
}
|
||||
|
||||
override protected void DoShowAnimation()
|
||||
{
|
||||
this.SetScale(0.1f, 0.1f);
|
||||
this.SetPivot(0.5f, 0.5f);
|
||||
this.TweenScale(new Vector2(1, 1), 0.3f).OnComplete(this.OnShown);
|
||||
}
|
||||
|
||||
override protected void DoHideAnimation()
|
||||
{
|
||||
this.TweenScale(new Vector2(0.1f, 0.1f), 0.3f).OnComplete(this.HideImmediately);
|
||||
}
|
||||
|
||||
override protected void OnShown()
|
||||
{
|
||||
contentPane.GetTransition("t1").Play();
|
||||
}
|
||||
|
||||
override protected void OnHide()
|
||||
{
|
||||
contentPane.GetTransition("t1").Stop();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f922289dfda2b1d4689eabfcdf6a5b91
|
||||
timeCreated: 1447054712
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae0ad495a670df246b212607e661ec96
|
||||
folderAsset: yes
|
||||
timeCreated: 1446643487
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,86 +0,0 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using System.Net;
|
||||
using UnityEngine.Networking;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Demonstrated how to load UI package from assetbundle. The bundle can be build from the Window Menu->Build FairyGUI example bundles.
|
||||
/// </summary>
|
||||
class BundleUsageMain : MonoBehaviour
|
||||
{
|
||||
GComponent _mainView;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
StartCoroutine(LoadUIPackage());
|
||||
}
|
||||
|
||||
IEnumerator LoadUIPackage()
|
||||
{
|
||||
string url = Application.streamingAssetsPath.Replace("\\", "/") + "/fairygui-examples/bundleusage.ab";
|
||||
if (Application.isEditor)
|
||||
{
|
||||
UriBuilder uri = new UriBuilder(url);
|
||||
uri.Scheme = "file";
|
||||
url = uri.ToString();
|
||||
}
|
||||
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(url);
|
||||
#else
|
||||
UnityWebRequest www = UnityWebRequest.GetAssetBundle(url);
|
||||
#endif
|
||||
yield return www.SendWebRequest();
|
||||
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
if (www.result == UnityWebRequest.Result.Success)
|
||||
#else
|
||||
if (!www.isNetworkError && !www.isHttpError)
|
||||
#endif
|
||||
{
|
||||
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(www);
|
||||
#else
|
||||
WWW www = new WWW(url);
|
||||
yield return www;
|
||||
|
||||
if (string.IsNullOrEmpty(www.error))
|
||||
{
|
||||
AssetBundle bundle = www.assetBundle;
|
||||
#endif
|
||||
if (bundle == null)
|
||||
{
|
||||
Debug.LogWarning("Run Window->Build FairyGUI example Bundles first.");
|
||||
yield return 0;
|
||||
}
|
||||
UIPackage.AddPackage(bundle);
|
||||
|
||||
_mainView = UIPackage.CreateObject("BundleUsage", "Main").asCom;
|
||||
_mainView.fairyBatching = true;
|
||||
_mainView.MakeFullScreen();
|
||||
_mainView.AddRelation(GRoot.inst, RelationType.Size);
|
||||
|
||||
GRoot.inst.AddChild(_mainView);
|
||||
_mainView.GetTransition("t0").Play();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Run Window->Build FairyGUI example Bundles first.");
|
||||
}
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c34dde491ef252c49af798031b5a37de
|
||||
timeCreated: 1446643490
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee28fce39e275054fad5911e3f98c5e2
|
||||
folderAsset: yes
|
||||
timeCreated: 1447173764
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,57 +0,0 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
public class CooldownMain : MonoBehaviour
|
||||
{
|
||||
GComponent _mainView;
|
||||
|
||||
GButton _btn0;
|
||||
GImage _mask0;
|
||||
float _time1;
|
||||
|
||||
GButton _btn1;
|
||||
GImage _mask1;
|
||||
float _time2;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
_mainView = this.gameObject.GetComponent<UIPanel>().ui;
|
||||
|
||||
_btn0 = _mainView.GetChild("b0").asButton;
|
||||
_btn0.icon = "Cooldown/k0";
|
||||
_time1 = 5;
|
||||
_mask0 = _btn0.GetChild("mask").asImage;
|
||||
|
||||
_btn1 = _mainView.GetChild("b1").asButton;
|
||||
_btn1.icon = "Cooldown/k1";
|
||||
_time2 = 10;
|
||||
_mask1 = _btn1.GetChild("mask").asImage;
|
||||
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
_time1 -= Time.deltaTime;
|
||||
if (_time1 < 0)
|
||||
_time1 = 5;
|
||||
_mask0.fillAmount = 1 - (5 - _time1) / 5f;
|
||||
|
||||
_time2 -= Time.deltaTime;
|
||||
if (_time2 < 0)
|
||||
_time2 = 10;
|
||||
_btn1.text = string.Empty + Mathf.RoundToInt(_time2);
|
||||
_mask1.fillAmount = 1 - (10 - _time2) / 10f;
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c59a131f345dd4e4895409b111e0c434
|
||||
timeCreated: 1447174165
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9255b3554fc92214b98dc85f52b3ebb2
|
||||
folderAsset: yes
|
||||
timeCreated: 1461431337
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,58 +0,0 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class CurveMain : MonoBehaviour
|
||||
{
|
||||
GComponent _mainView;
|
||||
GList _list;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
_mainView = this.GetComponent<UIPainter>().ui;
|
||||
|
||||
_list = _mainView.GetChild("list").asList;
|
||||
_list.SetVirtualAndLoop();
|
||||
_list.itemRenderer = RenderListItem;
|
||||
_list.numItems = 5;
|
||||
_list.scrollPane.onScroll.Add(DoSpecialEffect);
|
||||
|
||||
DoSpecialEffect();
|
||||
}
|
||||
|
||||
void DoSpecialEffect()
|
||||
{
|
||||
//change the scale according to the distance to middle
|
||||
float midX = _list.scrollPane.posX + _list.viewWidth / 2;
|
||||
int cnt = _list.numChildren;
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
GObject obj = _list.GetChildAt(i);
|
||||
float dist = Mathf.Abs(midX - obj.x - obj.width / 2);
|
||||
if (dist > obj.width) //no intersection
|
||||
obj.SetScale(1, 1);
|
||||
else
|
||||
{
|
||||
float ss = 1 + (1 - dist / obj.width) * 0.24f;
|
||||
obj.SetScale(ss, ss);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RenderListItem(int index, GObject obj)
|
||||
{
|
||||
GButton item = (GButton)obj;
|
||||
item.SetPivot(0.5f, 0.5f);
|
||||
item.icon = UIPackage.GetItemURL("Curve", "n" + (index + 1));
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d30b14c0ce756e2428ef9db93b692b69
|
||||
timeCreated: 1461431341
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b781546cb2bc024a9f388f515ff11e4
|
||||
folderAsset: yes
|
||||
timeCreated: 1446628629
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,28 +0,0 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
/// <summary>
|
||||
/// Demonstrated the simple flow of a game.
|
||||
/// </summary>
|
||||
public class CutSceneMain : MonoBehaviour
|
||||
{
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
UIPackage.AddPackage("UI/CutScene");
|
||||
|
||||
LevelManager.inst.Init();
|
||||
LevelManager.inst.LoadLevel("scene1");
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0c05fcb4b735cf4587717a360b2a231
|
||||
timeCreated: 1446628633
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,82 +0,0 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
using UnityEngine.SceneManagement;
|
||||
#endif
|
||||
using FairyGUI;
|
||||
|
||||
public class LevelManager : MonoBehaviour
|
||||
{
|
||||
static LevelManager _instance;
|
||||
public static LevelManager inst
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
GameObject go = new GameObject("LevelManager");
|
||||
DontDestroyOnLoad(go);
|
||||
_instance = go.AddComponent<LevelManager>();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
GComponent _cutSceneView;
|
||||
GComponent _mainView;
|
||||
|
||||
public LevelManager()
|
||||
{
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
_cutSceneView = UIPackage.CreateObject("CutScene", "CutScene").asCom;
|
||||
_cutSceneView.SetSize(GRoot.inst.width, GRoot.inst.height);
|
||||
_cutSceneView.AddRelation(GRoot.inst, RelationType.Size);
|
||||
|
||||
_mainView = UIPackage.CreateObject("CutScene", "Main").asCom;
|
||||
_mainView.SetSize(GRoot.inst.width, GRoot.inst.height);
|
||||
_mainView.AddRelation(GRoot.inst, RelationType.Size);
|
||||
|
||||
_mainView.GetChild("n0").onClick.Add(() =>
|
||||
{
|
||||
LoadLevel("scene1");
|
||||
});
|
||||
|
||||
_mainView.GetChild("n1").onClick.Add(() =>
|
||||
{
|
||||
LoadLevel("scene2");
|
||||
});
|
||||
}
|
||||
|
||||
public void LoadLevel(string levelName)
|
||||
{
|
||||
StartCoroutine(DoLoad(levelName));
|
||||
GRoot.inst.AddChild(_cutSceneView);
|
||||
}
|
||||
|
||||
IEnumerator DoLoad(string sceneName)
|
||||
{
|
||||
GRoot.inst.AddChild(_cutSceneView);
|
||||
GProgressBar pb = _cutSceneView.GetChild("pb").asProgress;
|
||||
pb.value = 0;
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
AsyncOperation op = SceneManager.LoadSceneAsync(sceneName);
|
||||
#else
|
||||
AsyncOperation op = Application.LoadLevelAsync(sceneName);
|
||||
#endif
|
||||
float startTime = Time.time;
|
||||
while (!op.isDone || pb.value != 100)
|
||||
{
|
||||
int value = (int)((Time.time - startTime) * 100f / 3f);
|
||||
if (value > 100)
|
||||
value = 100;
|
||||
pb.value = value;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
GRoot.inst.RemoveChild(_cutSceneView);
|
||||
GRoot.inst.AddChild(_mainView);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfefd808bb86e4f4cb34eaf9da5d1a36
|
||||
timeCreated: 1446630965
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b79c211a7d63ecf4796b13556fd29826
|
||||
folderAsset: yes
|
||||
timeCreated: 1446620759
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,33 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
public class BuildAssetBundles
|
||||
{
|
||||
[MenuItem("Window/Build FairyGUI Example Bundles")]
|
||||
public static void Build()
|
||||
{
|
||||
string testPath = "UI/BundleUsage_fui";
|
||||
Object obj = Resources.Load(testPath);
|
||||
string path = AssetDatabase.GetAssetPath(obj);
|
||||
if(string.IsNullOrEmpty(path))
|
||||
{
|
||||
Debug.LogWarning("sample not found: " + testPath);
|
||||
return;
|
||||
}
|
||||
string basePath = path.Substring(0, path.Length - testPath.Length - 6);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
AssetImporter.GetAtPath(basePath + "Icons/i" + i + ".png").assetBundleName = "fairygui-examples/i" + i + ".ab";
|
||||
}
|
||||
|
||||
AssetImporter.GetAtPath(basePath + "UI/BundleUsage_fui.bytes").assetBundleName = "fairygui-examples/bundleusage.ab";
|
||||
AssetImporter.GetAtPath(basePath + "UI/BundleUsage_atlas0.png").assetBundleName = "fairygui-examples/bundleusage.ab";
|
||||
|
||||
if (!Directory.Exists(Application.streamingAssetsPath))
|
||||
Directory.CreateDirectory(Application.streamingAssetsPath);
|
||||
|
||||
BuildPipeline.BuildAssetBundles(Application.streamingAssetsPath, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb6ce699bc9e31440b4f01462aacc612
|
||||
timeCreated: 1446625466
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91fdebf77175d934ab3d4689ca57f396
|
||||
folderAsset: yes
|
||||
timeCreated: 1446569240
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,94 +0,0 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class EmitComponent : GComponent
|
||||
{
|
||||
GLoader _symbolLoader;
|
||||
GTextField _numberText;
|
||||
Transform _owner;
|
||||
|
||||
const float OFFSET_ADDITION = 2.2f;
|
||||
static Vector2 JITTER_FACTOR = new Vector2(80, 80);
|
||||
|
||||
public EmitComponent()
|
||||
{
|
||||
this.touchable = false;
|
||||
|
||||
_symbolLoader = new GLoader();
|
||||
_symbolLoader.autoSize = true;
|
||||
AddChild(_symbolLoader);
|
||||
|
||||
_numberText = new GTextField();
|
||||
_numberText.autoSize = AutoSizeType.Both;
|
||||
|
||||
AddChild(_numberText);
|
||||
}
|
||||
|
||||
public void SetHurt(Transform owner, int type, long hurt, bool critical)
|
||||
{
|
||||
_owner = owner;
|
||||
|
||||
TextFormat tf = _numberText.textFormat;
|
||||
if (type == 0)
|
||||
tf.font = EmitManager.inst.hurtFont1;
|
||||
else
|
||||
tf.font = EmitManager.inst.hurtFont2;
|
||||
_numberText.textFormat = tf;
|
||||
_numberText.text = "-" + hurt;
|
||||
|
||||
if (critical)
|
||||
_symbolLoader.url = EmitManager.inst.criticalSign;
|
||||
else
|
||||
_symbolLoader.url = "";
|
||||
|
||||
UpdateLayout();
|
||||
|
||||
this.alpha = 1;
|
||||
UpdatePosition(Vector2.zero);
|
||||
Vector2 rnd = Vector2.Scale(UnityEngine.Random.insideUnitCircle, JITTER_FACTOR);
|
||||
int toX = (int)rnd.x * 2;
|
||||
int toY = (int)rnd.y * 2;
|
||||
|
||||
EmitManager.inst.view.AddChild(this);
|
||||
GTween.To(Vector2.zero, new Vector2(toX, toY), 1f).SetTarget(this)
|
||||
.OnUpdate((GTweener tweener) => { this.UpdatePosition(tweener.value.vec2); }).OnComplete(this.OnCompleted);
|
||||
this.TweenFade(0, 0.5f).SetDelay(0.5f);
|
||||
}
|
||||
|
||||
void UpdateLayout()
|
||||
{
|
||||
this.SetSize(_symbolLoader.width + _numberText.width, Mathf.Max(_symbolLoader.height, _numberText.height));
|
||||
_numberText.SetXY(_symbolLoader.width > 0 ? (_symbolLoader.width + 2) : 0,
|
||||
(this.height - _numberText.height) / 2);
|
||||
_symbolLoader.y = (this.height - _symbolLoader.height) / 2;
|
||||
}
|
||||
|
||||
void UpdatePosition(Vector2 pos)
|
||||
{
|
||||
Vector3 ownerPos = _owner.position;
|
||||
ownerPos.y += OFFSET_ADDITION;
|
||||
Vector3 screenPos = Camera.main.WorldToScreenPoint(ownerPos);
|
||||
screenPos.y = Screen.height - screenPos.y; //convert to Stage coordinates system
|
||||
|
||||
Vector3 pt = GRoot.inst.GlobalToLocal(screenPos);
|
||||
this.SetXY(Mathf.RoundToInt(pt.x + pos.x - this.actualWidth / 2), Mathf.RoundToInt(pt.y + pos.y - this.height));
|
||||
}
|
||||
|
||||
void OnCompleted()
|
||||
{
|
||||
_owner = null;
|
||||
EmitManager.inst.view.RemoveChild(this);
|
||||
EmitManager.inst.ReturnComponent(this);
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
_owner = null;
|
||||
if (this.parent != null)
|
||||
{
|
||||
GTween.Kill(this);
|
||||
EmitManager.inst.view.RemoveChild(this);
|
||||
}
|
||||
EmitManager.inst.ReturnComponent(this);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8535a403e7324c49890b1de70edc2a0
|
||||
timeCreated: 1446570746
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,50 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class EmitManager
|
||||
{
|
||||
static EmitManager _instance;
|
||||
public static EmitManager inst
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
_instance = new EmitManager();
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public string hurtFont1;
|
||||
public string hurtFont2;
|
||||
public string criticalSign;
|
||||
|
||||
public GComponent view { get; private set; }
|
||||
|
||||
private readonly Stack<EmitComponent> _componentPool = new Stack<EmitComponent>();
|
||||
|
||||
public EmitManager()
|
||||
{
|
||||
hurtFont1 = "ui://EmitNumbers/number1";
|
||||
hurtFont2 = "ui://EmitNumbers/number2";
|
||||
criticalSign = "ui://EmitNumbers/critical";
|
||||
|
||||
view = new GComponent();
|
||||
GRoot.inst.AddChild(view);
|
||||
}
|
||||
|
||||
public void Emit(Transform owner, int type, long hurt, bool critical)
|
||||
{
|
||||
EmitComponent ec;
|
||||
if (_componentPool.Count > 0)
|
||||
ec = _componentPool.Pop();
|
||||
else
|
||||
ec = new EmitComponent();
|
||||
ec.SetHurt(owner, type, hurt, critical);
|
||||
}
|
||||
|
||||
public void ReturnComponent(EmitComponent com)
|
||||
{
|
||||
_componentPool.Push(com);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 335d4e8607937704285d9e0aec495020
|
||||
timeCreated: 1446570745
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,44 +0,0 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class EmitNumbersMain : MonoBehaviour
|
||||
{
|
||||
Transform _npc1;
|
||||
Transform _npc2;
|
||||
bool _finished;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
_npc1 = GameObject.Find("npc1").transform;
|
||||
_npc2 = GameObject.Find("npc2").transform;
|
||||
|
||||
StartCoroutine(RunTest());
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
_finished = true;
|
||||
}
|
||||
|
||||
IEnumerator RunTest()
|
||||
{
|
||||
while (!_finished)
|
||||
{
|
||||
EmitManager.inst.Emit(_npc1, 0, UnityEngine.Random.Range(100, 100000), UnityEngine.Random.Range(0, 10) == 5);
|
||||
EmitManager.inst.Emit(_npc2, 1, UnityEngine.Random.Range(100, 100000), UnityEngine.Random.Range(0, 10) == 5);
|
||||
yield return new WaitForSeconds(0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ee84d8c960d2404893a09cb4009bee8
|
||||
timeCreated: 1446569244
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fbba022553e7d1d438d20305716af90e
|
||||
folderAsset: yes
|
||||
timeCreated: 1446193142
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,196 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class EmojiMain : MonoBehaviour
|
||||
{
|
||||
GComponent _mainView;
|
||||
GList _list;
|
||||
GTextInput _input1;
|
||||
GTextInput _input2;
|
||||
GComponent _emojiSelectUI1;
|
||||
GComponent _emojiSelectUI2;
|
||||
|
||||
class Message
|
||||
{
|
||||
public string sender;
|
||||
public string senderIcon;
|
||||
public string msg;
|
||||
public bool fromMe;
|
||||
}
|
||||
List<Message> _messages;
|
||||
|
||||
Dictionary<uint, Emoji> _emojies;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
UIPackage.AddPackage("UI/Emoji");
|
||||
|
||||
UIConfig.verticalScrollBar = "ui://Emoji/ScrollBar_VT";
|
||||
UIConfig.defaultScrollBarDisplay = ScrollBarDisplayType.Auto;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
_messages = new List<Message>();
|
||||
|
||||
_mainView = this.GetComponent<UIPanel>().ui;
|
||||
|
||||
_list = _mainView.GetChild("list").asList;
|
||||
_list.SetVirtual();
|
||||
_list.itemProvider = GetListItemResource;
|
||||
_list.itemRenderer = RenderListItem;
|
||||
|
||||
_input1 = _mainView.GetChild("input1").asTextInput;
|
||||
_input1.onKeyDown.Add(__inputKeyDown1);
|
||||
|
||||
_input2 = _mainView.GetChild("input2").asTextInput;
|
||||
_input2.onKeyDown.Add(__inputKeyDown2);
|
||||
|
||||
//作为demo,这里只添加了部分表情素材
|
||||
_emojies = new Dictionary<uint, Emoji>();
|
||||
for (uint i = 0x1f600; i < 0x1f637; i++)
|
||||
{
|
||||
string url = UIPackage.GetItemURL("Emoji", Convert.ToString(i, 16));
|
||||
if (url != null)
|
||||
_emojies.Add(i, new Emoji(url));
|
||||
}
|
||||
_input2.emojies = _emojies;
|
||||
|
||||
_mainView.GetChild("btnSend1").onClick.Add(__clickSendBtn1);
|
||||
_mainView.GetChild("btnSend2").onClick.Add(__clickSendBtn2);
|
||||
|
||||
_mainView.GetChild("btnEmoji1").onClick.Add(__clickEmojiBtn1);
|
||||
_mainView.GetChild("btnEmoji2").onClick.Add(__clickEmojiBtn2);
|
||||
|
||||
_emojiSelectUI1 = UIPackage.CreateObject("Emoji", "EmojiSelectUI").asCom;
|
||||
_emojiSelectUI1.fairyBatching = true;
|
||||
_emojiSelectUI1.GetChild("list").asList.onClickItem.Add(__clickEmoji1);
|
||||
|
||||
_emojiSelectUI2 = UIPackage.CreateObject("Emoji", "EmojiSelectUI_ios").asCom;
|
||||
_emojiSelectUI2.fairyBatching = true;
|
||||
_emojiSelectUI2.GetChild("list").asList.onClickItem.Add(__clickEmoji2);
|
||||
}
|
||||
|
||||
void AddMsg(string sender, string senderIcon, string msg, bool fromMe)
|
||||
{
|
||||
bool isScrollBottom = _list.scrollPane.isBottomMost;
|
||||
|
||||
Message newMessage = new Message();
|
||||
newMessage.sender = sender;
|
||||
newMessage.senderIcon = senderIcon;
|
||||
newMessage.msg = msg;
|
||||
newMessage.fromMe = fromMe;
|
||||
_messages.Add(newMessage);
|
||||
|
||||
if (newMessage.fromMe)
|
||||
{
|
||||
if (_messages.Count == 1 || UnityEngine.Random.Range(0f, 1f) < 0.5f)
|
||||
{
|
||||
Message replyMessage = new Message();
|
||||
replyMessage.sender = "FairyGUI";
|
||||
replyMessage.senderIcon = "r1";
|
||||
replyMessage.msg = "Today is a good day. \U0001f600";
|
||||
replyMessage.fromMe = false;
|
||||
_messages.Add(replyMessage);
|
||||
}
|
||||
}
|
||||
|
||||
if (_messages.Count > 100)
|
||||
_messages.RemoveRange(0, _messages.Count - 100);
|
||||
|
||||
_list.numItems = _messages.Count;
|
||||
|
||||
if (isScrollBottom)
|
||||
_list.scrollPane.ScrollBottom();
|
||||
}
|
||||
|
||||
string GetListItemResource(int index)
|
||||
{
|
||||
Message msg = _messages[index];
|
||||
if (msg.fromMe)
|
||||
return "ui://Emoji/chatRight";
|
||||
else
|
||||
return "ui://Emoji/chatLeft";
|
||||
}
|
||||
|
||||
void RenderListItem(int index, GObject obj)
|
||||
{
|
||||
GButton item = (GButton)obj;
|
||||
Message msg = _messages[index];
|
||||
if (!msg.fromMe)
|
||||
item.GetChild("name").text = msg.sender;
|
||||
item.icon = UIPackage.GetItemURL("Emoji", msg.senderIcon);
|
||||
|
||||
//Recaculate the text width
|
||||
GRichTextField tf = item.GetChild("msg").asRichTextField;
|
||||
tf.emojies = _emojies;
|
||||
tf.text = EmojiParser.inst.Parse(msg.msg);
|
||||
}
|
||||
|
||||
void __clickSendBtn1(EventContext context)
|
||||
{
|
||||
string msg = _input1.text;
|
||||
if (msg.Length == 0)
|
||||
return;
|
||||
|
||||
AddMsg("Unity", "r0", msg, true);
|
||||
_input1.text = "";
|
||||
}
|
||||
|
||||
void __clickSendBtn2(EventContext context)
|
||||
{
|
||||
string msg = _input2.text;
|
||||
if (msg.Length == 0)
|
||||
return;
|
||||
|
||||
AddMsg("Unity", "r0", msg, true);
|
||||
_input2.text = "";
|
||||
}
|
||||
|
||||
void __clickEmojiBtn1(EventContext context)
|
||||
{
|
||||
GRoot.inst.ShowPopup(_emojiSelectUI1, (GObject)context.sender, PopupDirection.Up);
|
||||
}
|
||||
|
||||
void __clickEmojiBtn2(EventContext context)
|
||||
{
|
||||
GRoot.inst.ShowPopup(_emojiSelectUI2, (GObject)context.sender, PopupDirection.Up);
|
||||
}
|
||||
|
||||
void __clickEmoji1(EventContext context)
|
||||
{
|
||||
GButton item = (GButton)context.data;
|
||||
_input1.ReplaceSelection("[:" + item.text + "]");
|
||||
}
|
||||
|
||||
void __clickEmoji2(EventContext context)
|
||||
{
|
||||
GButton item = (GButton)context.data;
|
||||
_input2.ReplaceSelection(Char.ConvertFromUtf32(Convert.ToInt32(UIPackage.GetItemByURL(item.icon).name, 16)));
|
||||
}
|
||||
|
||||
void __inputKeyDown1(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Return)
|
||||
_mainView.GetChild("btnSend1").onClick.Call();
|
||||
}
|
||||
|
||||
void __inputKeyDown2(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Return)
|
||||
_mainView.GetChild("btnSend2").onClick.Call();
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4953851686ef2ed4d90f67c5fe144849
|
||||
timeCreated: 1446193148
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,31 +0,0 @@
|
||||
using FairyGUI;
|
||||
using FairyGUI.Utils;
|
||||
|
||||
public class EmojiParser : UBBParser
|
||||
{
|
||||
static EmojiParser _instance;
|
||||
public new static EmojiParser inst
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
_instance = new EmojiParser();
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
private static string[] TAGS = new string[]
|
||||
{ "88","am","bs","bz","ch","cool","dhq","dn","fd","gz","han","hx","hxiao","hxiu" };
|
||||
public EmojiParser ()
|
||||
{
|
||||
foreach (string ss in TAGS)
|
||||
{
|
||||
this.handlers[":"+ss] = OnTag_Emoji;
|
||||
}
|
||||
}
|
||||
|
||||
string OnTag_Emoji(string tagName, bool end, string attr)
|
||||
{
|
||||
return "<img src='" + UIPackage.GetItemURL("Emoji", tagName.Substring(1).ToLower()) + "'/>";
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebe7b2fb6b5fe8c488fac00b1b177326
|
||||
timeCreated: 1446193148
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc519b1dfb870064ea786640d8a0a8d1
|
||||
folderAsset: yes
|
||||
timeCreated: 1446648215
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,55 +0,0 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class ExtensionMain : MonoBehaviour
|
||||
{
|
||||
GComponent _mainView;
|
||||
GList _list;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
UIPackage.AddPackage("UI/Extension");
|
||||
UIObjectFactory.SetPackageItemExtension("ui://Extension/mailItem", typeof(MailItem));
|
||||
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
_mainView = this.GetComponent<UIPanel>().ui;
|
||||
|
||||
_list = _mainView.GetChild("mailList").asList;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
MailItem item = (MailItem)_list.AddItemFromPool();
|
||||
item.setFetched(i % 3 == 0);
|
||||
item.setRead(i % 2 == 0);
|
||||
item.setTime("5 Nov 2015 16:24:33");
|
||||
item.title = "Mail title here";
|
||||
}
|
||||
|
||||
_list.EnsureBoundsCorrect();
|
||||
float delay = 0f;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
MailItem item = (MailItem)_list.GetChildAt(i);
|
||||
if (_list.IsChildInView(item))
|
||||
{
|
||||
item.PlayEffect(delay);
|
||||
delay += 0.2f;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b0647927cbff65449b89590caf97481
|
||||
timeCreated: 1446648215
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,41 +0,0 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class MailItem : GButton
|
||||
{
|
||||
GTextField _timeText;
|
||||
Controller _readController;
|
||||
Controller _fetchController;
|
||||
Transition _trans;
|
||||
|
||||
public override void ConstructFromXML(FairyGUI.Utils.XML cxml)
|
||||
{
|
||||
base.ConstructFromXML(cxml);
|
||||
|
||||
_timeText = this.GetChild("timeText").asTextField;
|
||||
_readController = this.GetController("IsRead");
|
||||
_fetchController = this.GetController("c1");
|
||||
_trans = this.GetTransition("t0");
|
||||
}
|
||||
|
||||
public void setTime(string value)
|
||||
{
|
||||
_timeText.text = value;
|
||||
}
|
||||
|
||||
public void setRead(bool value)
|
||||
{
|
||||
_readController.selectedIndex = value ? 1 : 0;
|
||||
}
|
||||
|
||||
public void setFetched(bool value)
|
||||
{
|
||||
_fetchController.selectedIndex = value ? 1 : 0;
|
||||
}
|
||||
|
||||
public void PlayEffect(float delay)
|
||||
{
|
||||
this.visible = false;
|
||||
_trans.Play(1, delay, null);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26140e87934f8754689c7bf2ac147fbe
|
||||
timeCreated: 1446648219
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 029ae1bcb2ae7f2448723a7be724a31d
|
||||
folderAsset: yes
|
||||
timeCreated: 1465913233
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,78 +0,0 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class FilterMain : MonoBehaviour
|
||||
{
|
||||
GComponent _mainView;
|
||||
GSlider _s0;
|
||||
GSlider _s1;
|
||||
GSlider _s2;
|
||||
GSlider _s3;
|
||||
GSlider _s4;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
UIPackage.AddPackage("UI/Filter");
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
_mainView = this.GetComponent<UIPanel>().ui;
|
||||
|
||||
BlurFilter blurFilter = new BlurFilter();
|
||||
blurFilter.blurSize = 2;
|
||||
_mainView.GetChild("n21").filter = blurFilter;
|
||||
|
||||
_s0 = _mainView.GetChild("s0").asSlider;
|
||||
_s1 = _mainView.GetChild("s1").asSlider;
|
||||
_s2 = _mainView.GetChild("s2").asSlider;
|
||||
_s3 = _mainView.GetChild("s3").asSlider;
|
||||
_s4 = _mainView.GetChild("s4").asSlider;
|
||||
|
||||
_s0.value = 100;
|
||||
_s1.value = 100;
|
||||
_s2.value = 100;
|
||||
_s3.value = 200;
|
||||
_s4.value = 20;
|
||||
|
||||
_s0.onChanged.Add(__sliderChanged);
|
||||
_s1.onChanged.Add(__sliderChanged);
|
||||
_s2.onChanged.Add(__sliderChanged);
|
||||
_s3.onChanged.Add(__sliderChanged);
|
||||
_s4.onChanged.Add(__sliderChanged);
|
||||
}
|
||||
|
||||
void __sliderChanged(EventContext context)
|
||||
{
|
||||
int cnt = _mainView.numChildren;
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
GObject obj = _mainView.GetChildAt(i);
|
||||
if (obj.filter is ColorFilter)
|
||||
{
|
||||
ColorFilter filter = (ColorFilter)obj.filter;
|
||||
filter.Reset();
|
||||
filter.AdjustBrightness((float)(_s0.value - 100) / 100f);
|
||||
filter.AdjustContrast((float)(_s1.value - 100) / 100f);
|
||||
filter.AdjustSaturation((float)(_s2.value - 100) / 100f);
|
||||
filter.AdjustHue((float)(_s3.value - 100) / 100f);
|
||||
}
|
||||
else if (obj.filter is BlurFilter)
|
||||
{
|
||||
BlurFilter filter = (BlurFilter)obj.filter;
|
||||
filter.blurSize = (float)_s4.value / 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78878c40447242843aa913ef50cce606
|
||||
timeCreated: 1465402161
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2c523738da07e8498b13cb58f69289e
|
||||
folderAsset: yes
|
||||
timeCreated: 1464248161
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,115 +0,0 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class GestureMain : MonoBehaviour
|
||||
{
|
||||
GComponent _mainView;
|
||||
Transform _ball;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
UIPackage.AddPackage("UI/Gesture");
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
_mainView = this.GetComponent<UIPanel>().ui;
|
||||
GObject holder = _mainView.GetChild("holder");
|
||||
|
||||
_ball = GameObject.Find("Globe").transform;
|
||||
|
||||
SwipeGesture gesture1 = new SwipeGesture(holder);
|
||||
gesture1.onMove.Add(OnSwipeMove);
|
||||
gesture1.onEnd.Add(OnSwipeEnd);
|
||||
|
||||
LongPressGesture gesture2 = new LongPressGesture(holder);
|
||||
gesture2.once = false;
|
||||
gesture2.onAction.Add(OnHold);
|
||||
|
||||
PinchGesture gesture3 = new PinchGesture(holder);
|
||||
gesture3.onAction.Add(OnPinch);
|
||||
|
||||
RotationGesture gesture4 = new RotationGesture(holder);
|
||||
gesture4.onAction.Add(OnRotate);
|
||||
}
|
||||
|
||||
void OnSwipeMove(EventContext context)
|
||||
{
|
||||
SwipeGesture gesture = (SwipeGesture)context.sender;
|
||||
Vector3 v = new Vector3();
|
||||
if (Mathf.Abs(gesture.delta.x) > Mathf.Abs(gesture.delta.y))
|
||||
{
|
||||
v.y = -Mathf.Round(gesture.delta.x);
|
||||
if (Mathf.Abs(v.y) < 2) //消除手抖的影响
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
v.x = -Mathf.Round(gesture.delta.y);
|
||||
if (Mathf.Abs(v.x) < 2)
|
||||
return;
|
||||
}
|
||||
_ball.Rotate(v, Space.World);
|
||||
}
|
||||
|
||||
void OnSwipeEnd(EventContext context)
|
||||
{
|
||||
SwipeGesture gesture = (SwipeGesture)context.sender;
|
||||
Vector3 v = new Vector3();
|
||||
if (Mathf.Abs(gesture.velocity.x) > Mathf.Abs(gesture.velocity.y))
|
||||
{
|
||||
v.y = -Mathf.Round(Mathf.Sign(gesture.velocity.x) * Mathf.Sqrt(Mathf.Abs(gesture.velocity.x)));
|
||||
if (Mathf.Abs(v.y) < 2)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
v.x = -Mathf.Round(Mathf.Sign(gesture.velocity.y) * Mathf.Sqrt(Mathf.Abs(gesture.velocity.y)));
|
||||
if (Mathf.Abs(v.x) < 2)
|
||||
return;
|
||||
}
|
||||
|
||||
GTween.To(v, Vector3.zero, 0.3f).SetTarget(_ball).OnUpdate(
|
||||
(GTweener tweener) =>
|
||||
{
|
||||
_ball.Rotate(tweener.deltaValue.vec3, Space.World);
|
||||
});
|
||||
}
|
||||
|
||||
void OnHold(EventContext context)
|
||||
{
|
||||
GTween.Shake(_ball.transform.localPosition, 0.05f, 0.5f).SetTarget(_ball).OnUpdate(
|
||||
(GTweener tweener) =>
|
||||
{
|
||||
_ball.transform.localPosition = new Vector3(tweener.value.x, tweener.value.y, _ball.transform.localPosition.z);
|
||||
});
|
||||
}
|
||||
|
||||
void OnPinch(EventContext context)
|
||||
{
|
||||
GTween.Kill(_ball);
|
||||
|
||||
PinchGesture gesture = (PinchGesture)context.sender;
|
||||
float newValue = Mathf.Clamp(_ball.localScale.x + gesture.delta, 0.3f, 2);
|
||||
_ball.localScale = new Vector3(newValue, newValue, newValue);
|
||||
}
|
||||
|
||||
void OnRotate(EventContext context)
|
||||
{
|
||||
GTween.Kill(_ball);
|
||||
|
||||
RotationGesture gesture = (RotationGesture)context.sender;
|
||||
_ball.Rotate(Vector3.forward, -gesture.delta, Space.World);
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dffc58029aa66074287bfe11db08a102
|
||||
timeCreated: 1464248165
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf04af674d0fada4d93df62ec9e22a95
|
||||
folderAsset: yes
|
||||
timeCreated: 1456392097
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,44 +0,0 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class GuideMain : MonoBehaviour
|
||||
{
|
||||
GComponent _mainView;
|
||||
GComponent _guideLayer;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
_mainView = this.GetComponent<UIPanel>().ui;
|
||||
|
||||
_guideLayer = UIPackage.CreateObject("Guide", "GuideLayer").asCom;
|
||||
_guideLayer.SetSize(GRoot.inst.width, GRoot.inst.height);
|
||||
_guideLayer.AddRelation(GRoot.inst, RelationType.Size);
|
||||
|
||||
GObject bagBtn = _mainView.GetChild("bagBtn");
|
||||
bagBtn.onClick.Add(() =>
|
||||
{
|
||||
_guideLayer.RemoveFromParent();
|
||||
});
|
||||
|
||||
_mainView.GetChild("n2").onClick.Add(() =>
|
||||
{
|
||||
GRoot.inst.AddChild(_guideLayer); //!!Before using TransformRect(or GlobalToLocal), the object must be added first
|
||||
Rect rect = bagBtn.TransformRect(new Rect(0, 0, bagBtn.width, bagBtn.height), _guideLayer);
|
||||
|
||||
GObject window = _guideLayer.GetChild("window");
|
||||
window.size = new Vector2((int)rect.size.x, (int)rect.size.y);
|
||||
window.TweenMove(new Vector2((int)rect.position.x, (int)rect.position.y), 0.5f);
|
||||
});
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 917e86e515017db488b38e836ed52634
|
||||
timeCreated: 1456392101
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8294eab8d3a942c43aed8054200d3119
|
||||
folderAsset: yes
|
||||
timeCreated: 1446540831
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,34 +0,0 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class HeadBarMain : MonoBehaviour
|
||||
{
|
||||
GComponent _mainView;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
Transform npc = GameObject.Find("npc1").transform;
|
||||
UIPanel panel = npc.Find("HeadBar").GetComponent<UIPanel>();
|
||||
panel.ui.GetChild("name").text = "Long [color=#FFFFFF]Long[/color][img]ui://HeadBar/cool[/img] Name";
|
||||
panel.ui.GetChild("blood").asProgress.value = 75;
|
||||
panel.ui.GetChild("sign").asLoader.url = "ui://HeadBar/task";
|
||||
|
||||
npc = GameObject.Find("npc2").transform;
|
||||
panel = npc.Find("HeadBar").GetComponent<UIPanel>();
|
||||
panel.ui.GetChild("name").text = "Man2";
|
||||
panel.ui.GetChild("blood").asProgress.value = 25;
|
||||
panel.ui.GetChild("sign").asLoader.url = "ui://HeadBar/fighting";
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f24b49a96743734c8d2ef9ba2c9b32d
|
||||
timeCreated: 1446540834
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 108d5a390778d664cb644fadf56d6faf
|
||||
folderAsset: yes
|
||||
timeCreated: 1456474673
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,40 +0,0 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class HitTestMain : MonoBehaviour
|
||||
{
|
||||
Transform cube;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
|
||||
cube = GameObject.Find("Cube").transform;
|
||||
|
||||
Stage.inst.onTouchBegin.Add(OnTouchBegin);
|
||||
}
|
||||
|
||||
void OnTouchBegin()
|
||||
{
|
||||
if (!Stage.isTouchOnUI)
|
||||
{
|
||||
RaycastHit hit;
|
||||
Ray ray = Camera.main.ScreenPointToRay(new Vector2(Stage.inst.touchPosition.x, Screen.height - Stage.inst.touchPosition.y));
|
||||
if (Physics.Raycast(ray, out hit))
|
||||
{
|
||||
if (hit.transform == cube)
|
||||
{
|
||||
Debug.Log("Hit the cube");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12542fe68a883624ea477c953ae0cf52
|
||||
timeCreated: 1456474677
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c90dbc7e654112a4dbaa796e7e3cc987
|
||||
folderAsset: yes
|
||||
timeCreated: 1446193142
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,42 +0,0 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class JoystickMain : MonoBehaviour
|
||||
{
|
||||
GComponent _mainView;
|
||||
GTextField _text;
|
||||
JoystickModule _joystick;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
_mainView = this.GetComponent<UIPanel>().ui;
|
||||
|
||||
_text = _mainView.GetChild("n9").asTextField;
|
||||
|
||||
_joystick = new JoystickModule(_mainView);
|
||||
_joystick.onMove.Add(__joystickMove);
|
||||
_joystick.onEnd.Add(__joystickEnd);
|
||||
}
|
||||
|
||||
void __joystickMove(EventContext context)
|
||||
{
|
||||
float degree = (float)context.data;
|
||||
_text.text = "" + degree;
|
||||
}
|
||||
|
||||
void __joystickEnd()
|
||||
{
|
||||
_text.text = "";
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09cf2c20abdf7ea428bd3f1c68941949
|
||||
timeCreated: 1446193147
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,159 +0,0 @@
|
||||
using FairyGUI;
|
||||
using UnityEngine;
|
||||
|
||||
public class JoystickModule : EventDispatcher
|
||||
{
|
||||
float _InitX;
|
||||
float _InitY;
|
||||
float _startStageX;
|
||||
float _startStageY;
|
||||
float _lastStageX;
|
||||
float _lastStageY;
|
||||
GButton _button;
|
||||
GObject _touchArea;
|
||||
GObject _thumb;
|
||||
GObject _center;
|
||||
int touchId;
|
||||
GTweener _tweener;
|
||||
|
||||
public EventListener onMove { get; private set; }
|
||||
public EventListener onEnd { get; private set; }
|
||||
|
||||
public int radius { get; set; }
|
||||
|
||||
public JoystickModule(GComponent mainView)
|
||||
{
|
||||
onMove = new EventListener(this, "onMove");
|
||||
onEnd = new EventListener(this, "onEnd");
|
||||
|
||||
_button = mainView.GetChild("joystick").asButton;
|
||||
_button.changeStateOnClick = false;
|
||||
_thumb = _button.GetChild("thumb");
|
||||
_touchArea = mainView.GetChild("joystick_touch");
|
||||
_center = mainView.GetChild("joystick_center");
|
||||
|
||||
_InitX = _center.x + _center.width / 2;
|
||||
_InitY = _center.y + _center.height / 2;
|
||||
touchId = -1;
|
||||
radius = 150;
|
||||
|
||||
_touchArea.onTouchBegin.Add(this.OnTouchBegin);
|
||||
_touchArea.onTouchMove.Add(this.OnTouchMove);
|
||||
_touchArea.onTouchEnd.Add(this.OnTouchEnd);
|
||||
}
|
||||
|
||||
public void Trigger(EventContext context)
|
||||
{
|
||||
OnTouchBegin(context);
|
||||
}
|
||||
|
||||
private void OnTouchBegin(EventContext context)
|
||||
{
|
||||
if (touchId == -1)//First touch
|
||||
{
|
||||
InputEvent evt = (InputEvent)context.data;
|
||||
touchId = evt.touchId;
|
||||
|
||||
if (_tweener != null)
|
||||
{
|
||||
_tweener.Kill();
|
||||
_tweener = null;
|
||||
}
|
||||
|
||||
Vector2 pt = GRoot.inst.GlobalToLocal(new Vector2(evt.x, evt.y));
|
||||
float bx = pt.x;
|
||||
float by = pt.y;
|
||||
_button.selected = true;
|
||||
|
||||
if (bx < 0)
|
||||
bx = 0;
|
||||
else if (bx > _touchArea.width)
|
||||
bx = _touchArea.width;
|
||||
|
||||
if (by > GRoot.inst.height)
|
||||
by = GRoot.inst.height;
|
||||
else if (by < _touchArea.y)
|
||||
by = _touchArea.y;
|
||||
|
||||
_lastStageX = bx;
|
||||
_lastStageY = by;
|
||||
_startStageX = bx;
|
||||
_startStageY = by;
|
||||
|
||||
_center.visible = true;
|
||||
_center.SetXY(bx - _center.width / 2, by - _center.height / 2);
|
||||
_button.SetXY(bx - _button.width / 2, by - _button.height / 2);
|
||||
|
||||
float deltaX = bx - _InitX;
|
||||
float deltaY = by - _InitY;
|
||||
float degrees = Mathf.Atan2(deltaY, deltaX) * 180 / Mathf.PI;
|
||||
_thumb.rotation = degrees + 90;
|
||||
|
||||
context.CaptureTouch();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTouchEnd(EventContext context)
|
||||
{
|
||||
InputEvent inputEvt = (InputEvent)context.data;
|
||||
if (touchId != -1 && inputEvt.touchId == touchId)
|
||||
{
|
||||
touchId = -1;
|
||||
_thumb.rotation = _thumb.rotation + 180;
|
||||
_center.visible = false;
|
||||
_tweener = _button.TweenMove(new Vector2(_InitX - _button.width / 2, _InitY - _button.height / 2), 0.3f).OnComplete(() =>
|
||||
{
|
||||
_tweener = null;
|
||||
_button.selected = false;
|
||||
_thumb.rotation = 0;
|
||||
_center.visible = true;
|
||||
_center.SetXY(_InitX - _center.width / 2, _InitY - _center.height / 2);
|
||||
}
|
||||
);
|
||||
|
||||
this.onEnd.Call();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTouchMove(EventContext context)
|
||||
{
|
||||
InputEvent evt = (InputEvent)context.data;
|
||||
if (touchId != -1 && evt.touchId == touchId)
|
||||
{
|
||||
Vector2 pt = GRoot.inst.GlobalToLocal(new Vector2(evt.x, evt.y));
|
||||
float bx = pt.x;
|
||||
float by = pt.y;
|
||||
float moveX = bx - _lastStageX;
|
||||
float moveY = by - _lastStageY;
|
||||
_lastStageX = bx;
|
||||
_lastStageY = by;
|
||||
float buttonX = _button.x + moveX;
|
||||
float buttonY = _button.y + moveY;
|
||||
|
||||
float offsetX = buttonX + _button.width / 2 - _startStageX;
|
||||
float offsetY = buttonY + _button.height / 2 - _startStageY;
|
||||
|
||||
float rad = Mathf.Atan2(offsetY, offsetX);
|
||||
float degree = rad * 180 / Mathf.PI;
|
||||
_thumb.rotation = degree + 90;
|
||||
|
||||
float maxX = radius * Mathf.Cos(rad);
|
||||
float maxY = radius * Mathf.Sin(rad);
|
||||
if (Mathf.Abs(offsetX) > Mathf.Abs(maxX))
|
||||
offsetX = maxX;
|
||||
if (Mathf.Abs(offsetY) > Mathf.Abs(maxY))
|
||||
offsetY = maxY;
|
||||
|
||||
buttonX = _startStageX + offsetX;
|
||||
buttonY = _startStageY + offsetY;
|
||||
if (buttonX < 0)
|
||||
buttonX = 0;
|
||||
if (buttonY > GRoot.inst.height)
|
||||
buttonY = GRoot.inst.height;
|
||||
|
||||
_button.SetXY(buttonX - _button.width / 2, buttonY - _button.height / 2);
|
||||
|
||||
this.onMove.Call(degree);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3af309cbf1dcb94f88c9484271c4c9d
|
||||
timeCreated: 1446193148
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b7ffb771e0a22b4ebf0a7c2bed7d802
|
||||
folderAsset: yes
|
||||
timeCreated: 1456388404
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,63 +0,0 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class LoopListMain : MonoBehaviour
|
||||
{
|
||||
GComponent _mainView;
|
||||
GList _list;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
UIPackage.AddPackage("UI/LoopList");
|
||||
|
||||
_mainView = this.GetComponent<UIPanel>().ui;
|
||||
|
||||
_list = _mainView.GetChild("list").asList;
|
||||
_list.SetVirtualAndLoop();
|
||||
|
||||
_list.itemRenderer = RenderListItem;
|
||||
_list.numItems = 5;
|
||||
_list.scrollPane.onScroll.Add(DoSpecialEffect);
|
||||
|
||||
DoSpecialEffect();
|
||||
}
|
||||
|
||||
void DoSpecialEffect()
|
||||
{
|
||||
//change the scale according to the distance to middle
|
||||
float midX = _list.scrollPane.posX + _list.viewWidth / 2;
|
||||
int cnt = _list.numChildren;
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
GObject obj = _list.GetChildAt(i);
|
||||
float dist = Mathf.Abs(midX - obj.x - obj.width / 2);
|
||||
if (dist > obj.width) //no intersection
|
||||
obj.SetScale(1, 1);
|
||||
else
|
||||
{
|
||||
float ss = 1 + (1 - dist / obj.width) * 0.24f;
|
||||
obj.SetScale(ss, ss);
|
||||
}
|
||||
}
|
||||
|
||||
_mainView.GetChild("n3").text = "" + ((_list.GetFirstChildInView() + 1) % _list.numItems);
|
||||
}
|
||||
|
||||
void RenderListItem(int index, GObject obj)
|
||||
{
|
||||
GButton item = (GButton)obj;
|
||||
item.SetPivot(0.5f, 0.5f);
|
||||
item.icon = UIPackage.GetItemURL("LoopList", "n" + (index + 1));
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bab7cb69f587250498d0079f0e323fb0
|
||||
timeCreated: 1456388407
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d56bcf9c2887a841b07c14e421e98d5
|
||||
folderAsset: yes
|
||||
timeCreated: 1447054712
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,47 +0,0 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class ModalWaitingMain : MonoBehaviour
|
||||
{
|
||||
GComponent _mainView;
|
||||
Window4 _testWin;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
UIPackage.AddPackage("UI/ModalWaiting");
|
||||
UIConfig.globalModalWaiting = "ui://ModalWaiting/GlobalModalWaiting";
|
||||
UIConfig.windowModalWaiting = "ui://ModalWaiting/WindowModalWaiting";
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
_mainView = this.GetComponent<UIPanel>().ui;
|
||||
|
||||
_testWin = new Window4();
|
||||
|
||||
_mainView.GetChild("n0").onClick.Add(() => { _testWin.Show(); });
|
||||
|
||||
StartCoroutine(WaitSomeTime());
|
||||
}
|
||||
|
||||
IEnumerator WaitSomeTime()
|
||||
{
|
||||
GRoot.inst.ShowModalWait();
|
||||
|
||||
yield return new WaitForSeconds(3);
|
||||
|
||||
GRoot.inst.CloseModalWait();
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81df70f0eca40f24eb4d6448b5e3ed22
|
||||
timeCreated: 1447054712
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,20 +0,0 @@
|
||||
using FairyGUI;
|
||||
|
||||
public class Window4 : Window
|
||||
{
|
||||
public Window4()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.contentPane = UIPackage.CreateObject("ModalWaiting", "TestWin").asCom;
|
||||
this.contentPane.GetChild("n1").onClick.Add(OnClick);
|
||||
}
|
||||
|
||||
void OnClick()
|
||||
{
|
||||
this.ShowModalWait();
|
||||
Timers.inst.Add(3, 1, (object param) => { this.CloseModalWait(); });
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac9ab786f60351340a5de178d7d19c0d
|
||||
timeCreated: 1447054712
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b78b9866af43744b820fe19b605d80a
|
||||
folderAsset: yes
|
||||
timeCreated: 1456389889
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user