I am trying to run some editor scripts in the form of ScriptableObject subclasses from batchmode.
These ScriptableObject are getting unloaded prematurely via a call to Resources.UnloadUnusedAssets (called from BuildPipeline.BuildAssetBundles), resulting in the following error:
`MissingReferenceException: The object of type 'Foo' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.`
I had previously seen this error when running via the Editor Test Runner window (rather than batch mode). Setting `hideFlags = HideFlags.DontUnloadUnusedAsset` fixed this, but it's reappears when I run from the command line in batchmode.
Why the different behaviour between batchmode and running within the editor? I am running the following command:
`"C:\Program Files\Unity\Editor\Unity.exe" -batchmode -executeMethod My.App.Namespace.Start -logFile out.txt -buildTarget win64 -projectPath C:\Path\To\Unity\Project`. How can I get batchmode to acknowledge my object's hideFlags?
↧
HideFlags not respected in batch mode
↧
Why does hierarchy not show the gameObject using HideFlags.DontSave ?
Hi,
I made a cube using HideFlags.DontSave in scene1, then I load scene2.
I can see my cube in Game and Scene, but Hierarchy does not show it.
Is something wrong ?
↧
↧
How to manage temporary GameObject with HideFlags.DontSave on recompile
I have a custom editor for a scene component which draws temporary preview objects at edit time. Those objects have HideFlags.DontSave set, so that they are deleted when the scene is closed. (Is this bad practice, should I be checking for ApplicationQuit and delete them myself?)
My editor code uses OnEnable to find an existing temp object or create a new one. Everything works fine until I recompile, at which point I get multiple copies of the temp objects in the scene. Any ideas how to avoid this? It's not a big problem to delete additional copies as soon as I find them, but it feels dirty. There must be a clean way, just like the SceneView camera object works. Can I maybe use callbacks to store references or delete them at recompilation?
[CustomEditor(typeof(MapView))]
public class MapEditor : Editor
{
PreviewObject previewObject;
void OnEnable()
{
var allPreviews = Resources.FindObjectsOfTypeAll();
if (allPreviews.Length > 0)
previewObject = allPreviews[0];
if (previewObject == null)
{
var go = EditorUtility.CreateGameObjectWithHideFlags("Preview Object", HideFlags.DontSave, typeof(PreviewObject));
previewObject = go.GetComponent();
}
}
}
↧
HideInHierarchy But Still Selectable
Hi All,
Is there a way to select an object that has its hideFlags set to HideInHierarchy?
I would like to hide a submesh but still have its parent selectable in the SceneView. This currently doesn't work as the parent doesn't contain a mesh.
The parent does have the [SelectionBase] attribute but again it's not usable if there is nothing to contact.
Thanks,
↧
is there a way to hide an object synchronously?
Hi,
(this is my first post here, I'm a 4 days-old Unity user :) )
I draw some tiles (quads) in a RenderTexture (RT) and use the RT as a texture for another mesh.
it works fine but I would like to hide the quads once the render is over.
the idea would be to 1 show the tiles, 2 take a snapshot ( cam.Render() ) and 3 hide the tiles again in the update loop.
I tried the following to hide my tiles:
tile.GetComponent().enabled = true/false;
//and / or
tile.SetActive( true/false );
but nothing shows in the RT, I suspect it's either because **GetComponent()** and **SetActive()** are not synchronous so there is some time between the call and the tile being effectively altered, or because the Update() methods is called during the draw call ; in that case the enabled/active flags are not taken inot account.
also, I tried to store the tiles in a separate scene, but they show anyway.
As mentioned above, I'm very new to Unity, I may just have missed something obvious.
thanks in advance for your time
↧
↧
HideFlags.HideInHierarchy not updating hierarchy in Edit-mode
Hey there guys.
So here is the deal:
I made a window to allow me to quickly hide and unhide objects in my hierarchy. Here it is:
![alt text][1]
[1]: /storage/temp/82297-window.png
Yeah.... I'm making a MLG-style-game. Dont judge me :P
Alright. So to hide my objects I use this:
foreach (GameObject effect in GameObject.FindGameObjectsWithTag("Effect")) {
effect.SetActive (false);
if (effectsVisible)
effect.hideFlags = HideFlags.None;
else
effect.hideFlags = HideFlags.HideInHierarchy;
effect.SetActive (true);
Repaint ();
EditorApplication.RepaintHierarchyWindow ();
}
This is the "Effects visible" button. This should work but... it doesnt really. The hierarchyjust doesnt update when I press the button, It does however update when I close and reopen it. Then my Hideflags are set correctly.
Is there a way to reload the hierarchy via script or to set the hideflags in a way that automatically updates the hierarchy?
Thanks in advance guys :D
↧
HideFlags and Prefabs
My editor scripts create a prefab and then set it's hideFlags to HideFlags.NotEditable, HideFlags.HideInInspector and HideFlags.HideInHierarchy.
Everything goes right until I save and reload my scene. The prefab do not have the hideFlags any more.
This is a bug or i need to set every time the hideFlags?
↧
How can I set a selection-sphere in the editor
I have a gameobject in my unity editor.
It only has one component, which adds an "editor preview" as child-object.
The child object has `.hideFlags = HideFlags.NotEditable | HideFlags.DontSave | HideFlags.HideInHierarchy | HideFlags.HideInHierarchy;` set.
### Problem
My object is not selectable in the scene view.
Can I do something like "AddSelectionCollider()" ??
↧
OnDrawGizmos() is never called when hideFlags is set HideInHierarchy when the object created.
OnDrawGizmos() is never called when hideFlags is set HideInHierarchy when the object created.
And I changed the object's Hideflag to None. But still not called.
I tested some situation, and got some hints.
I made an object that Hide flag is none, and the object called OnDrawGizmos() very well.
And I change the object's option to HideInHierarchy and the object's still called OnDrawGizmos() very well.
I don't know what is right state, (Not called OnDrawGizmo(), or called the func in hide state.)
but I think it was somethings wrong.
Anybody knows this problem? I need some solution.
For my bad English, I put some sample code in here.
public class SomeComponents: MonoBehaviour
{
void OnDrawGizmos()
{
//some rendering code..
}
}
<< Situation 1>>
void Create()
{
GameObject goObj = new GameObject();
SomeComponents cpnt = goObj.AddComponent();
goObj.hideFlags = HideFlags.HideInHierarchy;
}
void SomeFunc1()
{
goObj.hideFlags = HideFlags.None;
}
void SomeFunc2()
{
goObj.hideFlags = HideFlags.HideInHierarchy;
}
In Situation 1, I create object and call SomeFunc1()
=> still NOT called OnDrawGizmos().<< Situation 2>>
void Create()
{
GameObject goObj = new GameObject();
SomeComponents cpnt = goObj.AddComponent();
goObj.hideFlags = HideFlags.None;
}
void SomeFunc1()
{
goObj.hideFlags = HideFlags.None;
}
void SomeFunc2()
{
goObj.hideFlags = HideFlags.HideInHierarchy;
}
In Situation 2, I create object and call SomeFunc2() => still called OnDrawGizmos().!!
What is the problem?
↧
↧
Enabling a hidden GameObject with a MeshRenderer - makes it visible in previews.
I'd like to confirm this is a bug, and not something I am doing wrong.
Given the monobehavior below:
If I click in its inspector - createItHidden , then click createItNow, then disable, and renable this monobehavor object:
The created object is visible, not only in the scene, but ALSO in the project's icons, an inspectors preview's (materials, models)
![alt text][1]
[ExecuteInEditMode]
public class HiddenObjectCreator : MonoBehaviour {
public GameObject hiddenObject;
public bool createItNow = false;
public bool createItHidden = false;
private void OnEnable()
{
if(hiddenObject)
hiddenObject.SetActive(true);
}
private void OnDisable()
{
if (hiddenObject)
hiddenObject.SetActive(false);
}
// Update is called once per frame
void Update ()
{
if (createItNow)
{
createItNow = false;
hiddenObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
hiddenObject.transform.localScale = new Vector3(.1f, 2, .1f);
if (createItHidden)
hiddenObject.hideFlags = HideFlags.HideAndDontSave;
}
}
}
[1]: /storage/temp/104600-hidenobjectinpreviews.png
↧
Error preventing build "An asset is marked with HideFlags.DontSave but is included in the build"
Hello,
I am currently struggling to find a solution to this problem: basically, on Unity 2017.2.1f1, I am getting this error:
An asset is marked with HideFlags.DontSave but is included in the build:
Asset: 'Library/unity editor resources'
Asset name: sv_label_1
(You are probably referencing internal Unity data in your build.)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
I tried going through all the code I have, trying to find incorrectly referenced Editor code.
Can anyone help me pointing me more precisely?
Thanks!
↧
HideFlags.HideAndDontSave does behaviour in 2017.4.0f1
HideFlags.HideAndDontSave is not destroying any object created in edit mode when change scenes or switching to play mode.
If I use any HideFlags.DontSave, the gameObject will still be there but not will not shown in Hierarchy.
Any ideas how to fix this? This is the intented behaviour?
↧
How can I create, via script, a hidden subasset (ScriptableObject) that is editor-only and invisible in Project view?
I am creating an asset (ScriptableObject) that is accesible to the user at runtime, with `AssetDatabase.CreateAsset`. Inside this asset, I am creating a metadata sub-asset with `AssetDatabase.AddObjectToAsset`.
I need this object to be editor-only (not included in builds, and unavailable at runtime).
I know that if the user doesn't reference this asset, it won't be included in builds.
So I want to hide this subasset from Project view, so that it isn't displayed to the user in the editor.
**Problem #1:** Setting `hideFlags` via script doesn't seem to work with `AddObjectToAsset`, the sub-asset is created with `m_ObjectHideFlags = 0` anyways.If I somehow manage to set it (by manually opening the .asset file and setting that field to `HideFlags.HideInHierarchy`, which is value 1), then the subasset is correctly hidden in Project view. But I need a way to set this flag via script.
**Edit:** The serializer works, it was my mistake.
**Problem #2:** When the sub-asset is hidden, using `AssetDatabase.LoadAssetAtPath(mainAssetPath)` returns null.
**Workaround for #2:** While I was typing, I found out that this code works:
`AssetDatabase.LoadAllAssetsAtPath(mainAssetPath).OfType().FirstOrDefault()`
I'm leaving the solution here in case anyone needs this.
↧
↧
Unity PERSISTENT error: Assertion failed on expression: 'VCCache::instance != NULL' unity
I have a custom menu item in a Unity2019.1.5f1 project which shows/hides several objects (from hierarchy) and components (from inspectors). To hide objects/components I set their hideFlags property.
----------
After I restart Unity, **with or without that script** existing in my assets, I got the following error when exiting play mode:
---> **Assertion failed on expression:** 'VCCache::instance != NULL' unity
----------
The menu item function works as expected but every time if I exit playmode with objects/components hidden I got an error:
---> **Assertion failed on expression:** 'ptr->GetHideFlags() == m_RequiredHideFlags'
----------
Is there someone who knows how to solve this?
Should I report the issue?
↧
How to disable game object from the scene.
![alt text][1]
[1]: /storage/temp/159865-screen3.png
HI There i am new to unity and started basics while practicing i found an issue that is when i am
trying to hide a game object using SetActive function from editor scene it is showing as hided but in
real time scene it is still showing the object. And i have attached few screenshots for reference and
script file that i am using to hide objects added here at the below.
// MainMenu
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class MainMenu : MonoBehaviour
{
public string firstLevel;
public Image optionsMenu;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void CloseOptions(){
optionsMenu.gameObject.SetActive(false);
}
public void OpenOptions(){
optionsMenu.gameObject.SetActive(true);
}
public void StartGame(){
SceneManager.LoadScene(firstLevel);
}
public void QuitGame(){
Application.Quit();
}
}
↧
build error: HideFlags.DontSave with asset named PreMatLight0
hi
i getting build error on one of scenes that says:
**An asset is marked with HideFlags.DontSave but is included in the build:
Asset: 'Library/unity editor resources'
Asset name: PreMatLight0
(You are probably referencing internal Unity data in your build.)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)**
searched on the internet looks like no one asked before about this and i looked over all images on that specific scene and no item named PreMatLight0 attached to them
this error only occur when that specific scene is on build list and ticked if i build game without that scene everything is fine
searched on the internet and found out its a built-in image of the editor but im just using default ui-mask and background from built-in images which should be fine
target is android with unity 2019.2.17f1
↧
DontDestroyOnLoad vs Hideflags.DontSave
What's the difference between DontDestroyOnLoad vs Hideflags.DontSave. I have an audio system in form of a scriptable object. It has some functions like PlaySfx or PlayMusic that other objects can call. When the game first starts, the scriptable object will create a placeholding object to hold an AudioSource component. So it's obvious that I want this placeholding object to be persistent for the hold game. Should I use DontDestroyOnLoad or Hideflags.DontSave in this example? Another situation that I may have is my pooling system. I want to allocate many objects at the beginning of the game and need it to stay persistent across all scenes. What's should I use in this instance?
↧
↧