公","type":5,"feeType":3,"actUrl":"","newOrHot&quot

gameObject.GetComponent(&Script&).enabled = true not working - Unity Answers
Navigation
Unity account
You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio.
gameObject.GetComponent(&Script&).enabled = true not working
I have created a script that controls Motion Blur image effect but &gameObject.GetComponent(&Script&).enabled =& not working, it says &BCE0019: 'enabled' is not a member of 'ponent'.&
Best Answer
Edit -& Unity 5 : GetComponent(&ScriptName&) is deprecated (the string version). You must use one of the other versions.
Once again. NEVER use the string-based version of the method GetComponent which returns a Component (the compiler cannot infer the type). Instead, use the type-based method:
gameObject.GetComponent( Script ).enabled =
gameObject.GetComponent&Script&().enabled =
(gameObject.GetComponent( typeof(Script) ) as Script).enabled =
or you could do (gameObject.GetComponent( &Script& ) as MonoBehaviour).enabled =
I think it has to be:
gameObject.GetComponent(Script).enabled
If that doesn't work try making a variable out of the GameObject the script is attached to. or try GetComponent(&Script&//or just Script).active
You probably don't want that because it will disable the hole gameObject rather than just the component.
camera.main.gameObject.GetComponent(MouseOrbit).enabled =
I had to use this & to access the First Person Controller component ...
gameObject.GetComponent(UnityStandardAssets.Characters.FirstPerson.FirstPersonController).enabled =
Hint: You can notify a user about this post by typing @username
Attachments: Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
17 People are following this question.AJAX in Plugins & WordPress Codex
Interested in functions, hooks, classes, or methods? Check out the new !
AJAX in Plugins
This article, aimed at plugin developers, describes how to add Ajax to a plugin. Before reading this article, you should be familiar with the following:
- Overview of the technology
- How to write a plugin
- Filters and actions - what they are and how to use them
How to add HTML to the appropriate WordPress page, post, or screen -- for instance, if you want to add Ajax to administration
screens you create, you will need t if you want to add Ajax to the display of a single post, you'll need to figure out the right filters and actions to add HTML to that spot on viewer-facing blog screens. This article does not cover these topics.
Since Ajax is already built into the core WordPress administration screens, adding more administration-side Ajax functionality to your plugin is fairly straightforward.
This short example uses PHP to write our JavaScript in the footer of the page. This script then triggers the AJAX request when the page is fully loaded:
add_action( 'admin_footer', 'my_action_javascript' ); // Write our JS below here
function my_action_javascript() { ?&
&script type=&text/javascript& &
jQuery(document).ready(function($) {
var data = {
'action': 'my_action',
'whatever': 1234
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
jQuery.post(ajaxurl, data, function(response) {
alert('Got this from the server: ' + response);
&/script& &?php
NOTE: Since , The JavaScript global variable ajaxurl can be used in case you want to separate your JavaScript code from php files into JavaScript only files. This is true on the administration side only. If you are using AJAX on the front-end, you need to make your JavaScript aware of the admin-ajax.php url. A best practice is documented in the fourth example, below using wp_localize_script().
Then, set up a PHP function to handle the AJAX request.
add_action( 'wp_ajax_my_action', 'my_action_callback' );
function my_action_callback() {
global $ // this is how you get access to the database
$whatever = intval( $_POST['whatever'] );
$whatever += 10;
wp_die(); // this is required to terminate immediately and return a proper response
Notice how the 'action' key's value 'my_action', defined in our JavaScript above, matches the latter half of the action 'wp_ajax_my_action' in our AJAX handler below. This is because it is used to call the server side PHP function through admin-ajax.php. If an action is not specified, admin-ajax.php will exit, and return 0 in the process.
You will need to add a few details, such as error checking and verifying that the request came from the right place ( using
), but hopefully the example above will be enough to get you started on your own administration-side Ajax plugin.
Notice the use of , instead of die() or exit(). Most of the time you should be using wp_die() in your Ajax callback function. This provides better integration with WordPress and makes it easier to test your code.
The same example as the previous one, except with the JavaScript on a separate external file we'll call js/my_query.js. The examples are relative to a plugin folder.
jQuery(document).ready(function($) {
var data = {
'action': 'my_action',
'whatever': ajax_object.we_value
// We pass php values differently!
// We can also pass the url value separately from ajaxurl for front end AJAX implementations
jQuery.post(ajax_object.ajax_url, data, function(response) {
alert('Got this from the server: ' + response);
With external JavaScript files, we must first
so they are included on the page. Additionally, we must use
to pass values into JavaScript object properties, since PHP cannot directly echo values into our JavaScript file. The handler function is the same as the previous example.
add_action( 'admin_enqueue_scripts', 'my_enqueue' );
function my_enqueue($hook) {
if( 'index.php' != $hook ) {
// Only applies to dashboard panel
wp_enqueue_script( 'ajax-script', plugins_url( '/js/my_query.js', __FILE__ ), array('jquery') );
// in JavaScript, object properties are accessed as ajax_object.ajax_url, ajax_object.we_value
wp_localize_script( 'ajax-script', 'ajax_object',
array( 'ajax_url' =& admin_url( 'admin-ajax.php' ), 'we_value' =& 1234 ) );
// Same handler function...
add_action( 'wp_ajax_my_action', 'my_action_callback' );
function my_action_callback() {
$whatever = intval( $_POST['whatever'] );
$whatever += 10;
Since WordPress 2.8, there is a hook similar to :
executes for users that are not logged in.
So, if you want it to fire on the front-end for both visitors and logged-in users, you can do this:
add_action( 'wp_ajax_my_action', 'my_action_callback' );
add_action( 'wp_ajax_nopriv_my_action', 'my_action_callback' );
Note: Unlike on the admin side, the ajaxurl javascript global does not get automatically defined for you, unless you have
or another Ajax-reliant plugin installed. So instead of relying on a global javascript variable, declare a javascript namespace object with its own property, ajaxurl. You might also use
to make the URL available to your script, and generate it using this expression: admin_url( 'admin-ajax.php' )
Note 2: Both front-end and back-end Ajax requests use admin-ajax.php so
will always return true in your action handling code.
When selectively loading your Ajax script handlers for the front-end and back-end, and using the
function, your wp_ajax_(action) and wp_ajax_nopriv_(action) hooks MUST be inside the is_admin() === true part.
Ajax requests bound to either wp_ajax_ or wp_ajax_nopriv_ actions are executed in the WP Admin context.
Carefully review the actions you are performing in your code since unprivileged users or visitors will be able to trigger requests with elevated permissions that they may not be authorized for.
if ( is_admin() ) {
add_action( 'wp_ajax_my_frontend_action', 'my_frontend_action_callback' );
add_action( 'wp_ajax_nopriv_my_frontend_action', 'my_frontend_action_callback' );
add_action( 'wp_ajax_my_backend_action', 'my_backend_action_callback' );
// Add other back-end action hooks here
// Add non-Ajax front-end action hooks here
Here the Ajax action my_frontend_action will trigger the PHP function my_frontend_action_callback() for all users. The Ajax action my_backend_action will trigger the PHP function my_backend_action_callback() for logged-in users only.
Plugins that insert posts via Ajax, such as infinite scroll plugins, should trigger the post-load event on document.body after posts are inserted. Other scripts that depend on a JavaScript interaction after posts are loaded, such as
script, listen for the post-load event to initialize their required JavaScript. When the post-load event is fired from , for example, AddToAny displays the share buttons for each post, and jQuery Masonry can position each post.
JavaScript triggering the post-load event after posts have been inserted via Ajax:
jQuery( document.body ).trigger( 'post-load' );
Note: Avoid using jQuery's load method with a selector expression to insert posts because it will cause &script& blocks in the response .
JavaScript listening to the post-load event:
jQuery( document.body ).on( 'post-load', function () {
// New posts have been added to the page.
If the Ajax request fails in , the response will be -1 or 0, depending on the reason for the failure. Additionally, if the request succeeds, but the Ajax action does not match a WordPress hook defined with add_action('wp_ajax_(action)', ...) or add_action('wp_ajax_nopriv_(action)', ...), then admin-ajax.php will respond 0.
To parse AJAX, WordPress must be reloaded through the admin-ajax.php script, which means that any PHP errors encountered in the initial page load will also be present in the AJAX parsing. If error_reporting is enabled, these will be echoed to the output buffer, polluting your AJAX response with error messages.
Because of this, care must be taken when debugging Ajax as any PHP notices or messages returned may confuse the parsing of the results or cause your JavaScript to error.
One option if you can't eliminate the messages and must run with
is to clear the buffer immediately before returning your data.
ob_clean();
It is also possible to use tools such as FirePHP to log debug messages to your browsers debug console. An alternative approach is to use a debugging proxy such as fiddler.
- examples on viewer-side AJAX for plugins
Codex Resources
Code is Poetry.http://bcy.net/u/1531855
19个视频,总播放:996
扫描二维码随身看视频
用手机或平板摄像头拍下右侧的二维码,您可以:
1 在手机或平板上继续观看该视频
2 分享给你的微信好友或者朋友圈
好莱坞影院推荐
赌神发哥重出江湖
全球最萌小黄人来了!
下载手机APPPlease note that GitHub no longer supports Internet Explorer versions 7 or 8.
We recommend upgrading to the latest , , or .
If you are using IE 11, make sure you .
opened this Issue Jun 18, 2013
& 13 comments
with its associated java interface:
List& TraduccionVO & getPoblacionesIn( List& ComboVO & poblaciones );
ComboVO#cod -& int code
ComboVO#codStr -& some other String code
yields the following exception:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter '__frch_item_3' not found. Available parameters are [list]
at org.apache.ibatis.session.defaults.DefaultSqlSession$StrictMap.get(DefaultSqlSession.java:257)
at org.apache.ibatis.reflection.wrapper.MapWrapper.get(MapWrapper.java:41)
at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:113)
at org.apache.ibatis.reflection.MetaObject.metaObjectForProperty(MetaObject.java:135)
at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:106)
at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:72)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:77)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:58)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:71)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:100)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:354)
at $Proxy10.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:194)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:114)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)
at $Proxy16.getPoblacionesIn(Unknown Source)
at es.myco.providers.traducciones.dao.TradPoblacionesProviderDAO.getPoblacionesIn(TradPoblacionesProviderDAO.java:47)
at es.myco.providers.traducciones.dao.TradPoblacionesProviderDAOTest.testGetPoblacionesInConElementosNulos(TradPoblacionesProviderDAOTest.java:83)
Also, ognl:ognl:2.6.9, was needed to be added as a dependency. Before adding this dependency MyBatis was complaining about ognl.PropertyAccessor not being found
will update the issue's description to reflect the real issue.
Could you create a test case so that we can reproduce the issue?
By the way, are you sure you are using 3.2.3? (version corrected)
To test item value in a foreach loop, you need to access it via the collection because MyBatis translates the item variable name at runtime.
&foreach item="item" collection="list" index="idx"&
&if test="list[idx] != null"&
Hope this helps.
Something went wrong with that request. Please try again.
You signed in with another tab or window.
to refresh your session.
You signed out in another tab or window.
to refresh your session.http://bcy.net/u/1532759
17个视频,总播放:899
扫描二维码随身看视频
用手机或平板摄像头拍下右侧的二维码,您可以:
1 在手机或平板上继续观看该视频
2 分享给你的微信好友或者朋友圈
好莱坞影院推荐
赌神发哥重出江湖
全球最萌小黄人来了!
下载手机APP}

我要回帖

更多关于 type是什么意思 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信