Defining custom state list - unity3d

When I attach Interactable component to my prefab, I can choose one (or more) of 4 state blueprints, such as DefaultInteractableStates.asset. Although it contains 4 defined states, I would need to remove "Default state" from that. Is there a way I could define my own list of states? I can see the - button to remove state, but the asset is read-only, so I cannot edit it.

This looks like MRTK
=> in general all the original profile assets are read-only protected.
You always need to make a copy/clone of whatever profile you want to change and edit the copy instead and assign the copy to your profiles.
Also see How to configure Interactable.

Related

Unity Visual Scripting Variable

I have a scene that has 3 buttons, one for each level. I made buttons 2 and 3 uninteractable and I want to make it so when you win the 1st you can start the 2nd etc... So I have unchecked the interactable box from the options of button2. Then I went to the script of my player and I have connected the following parts so when he completes the 1st level the button 2 gets to be interactible. But there seems to be an issue.
(This answer only applies if you were loading new scenes.)
Perhaps, the problem is that you can’t save a variable telling which levels are allowed. (Unless you do it through, an actual save mechanic.) this is because unity destroys all objects in a scene when loading a new scene. This removes all data stored in variables. You could get around this from using
DontDestroyOnLoad(gameObject);
this saves the gameObect variable you put in the parentheses through scene loading. You can attach a script that would store the variables to this, to save information.
If you can’t figure out how to get the variables from other scripts, use this:
var newVariable = GameObjectVariable.GetComponent<scriptName>().variableName;
I see you were using visual coding, so if you can try and figure out how to find these methods in there, it should work.
If you want to use actual save mechanics, go to this link:
https://docs.unity3d.com/ScriptReference/PlayerPrefs.html/
Set Variable need to receive a flow input.

Should I add the information in both side

I am new to unity ,plz forgive me asking these questions
It bumps out : default reference will only be applied in edit mode
Is it important, what is that?
Should I need to add the information(food and border ) to both sides?
The second image are default references. If you set them they are automatically applied after adding this script to an object.
They are not required. And only apply to a script added via the Editor (not by script!). What matters later on runtime are only the values on the GameObject.
Further you can only reference assets from the Assets folder here. They make sense e.g. if you have a button script that uses a certain Click sound, a texture and e.g. a prefab. For these three you now could already define default values so someone using your component doesn't have to assign everything everytime but already has the default references as a kind of fallback.
So in your case it would only make sense, if the borders are prefabs from the Assets that are spawned by this script. The FoodPrefab is even called like this and makes sense to have as a default reference so you don't have to drag it into each and every instance of SpawnFood you create.
And btw just by looking at your settings you should probably directly make your fields of type RectTransform so you can't accidentally reference another object there.

Filtering an object field in Unity Editor Extension

I'm looking to use Unity's ObjectField to have users search for objects of a particular type. I know the constructor allows for a typeOf(objectType), but that does not seem to allow for filtering on custom components.
Essentially, a previous editor script I have sets up objects, and places a unique custom script on each of the components, but I've been unsuccessful in utilizing the ObjectField to search for just those objects. If I change the typeOf in my object field to be my component, it is always empty, despite there being many prefabs with that script attached in my project.
Has anyone had any success with this? Using GameObject finds them, but this finds all game objects. Is there any way to restrict this? Or to keep it only looking at particular folders?
Adding a filter while the field itself stays as type Object is a bit tricky. Here's one way.
Use ShowObjectPicker
Try opening a custom ObjectPicker. To do so you'll have to hide the default object picker and call one with a set searchFilter. It is quite a bit of work.
Setting searchFilter
Use https://docs.unity3d.com/ScriptReference/EditorGUIUtility.ShowObjectPicker.html with a searchFilter that matches the component you add to every object you want to show up in an ObjectPicker. for example "t:objectType".
There's some good information on using ShowObjectPicker at https://answers.unity.com/questions/554012/how-do-i-use-editorguiutilityshowobjectpicker-c.html
Hide default object picker
Here's a post with a way to hide the default object picker Is there any way to hide the "Object picker" of an EditorGUILayout.ObjectField in Unity Isnpector?
Show picker
You'll need to create your own Editor GUI.Button to bring up the ShowObjectPicker with the custom searchFilter.
Assets searchFilter
As a sidenote, to do the same with file assets use a "l:labelName" fileFilter instead of "t:objectType". You can set the label with the Unity Editor UI as shown here:
or with "ref:relative/path/from/assets/to/material/material.mat"

