public WebBrowser() { this.hostView = null; this.parentWin = null; this.internalWebView = null; this.dockedGetterMethod = null; }
public bool AttachView(EditorWindow parent, ScriptableObject webView, bool initialize = false) { this.parentWin = parent; this.internalWebView = webView; if (this.internalWebView != null) { this.hostView = Tools.GetReflectionField<object>(parent, "m_Parent"); this.dockedGetterMethod = this.parentWin.GetType().GetProperty("docked", Tools.FullBinding).GetGetMethod(true); if (this.hostView != null && dockedGetterMethod != null) { if (initialize) { Rect initViewRect = new Rect(0, 20, this.parentWin.position.width, this.parentWin.position.height - ((this.IsDocked()) ? 20 : 40)); this.InitWebView(this.hostView, (int)initViewRect.x, (int)initViewRect.y, (int)initViewRect.width, (int)initViewRect.height, false); this.SetHideFlags(HideFlags.HideAndDontSave); this.AllowRightClickMenu(true); } } else { throw new Exception("Failed to get parent window or docked property"); } } return (this.internalWebView != null); }
public void DrawInspectorGUI(ScriptableObject settings, ServiceItem item, System.Action onReset, GUISkin skin) { if (FlowSystem.GetData() == null) return; ++UnityEditor.EditorGUI.indentLevel; try { if (this.GetAuthPermissions() != AuthKeyPermissions.None && FlowSystem.GetData().IsValidAuthKey() == false) { UnityEditor.EditorGUILayout.HelpBox("Authorization Key is not valid.", UnityEditor.MessageType.Error); FlowSystem.DrawEditorGetKeyButton(skin); } else if (FlowSystem.GetData().IsValidAuthKey(this.GetAuthPermissions()) == false) { UnityEditor.EditorGUILayout.HelpBox("You have no permission to use this service.", UnityEditor.MessageType.Warning); FlowSystem.DrawEditorGetKeyButton(skin); } else { this.DoInspectorGUI(settings, item, onReset, skin); } } catch (UnityException e) { Debug.LogException(e); } --UnityEditor.EditorGUI.indentLevel; }
static public int constructor(IntPtr l) { UnityEngine.ScriptableObject o; o = new UnityEngine.ScriptableObject(); pushObject(l, o); return(1); }
static int CreateInstance(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1 && TypeChecker.CheckTypes <System.Type>(L, 1)) { System.Type arg0 = (System.Type)ToLua.ToObject(L, 1); UnityEngine.ScriptableObject o = UnityEngine.ScriptableObject.CreateInstance(arg0); ToLua.Push(L, o); return(1); } else if (count == 1 && TypeChecker.CheckTypes <string>(L, 1)) { string arg0 = ToLua.ToString(L, 1); UnityEngine.ScriptableObject o = UnityEngine.ScriptableObject.CreateInstance(arg0); ToLua.Push(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.ScriptableObject.CreateInstance")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary> // This makes it easy to create, name and place unique new ScriptableObject asset files. /// </summary> public static void CreateAssetAtPath( ScriptableObject pxObject, string pxPath, string pxFilename ) { string pxFullPath = ""; string pxAssetPath = "Assets"; string pxExtension = ".asset"; bool bPathSupplied = !string.IsNullOrEmpty( pxPath ); bool bFilenameSupplied = !string.IsNullOrEmpty( pxFilename ); // Concatenate the full path for the asset if ( bPathSupplied ) { List<string> pxPathComponents = new List<string>(); bool bAssetPathSupplied = pxPath.StartsWith( pxAssetPath ); if ( !bAssetPathSupplied ) { pxPathComponents.Add( pxAssetPath ); pxPathComponents.Add( "/" ); } pxPathComponents.Add( pxPath ); bool bPathHasTrailingSlash = pxPath.EndsWith( "/" ); if ( !bPathHasTrailingSlash ) { pxPathComponents.Add( "/" ); } if ( bFilenameSupplied ) { pxPathComponents.Add( pxFilename ); bool bExtensionSupplied = pxFilename.EndsWith( pxExtension ); if ( !bExtensionSupplied ) { pxPathComponents.Add( pxExtension ); } } else { pxPathComponents.Add( pxObject.name ); pxPathComponents.Add( pxExtension ); } string[] pxComponentArray = pxPathComponents.ToArray(); pxFullPath = string.Concat( pxComponentArray ); } else { string pxObjectTypeName = pxObject.GetType().Name; pxFullPath = pxAssetPath + "/" + pxObjectTypeName + pxExtension; } // Create the Asset Debug.Log( "Creating asset at: " + pxFullPath + "..." ); AssetDatabase.CreateAsset( pxObject, pxFullPath ); AssetDatabase.SaveAssets(); }
public static void CreateAsset(ScriptableObject o, string name) { string path; if (o.GetType() == typeof(Quest)) { path = "Assets/Resources/Quests"; } else path = "Assets/Resources/Items"; if (Path.GetExtension(path) != "") { path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), ""); } string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/" + name + ".asset"); if (!AssetDatabase.Contains(o)) { AssetDatabase.CreateAsset(o, assetPathAndName); Debug.Log("Asset has been created in " + assetPathAndName); } else { Debug.Log("Asset has already been in database in " + o.ToString()); AssetDatabase.Refresh(); EditorUtility.FocusProjectWindow(); Selection.activeObject = o; return; } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); EditorUtility.FocusProjectWindow(); Selection.activeObject = o; }
void OnGUI() { _sheetIndex = EditorGUILayout.IntField("sheet number: ", _sheetIndex); if (GUILayout.Button("根据文件生成通用配置描述文件", GUILayout.MaxWidth(200), GUILayout.Height(80))) { _ImportCommonCFGCSharp(); } EditorGUILayout.Separator(); _ta = EditorGUILayout.ObjectField("配置描述文件:", _ta, typeof(TextAsset), GUILayout.MinWidth(200)) as TextAsset; if (GUILayout.Button("根据文件生成通用配置数据文件", GUILayout.MaxWidth(200), GUILayout.Height(80))) { AssetUtil.SaveAsset(ScriptableObject.CreateInstance(_ta.name), _ta.name); } EditorGUILayout.Separator(); _so = EditorGUILayout.ObjectField("配置文件:", _so, typeof(ScriptableObject), GUILayout.MinWidth(200)) as ScriptableObject; if (GUILayout.Button("根据文件导入通用配置数据", GUILayout.MaxWidth(200), GUILayout.Height(80))) { _ImportCommonCFGData(); } }
static public int constructor(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif UnityEngine.ScriptableObject o; o = new UnityEngine.ScriptableObject(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
public static void SaveAsset(ScriptableObject asset, string path) { AssetDatabase.CreateAsset(asset, path); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = asset; }
static public int CreateInstance_s(IntPtr l) { try{ if (matchType(l, 1, typeof(string))) { System.String a1; checkType(l, 1, out a1); UnityEngine.ScriptableObject ret = UnityEngine.ScriptableObject.CreateInstance(a1); pushValue(l, ret); return(1); } else if (matchType(l, 1, typeof(System.Type))) { System.Type a1; checkType(l, 1, out a1); UnityEngine.ScriptableObject ret = UnityEngine.ScriptableObject.CreateInstance(a1); pushValue(l, ret); return(1); } LuaDLL.luaL_error(l, "No matched override function to call"); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
//Use this for initialization void Start() { //KEYBOARD/CONTROLLER SWITCH gameScript = ScriptableObject.CreateInstance("GameController"); gameInstance = (GameController)gameScript; gameInstance.Init(); }
protected override void OnValidate() { base.OnValidate(); if (ToDoApplication == null) { _toDoApplicationObject = null; } }
protected void ReplaceDockAreaPane(View dockArea, EditorWindow originalPane, EditorWindow newPane) { if (dockArea.HasField("m_Panes")) { var dockedPanes = dockArea.GetFieldValue <List <EditorWindow> >("m_Panes"); var dockIndex = dockedPanes.IndexOf(originalPane); dockedPanes[dockIndex] = newPane; } }
static public int constructor(IntPtr l) { try { UnityEngine.ScriptableObject o; o = new UnityEngine.ScriptableObject(); pushValue(l, o); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
public static int constructor(IntPtr l) { try { UnityEngine.ScriptableObject o; o=new UnityEngine.ScriptableObject(); pushValue(l,o); return 1; } catch(Exception e) { LuaDLL.luaL_error(l, e.ToString()); return 0; } }
static public int constructor(IntPtr l) { LuaDLL.lua_remove(l, 1); UnityEngine.ScriptableObject o; if (matchType(l, 1)) { o = new UnityEngine.ScriptableObject(); pushObject(l, o); return(1); } LuaDLL.luaL_error(l, "New object failed."); return(0); }
public static int constructor(IntPtr l) { try { UnityEngine.ScriptableObject o; o=new UnityEngine.ScriptableObject(); pushValue(l,true); pushValue(l,o); return 2; } catch(Exception e) { return error(l,e); } }
static public int constructor(IntPtr l) { try { UnityEngine.ScriptableObject o; o = new UnityEngine.ScriptableObject(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
protected static void SwapViews(View a, View b) { var containerA = a.GetPropertyValue <ContainerWindow>("window"); var containerB = b.GetPropertyValue <ContainerWindow>("window"); SetFreezeContainer(containerA, true); SetFreezeContainer(containerB, true); containerA.SetPropertyValue("rootView", b); containerB.SetPropertyValue("rootView", a); SetFreezeContainer(containerA, true); SetFreezeContainer(containerB, true); }
void OnGUI() { if (show == true) { boxColor = new GUIStyle(GUI.skin.box); GUILayout.BeginArea (new Rect (0, 0, Screen.width, Screen.height)); GUILayout.BeginHorizontal (); GUILayout.FlexibleSpace (); GUILayout.BeginVertical (); GUILayout.FlexibleSpace (); // GUILayout.Label("Filter: "); filter = GUILayout.TextArea(filter, 25, GUILayout.Width(200)); filter = filter.ToLower(); //scrollArea = GUILayout.BeginScrollView (scrollArea, GUILayout.Width (900), GUILayout.Height (750)); for (int i = 0; i < content.Count; i++) { if(content[i].Name.ToLower().Contains(filter)) { if(selected == content[i]) { boxColor.normal.textColor = Color.green; boxColor.normal.background = content[i].Icon; } else { boxColor.normal.textColor = Color.white; boxColor.normal.background = content[i].Icon; } GUILayout.Box(content[i].name, boxColor, GUILayout.Height(128), GUILayout.Width(128)); if (Event.current.type == EventType.MouseUp && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) { selected = content[i]; } } } //GUILayout.EndScrollView(); // GUILayout.FlexibleSpace (); GUILayout.EndVertical (); GUILayout.FlexibleSpace (); GUILayout.EndHorizontal (); GUILayout.EndArea (); } }
public static T GetScriptableObjectInterface <T>(this UnityEngine.ScriptableObject o) { var targetType = typeof(T); var objectType = o.GetType(); foreach (var objectInterface in objectType.GetInterfaces()) { if (objectInterface == targetType) { return(o.To <T>()); } } return(default(T)); }
public static bool CanCreateGraphData(ScriptableObject parentObject, FieldInfo fieldInfo, out GraphData graphData) { graphData = null; Type fieldValueType = fieldInfo.FieldType; if (fieldValueType.IsGenericType && (fieldValueType.GetGenericTypeDefinition() == typeof(List<>)) && typeof(ScriptableObject).IsAssignableFrom( fieldValueType.GetGenericArguments()[0])){ object[] attributes = fieldInfo.GetCustomAttributes(false); if (attributes == null || attributes.Length == 0){ return false; } GraphAttribute attribute = attributes .ToList().First((arg) => arg.GetType() == typeof(GraphAttribute)) as GraphAttribute; if (attribute != null){ object fieldValue = fieldInfo.GetValue(parentObject); if (fieldValue == null){ var newList = Activator.CreateInstance(fieldValueType); fieldInfo.SetValue(parentObject, newList); fieldValue = newList; } SerializedObject serializedObject = new SerializedObject(parentObject); graphData = new GraphData(); graphData.ItemBaseType = fieldValueType.GetGenericArguments()[0]; graphData.ItemList = fieldValue as IList; graphData.PropertyName = fieldInfo.Name; graphData.ParentObject = parentObject; graphData.SerializedItemList = serializedObject.FindProperty(fieldInfo.Name); if (string.IsNullOrEmpty(graphData.PropertyName)){ graphData.PropertyName = fieldInfo.Name; } graphData.StartNode = null; if (!string.IsNullOrEmpty(attribute.StartNode)){ graphData.StartNode = serializedObject.FindProperty(attribute.StartNode); if (graphData.StartNode == null){ Debug.LogError("Cant find property with name " + attribute.StartNode +" for this graph"); } else if (false){ //fixme through reflexion get field type graphData.StartNode = null ; Debug.LogError("Start node type is not assignable from graph node type"); } } graphData.SetDefaultStartNodeIfNothingSelected(); return true; } } return false; }
protected void SwapViews(View a, View b) { var containerA = a.GetPropertyValue <ContainerWindow>("window"); var containerB = b.GetPropertyValue <ContainerWindow>("window"); SetFreezeContainer(containerA, true); SetFreezeContainer(containerB, true); Logger.Debug("Swapping views {0} and {1} @ {2} and {3}", a, b, containerA, containerB); containerA.SetPropertyValue("rootView", b); containerB.SetPropertyValue("rootView", a); SetFreezeContainer(containerA, true); SetFreezeContainer(containerB, true); }
public static List <T> GetScriptableObjectInterfaces <T>(this UnityEngine.ScriptableObject o) { var result = new List <T>(); var targetType = typeof(T); var objectType = o.GetType(); foreach (var objectInterface in objectType.GetInterfaces()) { if (objectInterface == targetType) { result.Add(o.To <T>()); } } return(result); }
protected void LoadUrl(string url) { if (!this.webView) { var editorAsm = typeof(SceneView).Assembly; var engineAsm = typeof(ScriptableObject).Assembly; var webViewRect = (Rect)engineAsm.GetType("UnityEngine.GUIClip", throwOnError: true).InvokeMember("Unclip", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public, null, null, new object[] { new Rect(0, 0, this.position.width, this.position.height) }); this.webView = CreateInstance(editorAsm.GetType("UnityEditor.WebView", throwOnError: true)); var hostView = this.GetFieldValue("m_Parent"); this.webView.Invoke("InitWebView", hostView, (int)(webViewRect.x + Paddings.x), (int)(webViewRect.y + Paddings.y), (int)(webViewRect.width - (Paddings.width + Paddings.x)), (int)(webViewRect.height - (Paddings.height + Paddings.y)), false); this.webView.SetPropertyValue("hideFlags", HideFlags.HideAndDontSave); } this.webView.Invoke("SetDelegateObject", this); this.webView.Invoke("LoadURL", url); if (Settings.Current.Verbose) Debug.Log("WebView is loading '" + url + "'."); }
public static void AtlasField(string guid, MadAtlas atlas, string label, MadAtlasBrowser.Changed callback, ScriptableObject parent) { string spriteName = ""; if (!string.IsNullOrEmpty(guid)) { var guids = atlas.ListItemGUIDs(); var index = guids.FindIndex((s) => s == guid); if (index != -1) { spriteName = atlas.items[index].name; } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.TextField(label, spriteName); if (GUILayout.Button("Browse", GUILayout.Width(55))) { MadAtlasBrowser.Show(atlas, guid, callback, parent); } EditorGUILayout.EndHorizontal(); }
public static void AtlasField(SerializedProperty textureField, MadAtlas atlas, string label, ScriptableObject parent) { string guid = textureField.stringValue; string spriteName = ""; if (!string.IsNullOrEmpty(guid) && atlas != null) { var item = atlas.GetItem(guid); if (item != null) { spriteName = item.name; } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.TextField(label, spriteName); MadGUI.ConditionallyEnabled(atlas != null, () => { if (GUILayout.Button("Browse", GUILayout.Width(55))) { MadAtlasBrowser.Show(atlas, textureField, parent); } }); EditorGUILayout.EndHorizontal(); }
/// <summary>Create a new instance and automatically assigns the window, view and container.</summary> public ViewPyramid(ScriptableObject viewOrWindow) { if (!viewOrWindow) { m_window = null; m_view = null; m_container = null; } else if (viewOrWindow.IsOfType(typeof(EditorWindow))) { m_window = viewOrWindow as EditorWindow; m_view = m_window.GetFieldValue <View>("m_Parent"); m_container = m_view.GetPropertyValue <ContainerWindow>("window"); } else if (viewOrWindow.IsOfType(Types.View)) { m_window = null; m_view = viewOrWindow; m_container = m_view.GetPropertyValue <ContainerWindow>("window"); } else if (viewOrWindow.IsOfType(Types.ContainerWindow)) { m_window = null; m_view = viewOrWindow.GetPropertyValue <ContainerWindow>("rootView"); m_container = viewOrWindow; } else { throw new ArgumentException("Param must be of type EditorWindow, View or ContainerWindow", "viewOrWindow"); } if (!m_window && m_view && m_view.IsOfType(Types.HostView)) { m_window = m_view.GetPropertyValue <EditorWindow>("actualView"); } m_windowInstanceID = m_window ? m_window.GetInstanceID() : 0; m_viewInstanceID = m_view ? m_view.GetInstanceID() : 0; m_containerInstanceID = m_container ? m_container.GetInstanceID() : 0; }
static int _CreateUnityEngine_ScriptableObject(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 0) { UnityEngine.ScriptableObject obj = new UnityEngine.ScriptableObject(); ToLua.Push(L, obj); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.ScriptableObject.New")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private void OnGUI() { EditorGUILayout.LabelField($"UniReduxで管理されているStoreのStateを表示します。{(RootId > 0 ? $"Id:{RootId}を表示しています." : "")}"); using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar)) { if (GUILayout.Button("Reload", EditorStyles.toolbarButton, GUILayout.Width(100))) { Reload(); } using (var checkScope = new EditorGUI.ChangeCheckScope()) { if (_searchField == null) { return; } var searchString = _searchField.OnToolbarGUI(_treeView.searchString); if (checkScope.changed) { SessionState.SetString(UniReduxTreeView.SortedColumnIndexStateKey, searchString); _treeView.searchString = searchString; } } EditorGUILayout.LabelField("Store Object", GUILayout.Width(80)); _scriptableObject = EditorGUILayout.ObjectField(_scriptableObject, typeof(UnityEngine.ScriptableObject), true, GUILayout.Width(150)) as UnityEngine.ScriptableObject; _application = _scriptableObject as Application <ToDoState>; if (_application == null) { _scriptableObject = null; } } if (_treeView != null && _treeView.GetRows() != null) { _treeView.OnGUI(new Rect(0, EditorGUIUtility.singleLineHeight * 2.3f, position.width, position.height - EditorGUIUtility.singleLineHeight * 2.3f)); } }
public DefaultItemWindow(ScriptableEditorWindow ownerWindow, ScriptableObject data) { this._data = data; this._ownerWindow = ownerWindow; }
public void SetDelegateObject(ScriptableObject value) { Tools.CallReflectionMethod(this.internalWebView, "SetDelegateObject", value); }
public bool DefineScriptObject(string path, ScriptableObject obj) { return Tools.CallReflectionMethod<bool>(this.internalWebView, "DefineScriptObject", path, obj); }
// PRIVATE STATIC //-------------------------------------- // Methods //-------------------------------------- ///<summary> /// Constructor ///</summary> public UMOMManagerCandidate(MonoScript aMonoScript, ScriptableObject aScriptableObject, SerializedProperty aManagers_serializedproperty) { _monoScript = aMonoScript; _inUseFromAssets_scriptableobject = aScriptableObject; _managersFromRAM_serializedproperty = aManagers_serializedproperty; // _doSetType(); }
private static bool OkToAdd(List<ScriptableObject> items, ScriptableObject item) { if (!item) { Debug.LogError("Can't set item to none."); return false; } if (!(item is IInputBuildProcessor)) { Debug.LogError(string.Format("{0} does not implement {1}." , item.name, typeof(IInputBuildProcessor).Name)); return false; } if (items.Contains(item)) { Debug.LogError(item.name + " already in the processor list."); return false; } IInputBuildProcessor pa = (IInputBuildProcessor)item; if (pa.DuplicatesAllowed) return true; foreach (ScriptableObject itemB in items) { IInputBuildProcessor pb = (IInputBuildProcessor)itemB; if (pb.DuplicatesAllowed) continue; System.Type ta = pb.GetType(); System.Type tb = pa.GetType(); if (ta.IsAssignableFrom(tb) || tb.IsAssignableFrom(ta)) { Debug.LogError(string.Format( "Disallowed dulicate detected. {0} and {1} are same type." , pa.Name, pb.Name)); return false; } } return true; }
public void SetAIInformation(ScriptableObject ai) { // This method is required to access the method below using Reflection this.SetAIInformation(ai as AIInfo); }
public static extern void UnRegisterDownloadDelegate(ScriptableObject d);
public static extern MonoScript FromScriptableObject(ScriptableObject scriptableObject);
public static void Show(MadAtlas atlas, SerializedProperty property, ScriptableObject parent) { if (property != null) { var currentGUID = property.stringValue; Show(atlas, currentGUID, (guid) => { if (parent != null) { property.serializedObject.UpdateIfDirtyOrScript(); property.stringValue = guid; property.serializedObject.ApplyModifiedProperties(); }}, parent); } else { Show(atlas, "", null, parent); } }
public static void CreateAsset(ScriptableObject obj, string path, string name) { CheckDictory(path); AssetDatabase.CreateAsset(obj, path + "/" + name + ".asset"); }
protected abstract void DoInspectorGUI(ScriptableObject settings, ServiceItem item, System.Action onReset, GUISkin skin);
public static extern bool IsDestroyScriptableObject(ScriptableObject target);
/// <summary>Prevents any repaint on the container window. This fixes some glitches on macOS.</summary> /// <param name="containerWindow">The ContainerWindow to freeze the repaints.</param> /// <param name="freeze">Wheter to freeze or unfreeze the container.</param> protected void SetFreezeContainer(ContainerWindow containerWindow, bool freeze) { containerWindow.InvokeMethod("SetFreezeDisplay", freeze); }
public bool DefineScriptObject(string path, ScriptableObject obj);
public static void Show(MadAtlas atlas, string currentGUID, Changed changedCallback, ScriptableObject parent) { //var window = ScriptableObject.CreateInstance<MadAtlasBrowser>(); var browser = EditorWindow.GetWindow<MadAtlasBrowser>(true, "Atlas Browser", true); browser.atlas = atlas; browser.changedCallback = changedCallback; browser.selectedItemGUID = currentGUID; browser.parent = parent; }
public void SetDelegateObject(ScriptableObject value);