Categories
Unity Programming

Fixing Unity UI TextInput Issues

While working with Unity we noticed a number of issues with the TextField component, problems such as being unable to click on or focus the text field and not accepting keyboard input or displaying a flashing caret to indicate.

  1. Check the EventSystem object is added to your project, if not you can add this by going to Add New Object > UI > EventObject.
  2. Check for any object that overlays your InputField object, either remove the overlaying object or add a Graphic Raycasting component to the object.
  3. Unity does not support rich text on the placeholder text, deselect the rich text checkbox on the TextField component.
Categories
Unity Programming

Fix Issues Upgrading from Unity 2018 to 2019

When upgrading from Unity 2018 to Unity 2019 or opening a project from 2018 in a Unity 2019 version you can get some errors. Don’t panic, this is to be expected and these can be easily fixed.

UIElements Error

Error: The type or namespace name “ElementName” could not be found

Solution: Remove the namespace .Experimental from the UIElements using statements (at the top of all affected scripts).

2018: using UnityEngine.Experimental.UIElements;
2019: using UnityEngine.UIElements;

GetRootVisualContainer Error

Error: … does not contain a definition for ‘GetRootVisualContainer’ and no accessible extension method ‘GetRootVisualContainer’ accepting a first argument of type

Solution:​ Calls to EditorWindow.GetRootVisualContainer()​ need to be updated to the EditorWindow.rootVisualElement​ property.

2018: EditorWindow.GetRootVisualContainer()
2019: EditorWindow.rootVisualElement​

ClippingOptions Error

Error: The name ‘ClippingOptions’ does not exist in the current context

Reason: The ​ClippingOptions​ property is now split between the ​cacheAsBitmap and style.overflow ​properties​.

Solution: ​Set ​cacheAsBitmap​ to true to trigger bitmap caching, which also requires that the element received has the ​overflow​ property value set to Overflow.Hidden

2018: this.clippingOptions = ClippingOptions.ClipAndCacheContents;
2019: this.cacheAsBitmap = true;

CloneTree Error

Error: The call is ambiguous between the following methods or properties: ‘VisualTreeAsset.CloneTree(string)’ and ‘VisualTreeAsset.CloneTree(VisualElement)’

Reason: VisualTreeAsset.CloneTree no longer accepts a dictionary.

Solution: Call this method without any argument.

2018: VisualTreeAsset.CloneTree(null)
2019: VisualTreeAsset.CloneTree()

AddStyleSheetPath Error

Error: ‘VisualElement’ does not contain a definition for ‘AddStyleSheetPath’ and no accessible extension method ‘AddStyleSheetPath’ accepting a first argument of type ‘VisualElement’ could be found

Reason: AddStyleSheetPath()​ and related methods were removed to decouple UIElements from resources folders.

Solution: You can use the ​styleSheets​ property and explicitly load style sheets via the ​Resources​ class or ​AssetDatabase​ class.

2018: GetRootVisualContainer().AddStyleSheetPath("Assets/styles.uss")
2019: rootVisualElement.styleSheets.Add(Resources.Load("Assets/styles.uss"));

Categories
Releases

AlienScience WordPress Theme

Introducing the first WordPress theme release by Higher Coding: AlienScience and the premium version AlienScience Declassified.

AlienScience is a responsive and semantic HTML5 theme perfect for science or space related websites with some great features such as a responsive layout, semantic markup, support for a jQuery content slider, custom header icons and more.

 

Categories
Coding

How to Fix Facebook PHP SDK Error When Updating

A recent update to the Facebook SDK has caused issues with some older versions which causes the following error:

PHP Fatal error: Cannot use object of type stdClass as array in FacebookRedirectLoginHelper.php on line 191

To fix this issue, go to FacebookRedirectLoginHelper.php then find $response['access_token']

You will see this code:

if (isset($response['access_token'])) {
    return new FacebookSession($response['access_token']);
}

Replace it with this:

if (isset($response->access_token)) {
    return new FacebookSession($response->access_token);
}