How to get a component to show up in the list of draggable components (for parsys)?

I'm trying to create a component that I can drag into a parsys component, but for some reason it doesn't show up in the list of available components (see images below). I'm pretty new to AEM, so if I sound ignorant, I probably am (edits to this question are welcome).
The first and the foremost requirement for your component to be draggable is to have either a dialog or design_dialog.
Second, it shouldn't be part of the component group .hidden. It is fine if it doesn't have a componentGroup property at all, you can find it under NO GROUP DEFINED.
Set the allowedParents property of type String[] to */parsys.
And finally make sure that the jcr:title is different from the name of your component. They shouldn't be the same. For Eg: If the name of the component is text then the title should at least be Text.
I haven't worked in the touchUI, but for sidekick this holds good. So I guess it should work for your case too.
First: Make sure you have a dialog defined.
Second: Ensure that there is a componentGroup defined that doesn't start with a period. ANY group name that starts with a period will hide the component.
Third: Make sure the component is enabled with design mode.
AEM Mastery blog post about getting a component to show in the sidekick

How do we define global properties in CQ5

My Requirement is to have a global header and footer with author able properties.
So if we update the properties on one page it should be reflected across all pages.
What is the best approach to achieve this in CQ5.
ACS AEM Commons now supports this functionality without use of an iparsys - Shared Component Properties (http://adobe-consulting-services.github.io/acs-aem-commons/features/shared-component-properties.html)
Configure your menu with Shared and/or Global properties and you can simply template it directly onto all of your pages (no iparsys required). You can then edit the header/footer from any page on the site and it will by updated on all pages.
Unlike using design dialogs, Shared Component Properties supports standard content activation and internationalization (values stored below the homepage) and anything else you would expect from content.
If all of your pages site under a hierarchy, you could use an Inherited Paragraph System (iparsys). This is from an old version of the documentation, but is still a good intro:
The inherited paragraph system is a paragraph system that also allows
you to inherit the created paragraphs from the parent. You add
paragraphs to iparsys at for example, /content/geometrixx/en/products
and as result, all the subpages of products that also have iparsys
with the same name inherit the created paragraphs from the parent. On
each level, you can add more paragraphs, which are then inherited by
the children pages. You can also cancel paragraph inheritance at a
level at any time.
While not quite what you're describing in the original post (edit anywhere) it will allow you to edit the content once (at the parent page) and inherit the changes everywhere.
Traditionally you could create the components and swap the dialogs out for design dialogs. Basically you would rename your component dialog to design_dialog.
What this will do is save the changes you make to this object to a design path under etc. You can set a design path for site by going to the top level parent and setting a designPath property.
So node structure might look something like
parentNode
- #prop designPath = "designs/myapplication"
childNode1
childNode2
etc...
Any component using a design_dialog on the parentNode or its children nodes will get their information from the designPath. If you do not set a design path, the infomration is saved under etc/designs/default (or defaults, not sure, going off the top of my head).
There are some alternatives to this:
What our team did was in our siteHeader component we use http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/commons/inherit/InheritanceValueMap.html (inheritancevalue map) instead of the regular value map. The inherited value map will traverse the tree up looking for items from it's parents. This is a great source for learning how to use valuemap instead of just the default properties object:
http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2013/02/valuemap-and-his-friend.html
This does get complicated with larger sites, and you'll have to do a lot of customization to get the system working the way you want, but it's an option if you don't want to have to manually set designPaths for every new site your authors create.
Alternatively, if you do like the idea of using designPaths and design_dialogs, you can always hook into the page creation workflow and have the page component add a designPath property on creation (this is a lot easier said than done though).
hope that helps